import numpy as np import cv2 cap = cv2.VideoCapture(0) ret, frame = cap.read() minLineLength = 600 maxLineGap = 5 while(1): ret, frame = cap.read() gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,50,150,apertureSize = 3) lines = cv2.HoughLinesP(edges,1,np.pi/180,50,minLineLength,maxLineGap) if lines is not None : for x1,y1,x2,y2 in lines[0]: cv2.line(frame,(x1,y1),(x2,y2),(0,255,0),2) cv2.imshow('frame o',frame) k = cv2.waitKey(30) & 0xff if k == 27: break cap.release() cv2.destroyAllWindows()