Python+opencv realizes the Huffman transformation detection line

Source: Internet
Author: User

PYTHON+OPENCV implementation of Gaussian smoothing filter
PYTHON+OPENCV Realization of threshold segmentation

(2016-5-10) to Opencv-python tutorials ' s documentation can be downloaded

Function:

Create a slider bar to control the length threshold of the detection line, which is greater than the threshold value and is less than the threshold value ignored
Note: The function here is houghlinesp instead of Houghlines, because the HOUGHLINESP directly gives a straight line breakpoint, can be lazy when drawing a line segment

Code:
#-*-Coding:utf-8-*-ImportCv2#两个回调函数 def houghlinesp(minlinelength):    GlobalMinlinelength minlinelength = minlinelength +1    Print "Minlinelength:", Minlinelength +1Tempiamge = Scr.copy () lines = Cv2. Houghlinesp (Edges,1, cv2.cv.cv_pi/ the, Minlinelength,0) forX1,y1,x2,y2inchlines[0]: Cv2.line (Tempiamge, (x1,y1), (X2,y2), (0,255,0),1) Cv2.imshow (WINDOW_NAME,TEMPIAMGE)#临时变量Minlinelength = -#全局变量Minlinelength = -Max_value = -Window_name ="Houghlines Demo"Trackbar_value ="Minlinelength"#读入图片, the pattern is a grayscale chart, creating a windowSCR = Cv2.imread ("G:\\homework\\building.bmp"Gray = Cv2.cvtcolor (SCR,CV2). Color_bgr2gray) img = cv2. Gaussianblur (Gray, (3,3),0) edges = Cv2. Canny (IMG, -, Max, aperturesize =3) Cv2.namedwindow (Window_name)#创建滑动条Cv2.createtrackbar (Trackbar_value, Window_name, Minlinelength, Max_value, HOUGHLINESP)#初始化HOUGHLINESP ( -)ifCv2.waitkey (0) == -: Cv2.destroyallwindows ()
Call:
>>> import os>>> os.chdir("g:\homework")>>> >>> import2021222325262728

Python+opencv realizes the Huffman transformation detection line

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.