我希望在图像上的两个已知点之间运行直线检测器,但首先我需要加宽直线周围的区域,以便我的直线检测器有更多的区域可用.主要问题是它相对于线的斜率拉伸了线周围的区域.例如:white line generated form two points with black bounding box.
我try 手动操作长方体数组:
input_to_min_area = np.array([[660, 888], [653, 540]]) # this works instead of contour as an input to minAreaRect
rect = cv.minAreaRect(input_to_min_area)
box = cv.boxPoints(rect)
box[[0, 3], 0] += 20
box[[1, 2], 0] -= 20
box = np.int0(box)
cv.drawContours(self.images[0], [box], 0, (0, 255, 255), 2)
但这对任何直线斜率都不起作用.从垂直到this angle一切都很好,但horizontal lines就不行了.
哪种更简单的解决方案适用于任何直线坡度?