Principle analysis of Lane line detection Hough line detection

Source: Internet
Author: User

http://blog.csdn.net/happy_stars_2016/article/details/52691255

First, lane line detection steps


1, Grayscale

Grayscale key functions: Cvcvtcolorcvcvtcolor (iplimage* src, iplimage* DST, Cv_brg2gray);
The last parameter is Cv_brg2gray, which indicates that the BRG picture (color picture) is converted to a grayscale picture (black and white).


2. Binary Value

Image binary is to set the gray value of the pixel on the image to 0 or 255, that is, the entire image will show a significant black and white effect.

A two-valued image that can still reflect the overall and local features of the image is obtained by selecting the appropriate threshold values for the 256 grayscale images of the luminance level.
Cvthreshold (DST, Dst,threshold, Max_value, Threshold_type); Is to manually specify a threshold value for binary processing.
SRC: Original Array (single channel, 8-bit of 32-bit floating-point number).
DST: The output array must be the same as the SRC type, or 8-bit.
Threshold: Threshold value
Max_value: Use the maximum value of cv_thresh_binary and CV_THRESH_BINARY_INV.
Threshold_type: Threshold Type
Threshold_type=cv_thresh_binary: If SRC (x, y) >threshold, DST (x, y) = Max_value; Otherwise, DST (x, y) = 0;
THRESHOLD_TYPE=CV_THRESH_BINARY_INV: If SRC (x, y) >threshold,dst (x, y) = 0; Otherwise, DST (x, y) = Max_value.

The Threshold_type can use the Cv_thresh_otsu type so that the function uses the global adaptive threshold obtained by the large law Otsu to perform a binary picture, and the threshold in the parameter no longer works.


3. Canny Edge Detection

Canny operator to find the edge point specific algorithm steps are as follows:
1. Smoothing the image with a Gaussian filter
2. Calculate gradient amplitude and direction with first order biased finite difference
3. Non-maximum value suppression for gradient amplitude
4. Detecting and connecting edges with a dual-threshold algorithm
void Cvcanny (const cvarr* image, cvarr* edges, double threshold1, double threshold2, int aperture_size=3);
Image single-channel input images
Edges output image for single-channel storage Edge
Threshold1 First Threshold value
Threshold2 a second threshold value
Aperture_size is the Sobel operator kernel size
Small thresholds in threshold1 and threshold2 are used to control edge connections, and large thresholds are used to control the initial segmentation of strong edges.


4. Hough Line Detection

Hough Transform is a method of finding straight lines, circles and other simple shapes in an image. The OPENCV supports two different Hough transformations: The standard Hough transform (SHT) and the cumulative probability Hough transform (PPHT).

The same function can be used in OPENCV to use both algorithms.
cvseq* CvHonghLines2 (cvarr* image, void* line_storage,int mehtod, double rho, double theta, int threshold, double param1 =0, double param2 = 0);

Image input 8-bit, single-channel (two-value) images

Line_storage stores detected segments, which can be sequences or single-row/single-column matrices

Mehtod Hough transform variable The distance accuracy of rho and pixel-related units theta Radian measurement angle Accuracy

The threshold threshold parameter. If the corresponding cumulative value is greater than threshold, the segment returned by the function
PARAM1: For the traditional Hough transformation, do not use (0), the probability Hough transformation, it is the minimum segment length.
PARAM2: For the traditional Hough transform, do not use (0); for the probability Hough transformation, this parameter represents the maximum interval value (GAP) of the broken segment connection on the same line, that is, when the interval between two broken segments on the same line is less than param2, it is merged into one.

Second, the Hough linear detection principle

Hough transform has been widely used in computer vision, military defense, office automation and other fields. The basic idea is to transform the original image into a parametric space,

Using most of the boundary points to satisfy some parameter form to describe the line in the image, accumulate by setting accumulator, and obtain the information needed for the point of the peak.

Hough transform is favored by scholars in the field of image processing, pattern recognition and computer vision because of its insensitive to local defects, robustness to random noise, and good performance in parallel processing.
The prominent advantage of the Hough transform is that the more difficult global detection problem can be transformed into a local peak detection problem which is relatively easy to solve in the parameter space.
1962, Paul Hough based on the principle of mathematical duality, the method of detecting the straight line is presented, and the method is continuously researched and developed, which is mainly used in the field of pattern recognition to detect the two-valued image.

1, Hough Transformation principle

A. The problem of detecting lines in an image is essentially finding all the pixels that make up the line. So the problem is to find a straight line and become a problem that finds all (x, y) points that match y=kx+b.
B. Change the coordinate system y=kx+b and turn it into b=-xk+y. This is represented as an over-point (k,b) line bundle.
Each point in a straight line of the c.x-y space is represented as a straight line through (k,b) in the K-b coordinate system. Find a little bit of a problem and turn it into a question of finding a straight line.
D. For each point in the image, there are many lines in the K-b coordinate system. When you find the intersection of a line, it corresponds to finding the line in the image.


At present, OpenCV Hof is commonly used to detect straight lines, is the plane of any straight line in polar coordinate mode: ρ=xcosθ+ysinθ,

where p represents the distance from the point to the straight line of the Cartesian coordinate system, θ represents the angle between the x axis and the p so that a point on the image plane corresponds to a curve on the ρ-θ plane.

If the n points on the same line are transformed, the n points of the original image space correspond to the n sine curves in the parameter space, and the curves intersect at a point.


2, Hough detection steps

The Hough transform can be described in the following steps in the algorithm design:
A. Create a discrete parameter space between the ρ,θ appropriate maximum and minimum values, as shown in Figure 1-1.
B. Quantify the parameter space (ρ,θ) to M*n (M is the equal number of ρ, n is the equal number of θ) units, and set the accumulator matrix, as shown below.
C. Assign an accumulator Q (I,J) to each unit of the parameter space and set the initial value of the accumulator to 0
D. Take the ρ=xcosθ+ysinθ to each point on the image boundary (x, Y) to obtain the corresponding ρ value for each θ
E. In the parameter space, locate the cell corresponding to the ρ and θ and add 1 to the accumulator of the Unit, namely: Q (I,J) =q (i,j) +1.
F. When all points in the Cartesian coordinate system are traversed by 4 and 52 steps, the value of each accumulator in the parameter space is examined, and the ρ and θ corresponding to the largest unit of the accumulator are the parameters of the linear equation in the Cartesian coordinate system.

Note: When the points in the Cartesian coordinate system are distributed near the R Bar, the Ρk and Θk (k=1,2,..., R) corresponding to the largest R values in the accumulator are removed when the accumulator is detected in the 5th step.

With Ρk and θk as the parameters of linear equation ρ=xcosθ+ysinθ in Cartesian coordinate system, it is possible to detect multiple lines simultaneously.

3. Summary

As mentioned above, the basic strategy of the Hough transformation is to use the edge data points of the image space to meter
Calculates the possible trajectory of the reference point in the parameter space, computes the count of reference points in an accumulator, and finally selects the peak. This peak indicates that there are a lot of lines in the image space.

The parameters of the line are determined by the accumulator's ρ and θ, that is, according to Q (I,J) =q (i,j) +1, the point (x, y) of the image space that satisfies the formula makes up the 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.