If you want to get down and dirty, download the opencv library.
This page from the OpenCV documentation details how to check for similarity. USE THE PSNR METHOD--this is a direct pixel comparison. SSIM is an adaptive similarity method, so that things which -look- similar will return a higher level of similarity confidence, but because you are comparing identical things there is no reason to go to the extra effort and put in the extra processing power required for SSIM.
You can also ignore everything about the video stream--use
cv2.imread instead. Documentation for imread here.You could set up an interesting method to read the next image by defining a variable that adds 1 at the end of a while() loop, and then save your images in ascending numeric count.