Compare Images in Python

前端 未结 3 1135
[愿得一人]
[愿得一人] 2020-12-28 10:21

I need to compare two images that are screenshots of a software. I want to check if the two images are identical, including the numbers and letters displayed in the images.

3条回答
  •  感动是毒
    2020-12-28 11:02

    I can't give a ready to use answer, but I will point you in (I think) the right direction. A simple way of comparing two images is by making a hash of their binary representations and then see if those hashes are the same. One problem with this is with the hash function you want to use and you must look for one that have low chances of collisions, and the other is that an image file probably has metadata attached to the original binary information, so you will have to look at how to cut off that metadata in order to compare the images only using their binary info. Also, I don't know for sure but probably the binary representation of an image encoded in jpg is different from an image encoded in png, so you should be aware of that.

提交回复
热议问题