如何比较两个图像的相似性(与MD5不完全匹配)?
How can I take two images and compare them to see how similar they are?
I'm not talking about comparing two exact images using MD5. The two images that I am comparing will be completely different, as well as likely different sizes at times.
Using Pokemon cards as an example: I'm going to have scanned HD images of each of the cards. I want the user to be able to take a picture of their Pokemon card with their phone and I want to be able to compare it against my scanned images and then determine which card it is that they took a picture of.
The processing does not have to be done directly on the phone, offloading to a web service is an option however note that my knowledge somewhat limited on the programming languages (limited to PHP/JAVA/Android pretty much). The server I'm using is my own Ubuntu server so I do have access to the exec command from php if this would help.
At first I figured someone would have done something like this before (comparing two images). I tried using php with imageik using an example I found that claimed to do what I was trying ( utilizing compareImages() ), but it didn't work at all. There doesn't seem to be much (if any) documentation on doing something like this which is why I'm so stuck. All I'm looking for is a push in the right direction.
My second thought was to try using OCR to pull just the title of the card and I would just compare that against a database of titles and display the images tied to that title. So far I've tried using phpocr first, which didnt work at all as it requires monochrome images to my understanding. Next I tried tesseract directly from the console on my server, and while it did WAY better than phpocr, more than 80% of the characters were either wrong or incorrect on a scanned image, so a lower quality image coming from a smart phone would really have troubles.
I also tried OpenCV for Android but couldnt get any of the samples working.
Has anyone done anything like this, or at least used something that can accomplish what Im looking for?
如何拍摄两张图像并进行比较以查看它们的相似程度? p>
我不是在谈论使用MD5比较两个精确的图像。 我正在比较的两个图像将完全不同,有时可能会有不同的大小。 p>
使用口袋妖怪卡作为示例: 我将扫描高清图像 每张牌。 我希望用户能够用他们的手机拍摄他们的口袋妖怪卡片,我希望能够将它与我的扫描图像进行比较,然后确定他们拍摄的是哪张卡片。 p> \ n
处理不必直接在手机上完成,卸载到Web服务是一个选项,但请注意我的知识在某种程度上限于编程语言(仅限于PHP / JAVA / Android)。 我正在使用的服务器是我自己的Ubuntu服务器,所以我可以从php访问exec命令,如果这会有所帮助。 p>
起初我认为有人会做过这样的事情之前 (比较两张图片)。 我尝试使用php与imageik使用我发现声称做我正在尝试的例子(利用compareImages()),但它根本不起作用。 似乎没有太多(如果有的话)关于做这样的事情的文件,这就是为什么我这么卡住了。 所有我正在寻找的是推动正确的方向。 p>
我的第二个想法是尝试使用OCR来提取卡片的标题,我只是将它与数据库进行比较 标题并显示与该标题相关的图像。 到目前为止,我已经尝试过首先使用phpocr,它根本不起作用,因为它需要我理解的单色图像。 接下来我直接在我的服务器上的控制台上尝试了tesseract,虽然它比phpocr做得更好,但是超过80%的字符在扫描图像上是错误的或不正确的,所以来自智能手机的低质量图像真的会 有麻烦。 p>
我也试过OpenCV for Android但是无法使任何样本正常工作。 p>
有没有人做过这样的事情,或者至少 用过什么东西可以完成我想要的东西? p> div>
There are two distinct tasks - identify area of interest ( which can be done with Haar cascades - same as face detection ) and recognition of identified image which can be
done with invariant moment techniques (like Hu moments - it was good enough to count soviet tanks on satellite images so it shall be good for pokemons). Nice property of invariant moments is soft degradation of results in case of low quality - you get a list of probability for symbols - like this is 80% pikachu and 30% something else.
We are developing OCR library based on invariant moments for use in android here:
https://sourceforge.net/projects/javaocr/
( pure java and reasonable speed , and there are android samples in demos subdirectory. And here is app based on javaocr, it will recognize black on white phone number and dial it: https://play.google.com/store/apps/details?id=de.pribluda.android.ocrcall&feature=search_result#?t=W251bGwsMSwyLDEsImRlLnByaWJsdWRhLmFuZHJvaWQub2NyY2FsbCJd )
You may also consider some aiming help so user positions symbol to be matched properly ( so first task will use real intellect )
You should decide what kind of similarity comparison you need. There are geometric algorithms. They use edge detection and then try to match detected edges in both images. They are probably useful when dealing with different colours of objects with the same shape. And there are algorithms that are more based on colour similarity. They compare what colours are in the image and how they are distributed.
If you are looking for a concrete algorithm, you probably should have a look at the Hough Transform.