【发布时间】:2020-09-02 12:31:32
【问题描述】:
实际上,我不喜欢使用计算机视觉。提前抱歉。
我想检测电车车道的边缘。大多数情况下,代码运行良好,但有时它甚至无法画线。我不知道为什么。
cropped_Image函数只是裁剪当前帧的多边形区域。
display_lines 函数绘制角度绝对值在 30 到 90 之间的线条。它使用 cv2.line 来绘制线条。
代码如下:
_,frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) # convert image to gray to be one layer
blur = cv2.GaussianBlur(gray, (1, 1), 0) # to reduce noise in gray scale image
canny = cv2.Canny(blur, 150, 200, apertureSize=3)
cropped_image = region_of_interest(canny) # simply, it crops bottom of image
lines = cv2.HoughLinesP(cropped_image, 1, np.pi / 180, 100, np.array([]),
minLineLength=5, maxLineGap=5)
hough_bundler = HoughBundler()
lines_merged = hough_bundler.process_lines(lines, cropped_image)
line_image = display_lines(frame, lines_merged)
combo_image = cv2.addWeighted(frame, 0.8, line_image, 1, 1)
cv2.imshow(‘test’, combo_image)
查看:HoughBundler
预期:expected img
Canny:canny img of wrong result
结果:wrong result
【问题讨论】:
-
结果照片中的红线表示线的角度小于30。
标签: opencv edge-detection hough-transform imagefilter canny-operator