找到交叉点坐标OpenCV Python

时间:2017-04-11 14:20:43

标签: python-2.7 intersection opencv3.0 hough-transform

我必须找到暂停图像的角点。我在Python 2.7中使用OpenCV 3.1.0

Conner points are marked in blue dot

我使用了Houghline检测。但是,它找到了论文的外线。

cap = cv2.VideoCapture(1)
while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    frame=cv2.GaussianBlur(frame,(3,3),0);  
    cv2.adaptiveThreshold(frame,255,CV_ADAPTIVE_THRESH_MEAN_C, 
CV_THRESH_BINARY,75,10);  

    gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
    edges = cv2.Canny(gray,50,150,apertureSize = 3)
    cv2.imshow('canny',edges)
    lines = cv2.HoughLines(edges,r,t,th)
    for rho,theta in lines[0]:
        a = np.cos(theta)
        b = np.sin(theta)
        x0 = a*rho
        y0 = b*rho
        x1 = int(x0 + 1000*(-b))
        y1 = int(y0 + 1000*(a))
        x2 = int(x0 - 1000*(-b))
        y2 = int(y0 - 1000*(a))

        cv2.line(frame,(x1,y1),(x2,y2),(0,0,255),2)
    #Display the resulting frame
    cv2.imshow('frame',frame)
    if cv2.waitKey(40) & 0xFF == ord('q'):
        break

建议一种获得交叉点坐标的合适方法。如果你能提供一些示例代码。

0 个答案:

没有答案