python opencv形状相似度,
感谢博客:
(Python)从零开始,简单快速学机器仿人视觉Opencv---第十九节:关于轮廓的函数 - 古月居
import cv2
import numpy as np
img1 = cv2.imread('roi.jpg')
img2 = cv2.imread('0022.jpg')
ret,thresh=cv2.threshold(img1,127,255,0)
ret,thresh2=cv2.threshold(img2,127,255,0)
contours,hierarchy =cv2.findContours(thresh,2,1)
cnt1=contours[0]
contours,hierarchy =cv2.findContours(thresh2,2,1)
cnt2=contours[0]
ret=cv2.matchShapes(cnt1,cnt2,1,0,0)
print(ret)