Quyền Anh Quyền Anh - 1 year ago 184
C++ Question

Compare 2 cv::Mat

I have 2 cv::Mat array (with same size), and when I want to compare them (if identical), I used cv::compare


Is there any function that return true/false?

Answer Source

If you need to compare 2 cv::Mat by sizes, then you might check

if(mat1.size() == mat2.size())
    //do stuff
    //do other stuff

If you need to check if 2 cv::Mat are equal, you can perform the AND operator and check if the result is a cv::Mat full of zeros:

cv::bitwise_and(mat1, mat2, dst);        
if(cv::countNonZero(dst) > 0) //check non-0 pixels
   //do stuff in case cv::Mat are not the same
  //do stuff in case they are equal
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download