Detecting edges and contours are not only common and important tasks, they also constitute the basis for other complex operations. Lines and shape detection go hand in hand with edge and contour detection, so let's examine how OpenCV implements these.
The theory behind lines and shape detection has its foundation in a technique called the Hough transform, invented by Richard Duda and Peter Hart, who extended (generalized) the work done by Paul Hough in the early 1960s.
Let's take a look at OpenCV's API for the Hough transforms.
First of all, let's detect some lines, which is done with the HoughLines
and HoughLinesP
functions. The only difference between the two functions is that one uses the standard Hough transform, and the second uses the probabilistic Hough transform (hence P
in the name).
The probabilistic version is so-called because it only analyzes a subset of points and estimates the probability of these points all belonging to the same line. This...