如何确定 cv::Mat 是否为零矩阵?

编程入门 行业动态 更新时间:2024-10-22 05:13:18
本文介绍了如何确定 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 是否为零矩阵?

本文发布于:2023-11-29 17:18:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647073.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:矩阵   为零   cv   Mat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!