As mentioned by Acme, you can use cv::compare
although it is not as clean as you might hope.
In the following example, cv::compare
is called by using the !=
operator:
// Get a matrix with non-zero values at points where the
// two matrices have different values
cv::Mat diff = a != b;
// Equal if no elements disagree
bool eq = cv::countNonZero(diff) == 0;
Presumably it would be quicker to just iterate through comparing the elements though? If you know the type you could use the STL equal function:
bool eq = std::equal(a.begin<uchar>(), a.end<uchar>(), b.begin<uchar>());