There is no such a function I'm aware off in OpenCV, but it can easily be implemented. Any function that return's a sum of the elements will be wrong, because differences in one pixel can be compensated by differences in other pixels. The only way to guarantee correctness is by doing a pixel by pixel check. Here is a simple example:
template<typename T>
bool identical(cv::Mat m1, cv::Mat m2)
{
if(m1.cols != m2.cols || m1.rows != m2.rows)
return false;
for(int i=0; i<m1.rows; i++)
{
for(int j=0; j<m1.cols; j++)
{
if(m1.at<T>(i, j) != m2.at<T>(i, j))
return false;
}
}
return true;
}
I didn't checked the code, so, be careful just doing a 'ctrl+c'.