【发布时间】:2021-04-23 07:44:13
【问题描述】:
我正在尝试识别 7 段显示器上的数字。
我在 Jupyter notebook 上使用 python。
我有0~9 7段显示的数字图像,
和每个数字。分别保存。
下面是3,3.,2,2.的示例图片
我想在目标图像上找到这些图像。
听说OpenCV上有工具可以找到类似的图片。
我尝试了 使用 SIFT 描述符和比率测试进行蛮力匹配 但输出似乎不准确。
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
img1 = cv2.imread('C:\\Users\\USER\\Desktop\\test\\deeplearningimage\\thermo\\3..png',cv2.IMREAD_GRAYSCALE) # trainImage
img2 = cv2.imread('C:\\Users\\USER\\Desktop\\test\\thermosample.jpg',cv2.IMREAD_GRAYSCALE) # queryImage
# Initiate SIFT detector
sift = cv.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# BFMatcher with default params
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2,k=2)
# Apply ratio test
good = []
for m,n in matches:
if m.distance < 0.75*n.distance:
good.append([m])
# cv.drawMatchesKnn expects list of lists as matches.
img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,None,flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)
plt.imshow(img3),plt.show()'
这是上面代码的输出
不知道如何进行。
还有其他opencv 可以解决这个问题吗?
【问题讨论】:
-
你考虑过template matching吗?
-
@MANDU “我想在目标图像上找到这些图像”,你想找到位置吗?或者它是否存在?
-
我已经成功地使用了这里的想法:pyimagesearch.com/2017/02/13/… 记录来自 7 段显示器的数字
-
@SiHa 无论如何在该教程中,他不考虑点。只有 7 段对吗?
-
现在你提到它,是的,我相信这是真的(已经有一段时间了)。
标签: python opencv artificial-intelligence ocr