Python Opencv3 Line detection

Source: Internet
Author: User

Git:https://github.com/linyi0604/computer-vision

1 #Coding:utf82 3 ImportCv24 ImportNumPy as NP5 6 7 #Read in Image8img = Cv2.imread (".. /data/line1.png")9 #Convert to Grayscale imageTenGray =Cv2.cvtcolor (IMG, Cv2. Color_bgr2gray) One #Canny edge detection Aedges = Cv2. Canny (Gray, 50, 100) - """ - Canny edge detection: the There are five steps: - 1 Gaussian filter noise reduction - 2 Calculating Gradients - 3 Using non-maximum suppressed NMS on edge + 4 using a double threshold on the edge to remove false positives - 5 Analysis of all edge connections eliminates marginal edges + """ A  atMinlinelength = 20 -Maxlinegap = 5 -Lines = Cv2. Houghlinesp (edges, 1, np.pi/180, 100, Minlinelength, Maxlinegap) - """ - Cv2. Houghlinesp - function: Standard Hough line transform to find all lines in an image in Parameters: - 12 Value Graph to 2 radius Accuracy + 3 Angular accuracy - 4 Shortest detection length the 5 maximum allowable notch * return: $ a list, each item is a four-tuple, which is the coordinates of the two endpoints of a line, respectivelyPanax Notoginseng """ -  forLineinchlines: the      forx1, y1, x2, y2inchLine : +         #draw a line on the picture ACv2.line (IMG, (x1, y1), (x2, y2), (0, 255, 0), 2) the  +Cv2.imshow ("edges", edges) -Cv2.imshow ("Lines", IMG) $ Cv2.waitkey () $Cv2.destroyallwindows ()

Python Opencv3 Line detection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.