1
OpenCV와 Python을 사용하는 프로그램에서 도로 차선을 감지하려고합니다. 이를 위해 Hough Line Transform을 사용하여 선을 감지했습니다. 그러나, 그것은 서로의 바로 옆에 많은 라인을 발견하고 나는 그 모든 다른 라인들 사이에있는 평균 라인을 만드는 방법을 찾으려고 노력하고 있습니다. 팁? 당신이 서로 옆에 적은 라인을 원하는 경우 houghlinesP 기능Python과 OpenCV - Hough Line 변형의 지배적 인 라인
의 매개 변수를 조정해야
import numpy as np
import cv2
cap = cv2.VideoCapture('CVfootage.mov')
while(True):
ret, frame = cap.read()
frame = frame[200:720, 0:1280]
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray,(7,7),0)
edges = cv2.Canny(blur, 50, 150)
lines = cv2.HoughLinesP(image=edges,rho=1,theta=np.pi/180, threshold=100,lines=np.array([]), minLineLength=100,maxLineGap=80)
a,b,c = lines.shape
for i in range(a):
cv2.line(blur, (lines[i][0][0], lines[i][0][1]), (lines[i][0][2], lines[i][0][3]), (0, 0, 255), 3, cv2.LINE_AA)
cv2.imshow('edges', edges)
cv2.imshow('hough', blur)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
예제를 시각화하지 않고 "각각의 바로 옆에있는 많은 선"이라고 표현하는 것이 쉽지 않습니다. thresholding이 예상대로 작동하지 않는다는 것을 의미합니까? – NAmorim