import cv2 import numpy as np # define a video capture object vid = cv2.VideoCapture(0) while(True): # Capture the video frame # by frame ret, frame = vid.read() # Convert to grayscale. gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #Create default parametrization LSD lsd = cv2.createLineSegmentDetector(1000) lines = lsd.detect(gray)[0] #Position 0 of the returned tuple are the detected lines # The below for loop runs till r and theta values # are in the range of the 2d array if lines is not None: for line in lines: print (line) # Draw detected lines in the image frame = lsd.drawSegments(frame,lines) # Display the resulting frame cv2.imshow('frame', frame) # the 'q' button is set as the # quitting button you may use any # desired button of your choice if cv2.waitKey(1) & 0xFF == ord('q'): break # After the loop release the cap object vid.release() # Destroy all the windows cv2.destroyAllWindows()