Classes | |
class | cv::LineSegmentDetector |
Line segment detector class. More... | |
Enumerations | |
enum | cv::HoughModes { cv::HOUGH_STANDARD = 0 , cv::HOUGH_PROBABILISTIC = 1 , cv::HOUGH_MULTI_SCALE = 2 , cv::HOUGH_GRADIENT = 3 , cv::HOUGH_GRADIENT_ALT = 4 } |
Variants of a Hough transform. More... | |
enum | cv::LineSegmentDetectorModes { cv::LSD_REFINE_NONE = 0 , cv::LSD_REFINE_STD = 1 , cv::LSD_REFINE_ADV = 2 } |
Variants of Line Segment Detector. More... | |
Functions | |
CV_EXPORTS_W Ptr< LineSegmentDetector > | cv::createLineSegmentDetector (int refine=LSD_REFINE_STD, double scale=0.8, double sigma_scale=0.6, double quant=2.0, double ang_th=22.5, double log_eps=0, double density_th=0.7, int n_bins=1024) |
Creates a smart pointer to a LineSegmentDetector object and initializes it. More... | |
CV_EXPORTS_W void | cv::Canny (InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false) |
Finds edges in an image using the Canny algorithm [Canny86] . More... | |
CV_EXPORTS_W void | cv::Canny (InputArray dx, InputArray dy, OutputArray edges, double threshold1, double threshold2, bool L2gradient=false) |
CV_EXPORTS_W void | cv::cornerMinEigenVal (InputArray src, OutputArray dst, int blockSize, int ksize=3, int borderType=BORDER_DEFAULT) |
Calculates the minimal eigenvalue of gradient matrices for corner detection. More... | |
CV_EXPORTS_W void | cv::cornerHarris (InputArray src, OutputArray dst, int blockSize, int ksize, double k, int borderType=BORDER_DEFAULT) |
Harris corner detector. More... | |
CV_EXPORTS_W void | cv::cornerEigenValsAndVecs (InputArray src, OutputArray dst, int blockSize, int ksize, int borderType=BORDER_DEFAULT) |
Calculates eigenvalues and eigenvectors of image blocks for corner detection. More... | |
CV_EXPORTS_W void | cv::preCornerDetect (InputArray src, OutputArray dst, int ksize, int borderType=BORDER_DEFAULT) |
Calculates a feature map for corner detection. More... | |
CV_EXPORTS_W void | cv::cornerSubPix (InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria) |
Refines the corner locations. More... | |
CV_EXPORTS_W void | cv::goodFeaturesToTrack (InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask=noArray(), int blockSize=3, bool useHarrisDetector=false, double k=0.04) |
Determines strong corners on an image. More... | |
CV_EXPORTS_W void | cv::goodFeaturesToTrack (InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask, int blockSize, int gradientSize, bool useHarrisDetector=false, double k=0.04) |
CV_EXPORTS | cv::CV_WRAP_AS (goodFeaturesToTrackWithQuality) void goodFeaturesToTrack(InputArray image |
Same as above, but returns also quality measure of the detected corners. More... | |
CV_EXPORTS_W void | cv::HoughLines (InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn=0, double stn=0, double min_theta=0, double max_theta=CV_PI) |
Finds lines in a binary image using the standard Hough transform. More... | |
CV_EXPORTS_W void | cv::HoughLinesP (InputArray image, OutputArray lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0) |
Finds line segments in a binary image using the probabilistic Hough transform. More... | |
CV_EXPORTS_W void | cv::HoughLinesPointSet (InputArray point, OutputArray lines, int lines_max, int threshold, double min_rho, double max_rho, double rho_step, double min_theta, double max_theta, double theta_step) |
Finds lines in a set of points using the standard Hough transform. More... | |
CV_EXPORTS_W void | cv::HoughCircles (InputArray image, OutputArray circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0) |
Finds circles in a grayscale image using the Hough transform. More... | |
Variables | |
CV_EXPORTS OutputArray | cv::corners |
CV_EXPORTS OutputArray int | cv::maxCorners |
CV_EXPORTS OutputArray int double | cv::qualityLevel |
CV_EXPORTS OutputArray int double double | cv::minDistance |
CV_EXPORTS OutputArray int double double InputArray | cv::mask |
CV_EXPORTS OutputArray int double double InputArray OutputArray | cv::cornersQuality |
CV_EXPORTS OutputArray int double double InputArray OutputArray int | cv::blockSize = 3 |
CV_EXPORTS OutputArray int double double InputArray OutputArray int int | cv::gradientSize = 3 |
CV_EXPORTS OutputArray int double double InputArray OutputArray int int bool | cv::useHarrisDetector = false |
CV_EXPORTS OutputArray int double double InputArray OutputArray int int bool double | cv::k = 0.04) |
enum cv::HoughModes |
Variants of a Hough transform.
Variants of Line Segment Detector.
CV_EXPORTS_W void cv::Canny | ( | InputArray | dx, |
InputArray | dy, | ||
OutputArray | edges, | ||
double | threshold1, | ||
double | threshold2, | ||
bool | L2gradient = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Finds edges in an image using the Canny algorithm with custom image gradient.
dx | 16-bit x derivative of input image (CV_16SC1 or CV_16SC3). |
dy | 16-bit y derivative of input image (same type as dx). |
edges | output edge map; single channels 8-bit image, which has the same size as image . |
threshold1 | first threshold for the hysteresis procedure. |
threshold2 | second threshold for the hysteresis procedure. |
L2gradient | a flag, indicating whether a more accurate norm should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default norm is enough ( L2gradient=false ). |
CV_EXPORTS_W void cv::Canny | ( | InputArray | image, |
OutputArray | edges, | ||
double | threshold1, | ||
double | threshold2, | ||
int | apertureSize = 3 , |
||
bool | L2gradient = false |
||
) |
Finds edges in an image using the Canny algorithm [Canny86] .
The function finds edges in the input image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See http://en.wikipedia.org/wiki/Canny_edge_detector
image | 8-bit input image. |
edges | output edge map; single channels 8-bit image, which has the same size as image . |
threshold1 | first threshold for the hysteresis procedure. |
threshold2 | second threshold for the hysteresis procedure. |
apertureSize | aperture size for the Sobel operator. |
L2gradient | a flag, indicating whether a more accurate norm should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default norm is enough ( L2gradient=false ). |
CV_EXPORTS_W void cv::cornerEigenValsAndVecs | ( | InputArray | src, |
OutputArray | dst, | ||
int | blockSize, | ||
int | ksize, | ||
int | borderType = BORDER_DEFAULT |
||
) |
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
For every pixel , the function cornerEigenValsAndVecs considers a blockSize blockSize neighborhood . It calculates the covariation matrix of derivatives over the neighborhood as:
where the derivatives are computed using the Sobel operator.
After that, it finds eigenvectors and eigenvalues of and stores them in the destination image as where
The output of the function can be used for robust edge or corner detection.
src | Input single-channel 8-bit or floating-point image. |
dst | Image to store the results. It has the same size as src and the type CV_32FC(6) . |
blockSize | Neighborhood size (see details below). |
ksize | Aperture parameter for the Sobel operator. |
borderType | Pixel extrapolation method. See BorderTypes. BORDER_WRAP is not supported. |
CV_EXPORTS_W void cv::cornerHarris | ( | InputArray | src, |
OutputArray | dst, | ||
int | blockSize, | ||
int | ksize, | ||
double | k, | ||
int | borderType = BORDER_DEFAULT |
||
) |
Harris corner detector.
The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and cornerEigenValsAndVecs , for each pixel it calculates a gradient covariance matrix over a neighborhood. Then, it computes the following characteristic:
Corners in the image can be found as the local maxima of this response map.
src | Input single-channel 8-bit or floating-point image. |
dst | Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src . |
blockSize | Neighborhood size (see the details on cornerEigenValsAndVecs ). |
ksize | Aperture parameter for the Sobel operator. |
k | Harris detector free parameter. See the formula above. |
borderType | Pixel extrapolation method. See BorderTypes. BORDER_WRAP is not supported. |
CV_EXPORTS_W void cv::cornerMinEigenVal | ( | InputArray | src, |
OutputArray | dst, | ||
int | blockSize, | ||
int | ksize = 3 , |
||
int | borderType = BORDER_DEFAULT |
||
) |
Calculates the minimal eigenvalue of gradient matrices for corner detection.
The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, in terms of the formulae in the cornerEigenValsAndVecs description.
src | Input single-channel 8-bit or floating-point image. |
dst | Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src . |
blockSize | Neighborhood size (see the details on cornerEigenValsAndVecs ). |
ksize | Aperture parameter for the Sobel operator. |
borderType | Pixel extrapolation method. See BorderTypes. BORDER_WRAP is not supported. |
CV_EXPORTS_W void cv::cornerSubPix | ( | InputArray | image, |
InputOutputArray | corners, | ||
Size | winSize, | ||
Size | zeroZone, | ||
TermCriteria | criteria | ||
) |
Refines the corner locations.
The function iterates to find the sub-pixel accurate location of corners or radial saddle points as described in [forstner1987fast], and as shown on the figure below.
Sub-pixel accurate corner locator is based on the observation that every vector from the center to a point located within a neighborhood of is orthogonal to the image gradient at subject to image and measurement noise. Consider the expression:
where is an image gradient at one of the points in a neighborhood of . The value of is to be found so that is minimized. A system of equations may be set up with set to zero:
where the gradients are summed within a neighborhood ("search window") of . Calling the first gradient term and the second gradient term gives:
The algorithm sets the center of the neighborhood window at this new center and then iterates until the center stays within a set threshold.
image | Input single-channel, 8-bit or float image. |
corners | Initial coordinates of the input corners and refined coordinates provided for output. |
winSize | Half of the side length of the search window. For example, if winSize=Size(5,5) , then a search window is used. |
zeroZone | Half of the size of the dead region in the middle of the search zone over which the summation in the formula below is not done. It is used sometimes to avoid possible singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such a size. |
criteria | Criteria for termination of the iterative process of corner refinement. That is, the process of corner position refinement stops either after criteria.maxCount iterations or when the corner position moves by less than criteria.epsilon on some iteration. |
CV_EXPORTS_W Ptr<LineSegmentDetector> cv::createLineSegmentDetector | ( | int | refine = LSD_REFINE_STD , |
double | scale = 0.8 , |
||
double | sigma_scale = 0.6 , |
||
double | quant = 2.0 , |
||
double | ang_th = 22.5 , |
||
double | log_eps = 0 , |
||
double | density_th = 0.7 , |
||
int | n_bins = 1024 |
||
) |
Creates a smart pointer to a LineSegmentDetector object and initializes it.
The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
refine | The way found lines will be refined, see LineSegmentDetectorModes |
scale | The scale of the image that will be used to find the lines. Range (0..1]. |
sigma_scale | Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale. |
quant | Bound to the quantization error on the gradient norm. |
ang_th | Gradient angle tolerance in degrees. |
log_eps | Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen. |
density_th | Minimal density of aligned region points in the enclosing rectangle. |
n_bins | Number of bins in pseudo-ordering of gradient modulus. |
CV_EXPORTS cv::CV_WRAP_AS | ( | goodFeaturesToTrackWithQuality | ) |
Same as above, but returns also quality measure of the detected corners.
image | Input 8-bit or floating-point 32-bit, single-channel image. |
corners | Output vector of detected corners. |
maxCorners | Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set and all detected corners are returned. |
qualityLevel | Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see cornerMinEigenVal ) or the Harris function response (see cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected. |
minDistance | Minimum possible Euclidean distance between the returned corners. |
mask | Region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. |
cornersQuality | Output vector of quality measure of the detected corners. |
blockSize | Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs . |
gradientSize | Aperture parameter for the Sobel operator used for derivatives computation. See cornerEigenValsAndVecs . |
useHarrisDetector | Parameter indicating whether to use a Harris detector (see cornerHarris) or cornerMinEigenVal. |
k | Free parameter of the Harris detector. |
CV_EXPORTS_W void cv::goodFeaturesToTrack | ( | InputArray | image, |
OutputArray | corners, | ||
int | maxCorners, | ||
double | qualityLevel, | ||
double | minDistance, | ||
InputArray | mask, | ||
int | blockSize, | ||
int | gradientSize, | ||
bool | useHarrisDetector = false , |
||
double | k = 0.04 |
||
) |
CV_EXPORTS_W void cv::goodFeaturesToTrack | ( | InputArray | image, |
OutputArray | corners, | ||
int | maxCorners, | ||
double | qualityLevel, | ||
double | minDistance, | ||
InputArray | mask = noArray() , |
||
int | blockSize = 3 , |
||
bool | useHarrisDetector = false , |
||
double | k = 0.04 |
||
) |
Determines strong corners on an image.
The function finds the most prominent corners in the image or in the specified image region, as described in [Shi94]
The function can be used to initialize a point-based tracker of an object.
image | Input 8-bit or floating-point 32-bit, single-channel image. |
corners | Output vector of detected corners. |
maxCorners | Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set and all detected corners are returned. |
qualityLevel | Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see cornerMinEigenVal ) or the Harris function response (see cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected. |
minDistance | Minimum possible Euclidean distance between the returned corners. |
mask | Optional region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. |
blockSize | Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs . |
useHarrisDetector | Parameter indicating whether to use a Harris detector (see cornerHarris) or cornerMinEigenVal. |
k | Free parameter of the Harris detector. |
CV_EXPORTS_W void cv::HoughCircles | ( | InputArray | image, |
OutputArray | circles, | ||
int | method, | ||
double | dp, | ||
double | minDist, | ||
double | param1 = 100 , |
||
double | param2 = 100 , |
||
int | minRadius = 0 , |
||
int | maxRadius = 0 |
||
) |
Finds circles in a grayscale image using the Hough transform.
The function finds circles in a grayscale image using a modification of the Hough transform.
Example: :
It also helps to smooth image a bit unless it's already soft. For example, GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
image | 8-bit, single-channel, grayscale input image. |
circles | Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector or . |
method | Detection method, see HoughModes. The available methods are HOUGH_GRADIENT and HOUGH_GRADIENT_ALT. |
dp | Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. For HOUGH_GRADIENT_ALT the recommended value is dp=1.5, unless some small very circles need to be detected. |
minDist | Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed. |
param1 | First method-specific parameter. In case of HOUGH_GRADIENT and HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that HOUGH_GRADIENT_ALT uses Scharr algorithm to compute image derivatives, so the threshold value should normally be higher, such as 300 or normally exposed and contrasty images. |
param2 | Second method-specific parameter. In case of HOUGH_GRADIENT, it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. In the case of HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles. |
minRadius | Minimum circle radius. |
maxRadius | Maximum circle radius. If <= 0, uses the maximum image dimension. If < 0, HOUGH_GRADIENT returns centers without finding the radius. HOUGH_GRADIENT_ALT always computes circle radiuses. |
CV_EXPORTS_W void cv::HoughLines | ( | InputArray | image, |
OutputArray | lines, | ||
double | rho, | ||
double | theta, | ||
int | threshold, | ||
double | srn = 0 , |
||
double | stn = 0 , |
||
double | min_theta = 0 , |
||
double | max_theta = CV_PI |
||
) |
Finds lines in a binary image using the standard Hough transform.
The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform.
image | 8-bit, single-channel binary source image. The image may be modified by the function. |
lines | Output vector of lines. Each line is represented by a 2 or 3 element vector or , where is the distance from the coordinate origin (top-left corner of the image), is the line rotation angle in radians ( ), and is the value of accumulator. |
rho | Distance resolution of the accumulator in pixels. |
theta | Angle resolution of the accumulator in radians. |
threshold | Accumulator threshold parameter. Only those lines are returned that get enough votes ( ). |
srn | For the multi-scale Hough transform, it is a divisor for the distance resolution rho. The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these parameters should be positive. |
stn | For the multi-scale Hough transform, it is a divisor for the distance resolution theta. |
min_theta | For standard and multi-scale Hough transform, minimum angle to check for lines. Must fall between 0 and max_theta. |
max_theta | For standard and multi-scale Hough transform, an upper bound for the angle. Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly less than max_theta, depending on the parameters min_theta and theta. |
CV_EXPORTS_W void cv::HoughLinesP | ( | InputArray | image, |
OutputArray | lines, | ||
double | rho, | ||
double | theta, | ||
int | threshold, | ||
double | minLineLength = 0 , |
||
double | maxLineGap = 0 |
||
) |
Finds line segments in a binary image using the probabilistic Hough transform.
The function implements the probabilistic Hough transform algorithm for line detection, described in [Matas00]
See the line detection example below:
This is a sample picture the function parameters have been tuned for:
And this is the output of the above program in case of the probabilistic Hough transform:
image | 8-bit, single-channel binary source image. The image may be modified by the function. |
lines | Output vector of lines. Each line is represented by a 4-element vector , where and are the ending points of each detected line segment. |
rho | Distance resolution of the accumulator in pixels. |
theta | Angle resolution of the accumulator in radians. |
threshold | Accumulator threshold parameter. Only those lines are returned that get enough votes ( ). |
minLineLength | Minimum line length. Line segments shorter than that are rejected. |
maxLineGap | Maximum allowed gap between points on the same line to link them. |
CV_EXPORTS_W void cv::HoughLinesPointSet | ( | InputArray | point, |
OutputArray | lines, | ||
int | lines_max, | ||
int | threshold, | ||
double | min_rho, | ||
double | max_rho, | ||
double | rho_step, | ||
double | min_theta, | ||
double | max_theta, | ||
double | theta_step | ||
) |
Finds lines in a set of points using the standard Hough transform.
The function finds lines in a set of points using a modification of the Hough transform.
point | Input vector of points. Each vector must be encoded as a Point vector . Type must be CV_32FC2 or CV_32SC2. |
lines | Output vector of found lines. Each vector is encoded as a vector<Vec3d> . The larger the value of 'votes', the higher the reliability of the Hough line. |
lines_max | Max count of Hough lines. |
threshold | Accumulator threshold parameter. Only those lines are returned that get enough votes ( ). |
min_rho | Minimum value for for the accumulator (Note: can be negative. The absolute value is the distance of a line to the origin.). |
max_rho | Maximum value for for the accumulator. |
rho_step | Distance resolution of the accumulator. |
min_theta | Minimum angle value of the accumulator in radians. |
max_theta | Upper bound for the angle value of the accumulator in radians. The actual maximum angle may be slightly less than max_theta, depending on the parameters min_theta and theta_step. |
theta_step | Angle resolution of the accumulator in radians. |
CV_EXPORTS_W void cv::preCornerDetect | ( | InputArray | src, |
OutputArray | dst, | ||
int | ksize, | ||
int | borderType = BORDER_DEFAULT |
||
) |
Calculates a feature map for corner detection.
The function calculates the complex spatial derivative-based function of the source image
where , are the first image derivatives, , are the second image derivatives, and is the mixed derivative.
The corners can be found as local maximums of the functions, as shown below:
src | Source single-channel 8-bit of floating-point image. |
dst | Output image that has the type CV_32F and the same size as src . |
ksize | Aperture size of the Sobel . |
borderType | Pixel extrapolation method. See BorderTypes. BORDER_WRAP is not supported. |
CV_EXPORTS OutputArray int double double InputArray OutputArray int cv::blockSize = 3 |
CV_EXPORTS OutputArray cv::corners |
CV_EXPORTS OutputArray int double double InputArray OutputArray cv::cornersQuality |
CV_EXPORTS OutputArray int double double InputArray OutputArray int int cv::gradientSize = 3 |
CV_EXPORTS OutputArray int double double InputArray OutputArray int int bool double cv::k = 0.04) |
CV_EXPORTS OutputArray int double double InputArray cv::mask |
CV_EXPORTS OutputArray int cv::maxCorners |
CV_EXPORTS OutputArray int double double cv::minDistance |
CV_EXPORTS OutputArray int double cv::qualityLevel |
CV_EXPORTS OutputArray int double double InputArray OutputArray int int bool cv::useHarrisDetector = false |