How to determine if a cv::Mat is a zero matrix?(如何确定 cv::Mat 是否为零矩阵?)
问题描述
我有一个根据以下代码动态更改的矩阵;
I have a matrix that is dynamically being changed according to the following code;
for( It=all_frames.begin(); It != all_frames.end(); ++It)
{
ItTemp = *It;
subtract(ItTemp, Base, NewData);
cout << "The size of the new data for ";
cout << " is
" << NewData.rows << "x" << NewData.cols << endl;
cout << "The New Data is:
" << NewData << endl << endl;
NewData_Vector.push_back(NewData.clone());
}
我想要做的是确定 cv::Mat NewData 是零矩阵的帧.我尝试使用 cv::compare() 函数和简单的运算符(即 NewData == NoData)将它与大小相同的零矩阵进行比较,但我什至无法编译程序.
What I want to do is determine the frames at which the cv::Mat NewData is a zero matrix. I've tried comparing it to a zero matrix that is of the same size, using both the cv::compare() function and simple operators (i.e NewData == NoData), but I can't even compile the program.
是否有一种简单的方法可以确定 cv::Mat 何时填充零?
Is there a simple way of determining when a cv::Mat is populated by zeroes?
推荐答案
我用过
if (countNonZero(NewData) < 1)
{
cout << "Eye contact occurs in this frame" << endl;
}
这是一种非常简单(也许不是最优雅)的方法.
This is a pretty simple (if perhaps not the most elegant) way of doing it.
这篇关于如何确定 cv::Mat 是否为零矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何确定 cv::Mat 是否为零矩阵?


基础教程推荐
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31