Line detection in pictures - Hough transform

1 canny edge detection edge detection

The effect is as follows:

2. How to use a computer to identify and detect straight lines?

 Note: Not expressed in polar coordinates

1 Formula derivation

\theta and r uniquely determine a straight line: (the tangent of \theta is the slope)

Additional knowledge: Trigonometric functions

Tangent_Baidu Encyclopedia (baidu.com)

Function name

official

sine function

sinθ=y/r

cosine function

cosθ=x/r

tangent function

tanθ=y/x

cotangent function

cotθ=x/y

secant function

secθ=r/x

cosecant function

cscθ=r/y

2 Start counting and vote for the straight line

对 \thetarTrial area:

 Calculate the position information (x, y) of the edge point using all angle intervals \theta and vote in the above table.

Complete your vote:

 Each group is a straight line. The more votes it gets, the more likely it is that it is the target straight line.

 3. Code learning

I haven’t learned yet, but I have learned to write.

Guess you like

Origin blog.csdn.net/qq_46012097/article/details/134088135