我需要检测图像中的所有线条(边缘)以及它们在我的 xamarin 应用程序中的位置。
就像附图中一样。
我在 python 中尝试过 openCV,但仍然没有得到所有的线条,我只有对象周围的边界框和直线,但我也需要检测斜线。
这是我使用的python代码:`
blur = cv2.GaussianBlur(img, (3,3), 0)
canny = cv2.Canny(blur, l_th, u_th)
dilated = cv2.dilate(canny, None, iterations=3)
contours, hierarchy = cv2.findContours(dilated, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
for contour in contours:
(x, y, w, h) = cv2.boundingRect(contour)
cv2.rectangle(coloured_img, (x, y), (x+w, y+h), (0, 255, 0), 2)
原始图像:
我想要的输出:
我得到的输出:
请问有什么建议吗?