You need to run SIFT on both images to get points of interest (let's call them Keypoints) on both images.
After that, you need to find matches between the key points in both images. For this purpose, algorithms are implemented in OpenCV.
The similarity value can be calculated from the number of matches. You might think that if you get more than 4 points, the images will be the same, and you can also calculate the relative rotation between them.
source share