我需要识别给定图像中的以下点。但它没有给出正确的检测。有人可以提供一种方法来识别这样的图像中的这些点吗?
增强图像,先膨胀再锐化
我使用模板匹配来检测图像中的这些点。但效果并不好。代码如下。有没有其他方法可以检测到这些?
导入 cv2 将 numpy 导入为 np
img_rgb = cv2.imread(file)
cv2.imwrite("D:/4/Detect/"+str(i)+".0.jpg",img_rgb)
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
template = cv2.imread('a.jpg',0)
w, h = template.shape[::-1]
res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.455
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,255,255), 0)
cv2.imshow('Detected',img_rgb)
cv2.imwrite("D:/4/Detect/"+str(i)+".1.jpg",img_rgb)
cv2.waitKey(0)
cv2.destroyAllWindows()