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