How to determine if a cv::Mat is a zero matrix?
c++, compare, matrix, opencv
Solution
I used
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.
Problem
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 \n" << NewData.rows << "x" << NewData.cols << endl; cout << "The New Data is: \n" << NewData << endl << endl; NewData_Vector.push_back(NewData.clone()); } ``` 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. Is there a simple way of determining when a cv::Mat is populated by zeroes?