The time CV used by the Python line detection. Houghlinesp () function:
It has two parameters:
The shortest length of the minlinelength-line, shorter than this line will be ignored.
maxlinegap-the maximum interval between two lines, and if this value is less than this, the two lines are considered a line.
The return value of this function is the starting and ending point of the line.
See main program:
Import cv2
import NumPy as NP from
matplotlib import pyplot as Plt
img=cv2.imread (' biaoding.jpg ')
# Imgblur=cv2.medianblur (img,5)
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)
for X1,y1,x2,y2 in lines[0]:
cv2.line (IMG, ( X1,Y1), (X2,y2), (0,255,0), 2
cv2.imshow ("Edge", edges)
cv2.imshow ("image", img)
cv2.waitkey (0)
The result is as shown in figure: