I don't imagine an Algoritm that do that
an image can be affected by differences in light of the time, including taking the picture from the exact same place as the first, by comparing pixel by pixel values could give differences.
There are currently Alarm applications that forces you to take a picture of an object (that has previously photographed) and finding the coincidence, your alarm stops ringing. it forces you to wake up., but I honestly do not understand how they succeed.