opencv python的 Canny findContours得到两个非常接近的轮廓,角点有几个像素的差距,如何处理?
kernel_2 = cv2.getStructuringElement(cv2.MORPH_RECT,(3, 3))
eroded = cv2.erode(img_gray_binary,kernel_2,iterations=2)# 【0330new】 iterations=2 #腐蚀图像
dilated = cv2.dilate(eroded,kernel_2) #膨胀图像
img_cannyedges = cv2.Canny(dilated,100,200)
contours, hierarchy = cv2.findContours(img_cannyedges, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
序号140面积符合
bounding_rect: (286, 229, 127, 146)
x, y, w, h: 286 229 127 146
轮廓角点数量和数据: 3 [[[288 229]] [[412 300]] [[295 374]]]
序号141面积符合
bounding_rect: (286, 229, 127, 146)
x, y, w, h: 286 229 127 146
轮廓角点数量和数据: 4 [[[288 229]] [[290 358]] [[296 374]] [[412 300]]]
**********************************
序号67面积符合
bounding_rect: (286, 230, 126, 144)
x, y, w, h: 286 230 126 144
轮廓角点数量和数据: 4 [[[288 230]] [[411 300]] [[296 373]] [[291 372]]]
序号69面积符合
bounding_rect: (286, 230, 126, 144)
x, y, w, h: 286 230 126 144
轮廓角点数量和数据: 4 [[[288 230]] [[291 372]] [[297 373]] [[411 299]]]
更为奇怪的是,linux下thonny的imshow窗体,点击窗体上的保存按钮,点击后一个画面一闪而过,然后窗体就没有反应了。只能停止运行。