我有一个问题要查找该图像的轮廓,我使用了 findcontour 不是很准确,我做错了吗?
gs = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(gs, (3,3),0)
ret_otsu,im_bw_otsu = cv2.threshold(blur,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
kernel = np.ones((50,50),np.uint8)
closing = cv2.morphologyEx(im_bw_otsu, cv2.MORPH_CLOSE, kernel)
_, contours, hierarchy = cv2.findContours(closing,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
plottedContour = cv2.drawContours(gs,contours,-1,(0,255,0),2)
cv2.imshow('CONTOUR',plottedContour)
最佳答案
看起来您可能想查看其他轮廓,
cv2.drawContours(gs,contours,-1,(0,255,0),2)
cv2.drawContours(gs,contours,0,(0,255,0),2)
cv2.drawContours(gs,contours,1,(0,255,0),2)
cv2.drawContours(gs,contours,2,(0,255,0),2)
...
关于python - 发现轮廓不准确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60178751/