对于将来偶然发现此问题的任何人。
这可以通过模板匹配来完成。总而言之(我的理解),模板匹配在一个图像中寻找另一个图像中的精确匹配。
这是如何在Python中执行此操作的示例:
import cv2
method = cv2.TM_SQDIFF_NORMED
# Read the images from the file
small_image = cv2.imread('small_image.png')
large_image = cv2.imread('large_image.jpeg')
result = cv2.matchTemplate(small_image, large_image, method)
# We want the minimum squared difference
mn,_,mnLoc,_ = cv2.minMaxLoc(result)
# Draw the rectangle:
# Extract the coordinates of our best match
MPx,MPy = mnLoc
# Step 2: Get the size of the template. This is the same size as the match.
trows,tcols = small_image.shape[:2]
# Step 3: Draw the rectangle on large_image
cv2.rectangle(large_image, (MPx,MPy),(MPx+tcols,MPy+trows),(0,0,255),2)
# Display the original image with the rectangle around the match.
cv2.imshow('output',large_image)
# The image is only displayed if we call this
cv2.waitKey(0)
0
我目前正在建立一个基本上相当于搜索引擎和网络漫画画廊之间的交叉点的网站,该画廊侧重于引用来源并给予作者以荣誉。
我正在尝试找出一种搜索图像以在其中查找字符的方法。
例如:
假设我将红色字符和绿色字符另存为“ Red Man”和“ Green Man”,我如何确定图像是否包含一个或另一个。
不需要100%识别,或者什么是我想创建的更多功能,我不确定从哪里开始。我已经做了很多谷歌搜索的图像识别工作,但是并没有太大的帮助。
对于它的价值,我宁愿使用Python来完成。