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?
The Mat class of OpenCV library is used to store the values of an image. It represents an n-dimensional array and is used to store image data of grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms, etc.
In OpenCV the main matrix class is called Mat and is contained in the OpenCV-namespace cv. This matrix is not templated but nevertheless can contain different data types. These are indicated by a certain type-number. Additionally, OpenCV provides a templated class called Mat_, which is derived from Mat.
The Mat object has an empty property, so you can just ask Mat to tell you if it has something or it's empty. The result will be either true or false .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With