【发布时间】:2020-12-11 13:43:46
【问题描述】:
我需要检测使用 OpenCV 标记的选项。目前,我已经能够检测到所有方块,但标记的方块除外。我使用以下代码完成了此操作。
canny = (cv2.Canny(roi_box, 30, 100))
cv2_imshow(canny)
img = roi_box.copy()
contours, heirarchy = cv2.findContours(canny, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cntsSorted = sorted(contours, key=lambda x:cv2.contourArea(x))
print("contours %i" % len(contours))
for i in range(45, 0, -1):
cv2.drawContours(img, cntsSorted[i], -1, (0, 255,0), 4)
if (cv2.contourArea(cntsSorted[i]) > 300):
cv2_imshow(img)
标记的正方形面积约为50。有人可以告诉我如何解决这个问题吗?
【问题讨论】: