Skip to content

Instantly share code, notes, and snippets.

@ryul99
Created April 9, 2020 05:40
Show Gist options
  • Save ryul99/548c41577113c5f8fca62448f8d20ca2 to your computer and use it in GitHub Desktop.
Save ryul99/548c41577113c5f8fca62448f8d20ca2 to your computer and use it in GitHub Desktop.
Line Detection with opencv
def get_lines(img_path): # return: [[left, top, right, bottom]...]
img = cv2.imread(img_path)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,50,150,apertureSize = 3)
minLineLength = 100
maxLineGap = 10
lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
return lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment