麻烦大家帮忙看看第19行代码有什么问题,自己实在是搞不来了
这个是我的代码
0xff == 27
不是 =
img = cv2.imread("shu.png")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
h, w = gray.shape[:2] # template_gray 为灰度图
ret,binaryimg = cv2.threshold(gray,100,255,cv2.THRESH_BINARY)
countimg = []
contours,hierarchy = cv2.findContours(binaryimg,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
n = len(contours)
for i in range(n):
temp = np.zeros(img.shape, np.uint8)
countimg.append(temp)
if cv2.contourArea(contours[i]) > 20000:
countimg[i] = cv2.drawContours(img.copy(),contours,i,(0,0,255),3)
cv2.resize(countimg[i],dst=None,fx = 0.5,fy=0.5,dsize=None)
cv2.imshow("conter"+str(i),countimg[i])