How to verify that two images are exactly identical?

open("image1.jpg","rb").read() == open("image2.jpg","rb").read()

should tell you if they are exactly the same ...


How about giving your Images an index?

Pseudocode:

class Frame
{
   cvImage img;
   uint    idx;
}

Than simply check if the current index is greater than the last one you processed. It is simple and definitely faster than any image processing based approach.


I was doing something close to what you are doing; I was trying to get the difference. I used the subtract function. It may help you.

UPDATE:

import cv2
import numpy as np
a = cv2.imread("sample1.png")
b = cv2.imread("sample2.png")
difference = cv2.subtract(a, b)    
result = not np.any(difference)
if result is True:
    print "Pictures are the same"
else:
    cv2.imwrite("ed.jpg", difference )
    print "Pictures are different, the difference is stored as ed.jpg"