我目前正在构建基本上相当于搜索引擎和网络漫画画廊之间的交叉点,其重点是引用来源和给予作者信用。
我正在尝试找出一种方法来搜索图像以查找其中的字符。
例如:
假设我将红色字符和绿色字符保存为红人和绿人,如何确定图像是否包含其中之一。
这不需要 100% 的识别或者任何东西,这更多的是我想创建的附加功能,我只是不知道从哪里开始。我已经在谷歌上搜索了很多关于图像识别的信息,但没有发现太多帮助。
就其价值而言,我更喜欢使用 Python 来完成此操作。
I'm currently building what basically amounts to a cross between a search engine and a gallery for web comics that's focused on citing sources and giving authors credit.
I'm trying to figure out a way to search an image to find characters within it.
For example:
Assuming I have the red character and the green character saved as Red Man and Green Man how do I determine if an image contains one or the other.
This doesn't need to have 100% recognition or anything is this is more of an added feature I'd like to create, I'm just not sure where to start. I've done a lot of googling for image recognition but haven't found much helpful.
For what it's worth, I'd prefer to do this using Python.
发布评论
评论(4)
Moshe 的答案仅涵盖匹配给定图片中仅包含一次的模板。以下是一次匹配多个的方法:(
注意:我更改并修复了原始代码中的一些“错误”)
结果:
< /a>
来源: https://opencv24-python-tutorials.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html#template-matching-with-multiple-objects
As Moshe's answer only covers matching a template that is contained only once in the given picture. Here's how matching several at once:
(Note: I changed and fixed a few 'mistakes' that were in the original code)
Result:
Source: https://opencv24-python-tutorials.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html#template-matching-with-multiple-objects
对于任何将来偶然发现这一点的人。
这可以通过模板匹配来完成。总结一下(我的理解),模板匹配会寻找一个图像在另一图像中的精确匹配。
以下是如何在 Python 中执行此操作的示例:
For anyone who stumbles across this in the future.
This can be done with template matching. To summarize (my understanding), template matching looks for an exact match of one image within another image.
Here's an example of how to do it within Python:
OpenCV 有一个 Python 界面,你可以看看。如果字符不要改变太多,您可以尝试使用 matchTemplate 函数。
这里是他们的官方教程(本教程是使用 C++ 接口编写的,但您应该能够从中很好地了解如何在 Python 中使用该函数)。
OpenCV has a Python interface that you could look at. If the characters, don't change too much you could try to use the matchTemplate function.
Here is their official tutorial on it (the tutorial is written using the C++ interface, but you should be able to get a good idea of how to use the function in Python from it).
重要提示:matchTemplate 甚至能够检测调整大小和旋转的模板。这是代码和输出。
图像:
图片
模板:
企鹅
结果:
检测到
详细说明在这里(我的博客):simple-ai.net/find-and-replace-in-image
Important note: matchTemplate is even able to detect resized and rotated templates. Here's the code and outputs.
Image:
picture
Template:
penguin
Result:
detected
Detailed explanaition over here (my blog): simple-ai.net/find-and-replace-in-image