Findchessboardcorners
Int cvfindchessboardcorners (const void * image, cvsize pattern_size,
Cvpoint2d32f * corners, int * corner_count = NULL,
Int flags = cv_calib_cb_adaptive_thresh );
Image
The input chessboard image must be an 8-digit grayscale or color image.
Pattern_size
The number of corner points in each row and column in The checker chart.
Corners
Detected Corner Points
Corner_count
Output: Number of corner points. If it is not null, the function stores the number of detected corners in this variable.
Flags
Various operation marks can be a combination of 0 or lower nominal values:
Cv_calib_cb_adaptive_thresh-use an adaptive threshold (calculated based on average image brightness) to convert an image to a black/white image, rather than a fixed threshold.
Cv_calib_cb_normalize_image-use cvnormalizehist to balance the brightness of the image before the fixed or adaptive threshold value is used for binarization.
Cv_calib_cb_filter_quads-use other criteria (such as contour area, perimeter, and square shape) to remove the error blocks detected during contour detection.
The cvfindchessboardcorners function tries to determine whether the input image is in the checkerboard mode and determine the corner position. If all the corner points are detected and split, they are arranged in a certain order (one row, one row from left to right), the function returns a non-zero value, otherwise, if the function cannot find all vertices or record them, the function returns 0. For example, the 8x8 squares and 7x7 inner points on the right of a normal checker map are separated by Black Blocks. This function detects that the coordinates are only approximate values. to precisely determine their locations, you can use the cvfindcornersubpix function.
Findcornersubpix
Precise corner position
Void cvfindcornersubpix (const cvarr * image, cvpoint2d32f * corners,
Int count, cvsize win, cvsize zero_zone,
Cvtermcriteria criteria );
Image
Input image.
Corners
The initial coordinates of the input corner points, and the precise output coordinates are also stored.
Count
Number of corners
Win
Half the size of the search window. If win = (5, 5), use a search window of 5x2 + 1X5*2 + 1 = 11x11.
Zero_zone
The Dead Zone is half the size. The Dead Zone is the area where the sum operation is not performed on the central position of the search area. It is used to avoid some possible singularity of the Self-correlation matrix. If the value is (-1,-1), there is no dead zone.
Criteria
Find the termination condition of the iteration process of the corner point. That is, to determine the corner point position, either the number of iterations is greater than a set value, or the accuracy reaches a set value. Criteria can be the maximum number of iterations, set accuracy, or a combination of them.
The cvfindcornersubpix function uses iteration to find the angle point location with sub-pixel precision, or the radial saddle points ).
The implementation of sub-pixel-level corner point positioning is based on the observation of vector orthogonal, that is, the vector from the central point Q to the neighboring point P and the gradient orthogonal of the image at the point P (subject to image and measurement noise ). Consider the following expressions:
ε I = dipit · (Q-Pi)
Where, dipi indicates the image gradient at a neighboring point pi of Q. The Q value is obtained by minimizing ε I. By setting ε I to 0, you can establish the system equation as follows:
Sumi (dipi · dipit) · Q-Sumi (dipi · dipit · PI) = 0
The gradient in the Q's neighbor (search window) is accumulated. Call the first gradient parameter g and the second gradient parameter B to obtain:
Q = G-1 · B
This algorithm sets the center of the search window as the central Q, and then iterates until the center position below a certain threshold is found.
Drawchessboardcorners
Void cvdrawchessboardcorners (cvarr * image, cvsize pattern_size, cvpoint2d32f * corners,
Int count, int pattern_was_found );
Image
The result image must be an 8-bit color image.
Pattern_size
The number of inner points in each row and each column.
Corners
Corner Point array detected.
Count
Number of corner points.
Pattern_was_found
Indicates whether the entire board is found (= 0) or not (= 0 ). You can transmit the returned values of the cvfindchessboardcorners function.
When the board is not completely detected, the cvdrawchessboardcorners function draws the detected corner points in red circles. If the whole board is detected, it uses a straight line to connect all corner points.
Calibratecamera2 uses calibration to calculate the internal and external parameters of the camera.
Void cvcalibratecamera2 (const cvmat * object_points,
Constcvmat * image_points, const cvmat * point_counts,
Cvsizeimage_size, cvmat * intrinsic_matrix,
Cvmat * distortion_coeffs, cvmat * rotation_vectors = NULL,
Cvmat * translation_vectors = NULL, int flags = 0 );
Object_points
The world coordinate of the coordinate point, which is a matrix of 3xn or nx3. Here N is the total number of vertices in all views.
Image_points
Coordinate of the coordinate point, which is a matrix of 2xn or nx2. Here N is the total number of vertices in all views.
Point_counts
Vector, which specifies the number of vertices in different views. 1 XM or mx1 vector, and M indicates the number of views.
Image_size
Image Size, only used when initializing parameters.
Intrinsic_matrix
Output internal reference matrix (a). If cv_calib_use_intrinsic_guess and (or) cv_calib_fix_aspect_ration are specified, the FX, fy, CX, and Cy parts or all must be initialized.
Distortion_coeffs
The output is a 4x1 or 1X4 vector, which contains the deformation parameters [K1, K2, P1, P2].
Rotation_vectors
The output is a matrix of 3xm or mx3 with a rotation vector (compact representation of the rotation matrix. For details, refer to cvrodrigues2)
Translation_vectors
The output is a matrix of 3xm or mx3, which contains a translation vector.
Flags
Different signs can be 0 or a combination of the lower nominal values:
· Cv_calib_use_intrinsic_guess-the parameter matrix contains the initial values of FX, fy, CX, and Cy. Otherwise, the (CX, CY) is initialized to the image center (the image size is used here), and the focal length is calculated using the least square difference. Note: If the internal parameter is known and you do not need to use this function, use cvfindextrinsiccameraparams2.
· Cv_calib_fix_principal_point-The Master point remains unchanged during the global optimization process and remains in the center or other specified locations (when cv_calib_use_intrinsic_guess is set ).
· Cv_calib_fix_aspect_ratio-only one independent variable exists in FX and FY during the optimization process, and the ratio FX/fy remains unchanged. The value of FX/fy is the same as that of the parameter matrix during initialization. In this case, the actual initial values of (FX, FY) can be read from the input Memory Matrix (when cv_calib_use_intrinsic_guess is specified ), or use the estimated value (in the latter case, FX and FY may be set to any value, and only the ratio is used ).
· Cv_calib_zero_tangent_dist-the tangent deformation parameter (P1, P2) is set to 0, and its value remains 0 during the optimization process.
The cvcalibratecamera2 function estimates the internal and external parameters of the camera from each view. The vertices and their corresponding Two-Dimensional Projection on each view must be specified. These can be achieved by using an object with a known geometric shape cut with easy detection of feature points. Such an object is called a calibration device or a calibration mode. opencv has a built-in method of using the checker as a calibration device (refer to cvfindchessboardcorners ). Currently, the inner parameter passed in initialization (when cv_calib_use_intrinsic_guess is set) only supports flat calibration devices (the zcoordinate of the object point must be all 0 or all 1 ). However, the three-dimensional calibration equipment can still be used to provide the initial parameter matrix. After the initial values of the inner and outer parameter matrices are calculated, they are optimized to reduce the Inverse Projection Error (sum of squares of the differences between the actual coordinate on the image and the image coordinate calculated by cvprojectpoints2 ).
Undistort2 correction of image deformation caused by camera lens
Void cvundistort2 (const cvarr * SRC, cvarr * DST,
Const cvmat * intrinsic_matrix,
Const cvmat * distortion_coeffs );
SRC
Original Image (deformed image ).
DST
Result image (corrected image ).
Intrinsic_matrix
Parameter Matrix in the camera, in the format.
Distortion_coeffs
A vector composed of four deformation coefficients. The size is 4x1 or 1X4. The format is [K1,K2,P1,P2].
The cvundistort2 function is used to convert the image to offset the radial and tangent lens deformation. The camera parameters and deformation parameters can be obtained through the cvcalibratecamera2 function. Use the formula mentioned at the beginning of this section to calculate the position of each output image pixel in the input image, and then calculate the pixel value of the output image through bilinear interpolation. If the resolution of an image is different from that used when the image is set, you need to adjust FX, fy, CX, and Cy as the deformation does not change.
Findextrinsiccameraparams2 calculates out-of-camera parameters for a specified view
Void cvfindextrinsiccameraparams2 (const cvmat * object_points,
Const cvmat * image_points,
Const cvmat * intrinsic_matrix,
Const cvmat * distortion_coeffs,
Cvmat * rotation_vector,
Cvmat * translation_vector );
Object_points
Coordinate of the coordinate point, which is a matrix of 3xn or nx3. Here N is the number of views.
Image_points
Coordinate of the coordinate point in the image, which is a matrix of 2xn or nx2. Here N is the number of views.
Intrinsic_matrix
Reference matrix ().
Distortion_coeffs
Vector with a size of 4x1 or 1X4, which contains the deformation parameter [K1,K2,P1,P2]. If it is null, all deformation coefficients are 0.
Rotation_vector
The output is a matrix of 3X1 or 1x3, which contains a rotation vector (compact representation of the rotation matrix. For details, refer to the cvrodrigues2 function ).
Translation_vector
A matrix with a size of 3X1 or 1x3, which contains a translation vector.
The cvfindextrinsiccameraparams2 function uses known internal parameters and a view's external parameters to estimate the camera's external parameters. The coordinate points and the corresponding 2-Dimensional Projection on a 3D object must be specified. This function can also be used to minimize the Inverse Projection Error.
Goodfeaturestotrack determines the image's strong angle
Void cvgoodfeaturestotrack (const cvarr * image, cvarr * eig_image, cvarr * temp_image,
Cvpoint2d32f * corners, int * corner_count,
Double quality_level, double min_distance,
Const cvarr * mask = NULL );
Image
Input Image, 8-bit or floating point 32-bit, single channel
Eig_image
Temporary floating point 32-bit image with the same size as the input image
Temp_image
Another temporary image in the same format and size as eig_image
Corners
Output parameter, detected corner
Corner_count
Output parameter, number of detected Corner Points
Quality_level
The multiplication factor of the maximum and minimum feature values. Defines the minimum quality factor for acceptable image corners.
Min_distance
Limiting factor. The minimum distance between the obtained corner points. Euclidian Distance
Mask
ROI: region of interest. The function calculates the corner point in the ROI. If the mask is null, the entire image is selected.
The cvgoodfeaturestotrack function is used to search for Corner Points with large feature values in the image. This function uses cvcornermineigenval to calculate the minimum feature value of each pixel point of the input image and store the result in the eig_image variable. Then perform non-maximum suppression (only the local maximum value in the 3x3 neighborhood is retained ). In the next step, will the minimum feature value be less than quality_level? Max (eig_image (x, y) is excluded. Finally, the function ensures that there is sufficient distance between all the detected corner points (the first is retained for the strongest corner points, and then checks that the distance between the new and existing corner points is greater than min_distance
).