mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -620,7 +620,7 @@ CV_EXPORTS_W Mat findHomography(InputArray srcPoints, InputArray dstPoints, Outp
|
||||
@param Qz Optional output 3x3 rotation matrix around z-axis.
|
||||
|
||||
The function computes a RQ decomposition using the given rotations. This function is used in
|
||||
decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
|
||||
#decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
|
||||
and a rotation matrix.
|
||||
|
||||
It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
|
||||
@@ -674,7 +674,7 @@ CV_EXPORTS_W void decomposeProjectionMatrix( InputArray projMatrix, OutputArray
|
||||
|
||||
The function computes partial derivatives of the elements of the matrix product \f$A*B\f$ with regard to
|
||||
the elements of each of the two input matrices. The function is used to compute the Jacobian
|
||||
matrices in stereoCalibrate but can also be used in any other similar optimization function.
|
||||
matrices in #stereoCalibrate but can also be used in any other similar optimization function.
|
||||
*/
|
||||
CV_EXPORTS_W void matMulDeriv( InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB );
|
||||
|
||||
@@ -703,7 +703,7 @@ where \f$\mathrm{rodrigues}\f$ denotes a rotation vector to a rotation matrix tr
|
||||
\f$\mathrm{rodrigues}^{-1}\f$ denotes the inverse transformation. See Rodrigues for details.
|
||||
|
||||
Also, the functions can compute the derivatives of the output vectors with regards to the input
|
||||
vectors (see matMulDeriv ). The functions are used inside stereoCalibrate but can also be used in
|
||||
vectors (see matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
|
||||
your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
|
||||
function that contains a matrix multiplication.
|
||||
*/
|
||||
@@ -934,7 +934,7 @@ a 3D point expressed in the world frame into the camera frame:
|
||||
arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
|
||||
modules/3d/src/solvepnp.cpp version 2.4.9)
|
||||
- The P3P algorithm requires image points to be in an array of shape (N,1,2) due
|
||||
to its calling of cv::undistortPoints (around line 75 of modules/3d/src/solvepnp.cpp version 2.4.9)
|
||||
to its calling of #undistortPoints (around line 75 of modules/3d/src/solvepnp.cpp version 2.4.9)
|
||||
which requires 2-channel information.
|
||||
- Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
|
||||
it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
|
||||
@@ -1140,7 +1140,7 @@ vectors, respectively, and further optimizes them.
|
||||
- @ref SOLVEPNP_ITERATIVE Iterative method is based on a Levenberg-Marquardt optimization. In
|
||||
this case the function finds such a pose that minimizes reprojection error, that is the sum
|
||||
of squared distances between the observed projections imagePoints and the projected (using
|
||||
projectPoints ) objectPoints .
|
||||
#projectPoints ) objectPoints .
|
||||
- @ref SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
|
||||
In this case the function requires exactly four object and image points.
|
||||
@@ -1276,7 +1276,7 @@ a 3D point expressed in the world frame into the camera frame:
|
||||
arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
|
||||
modules/3d/src/solvepnp.cpp version 2.4.9)
|
||||
- The P3P algorithm requires image points to be in an array of shape (N,1,2) due
|
||||
to its calling of undistortPoints (around line 75 of modules/3d/src/solvepnp.cpp version 2.4.9)
|
||||
to its calling of #undistortPoints (around line 75 of modules/3d/src/solvepnp.cpp version 2.4.9)
|
||||
which requires 2-channel information.
|
||||
- Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
|
||||
it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
|
||||
@@ -1357,7 +1357,7 @@ CV_EXPORTS_W void convertPointsFromHomogeneous( InputArray src, OutputArray dst,
|
||||
@param dst Output vector of 2D, 3D, or 4D points.
|
||||
|
||||
The function converts 2D or 3D points from/to homogeneous coordinates by calling either
|
||||
convertPointsToHomogeneous or convertPointsFromHomogeneous.
|
||||
#convertPointsToHomogeneous or #convertPointsFromHomogeneous.
|
||||
|
||||
@note The function is obsolete. Use one of the previous two functions instead.
|
||||
*/
|
||||
@@ -1396,7 +1396,7 @@ matrices sequentially).
|
||||
|
||||
The calculated fundamental matrix may be passed further to computeCorrespondEpilines that finds the
|
||||
epipolar lines corresponding to the specified points. It can also be passed to
|
||||
stereoRectifyUncalibrated to compute the rectification transformation. :
|
||||
#stereoRectifyUncalibrated to compute the rectification transformation. :
|
||||
@code
|
||||
// Example. Estimation of fundamental matrix using the RANSAC algorithm
|
||||
int point_count = 100;
|
||||
@@ -1441,7 +1441,7 @@ be floating-point (single or double precision).
|
||||
@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ .
|
||||
Note that this function assumes that points1 and points2 are feature points from cameras with the
|
||||
same camera intrinsic matrix. If this assumption does not hold for your use case, use
|
||||
`undistortPoints()` with `P = cv::NoArray()` for both cameras to transform image points
|
||||
#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points
|
||||
to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
|
||||
passing these coordinates, pass the identity matrix for this parameter.
|
||||
@param method Method for computing an essential matrix.
|
||||
@@ -1464,7 +1464,7 @@ This function estimates essential matrix based on the five-point algorithm solve
|
||||
|
||||
where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the
|
||||
second images, respectively. The result of this function may be passed further to
|
||||
decomposeEssentialMat or recoverPose to recover the relative pose between cameras.
|
||||
#decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
Mat findEssentialMat(
|
||||
@@ -1539,13 +1539,13 @@ be floating-point (single or double precision).
|
||||
@param cameraMatrix1 Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
|
||||
Note that this function assumes that points1 and points2 are feature points from cameras with the
|
||||
same camera matrix. If this assumption does not hold for your use case, use
|
||||
`undistortPoints()` with `P = cv::NoArray()` for both cameras to transform image points
|
||||
#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points
|
||||
to normalized image coordinates, which are valid for the identity camera matrix. When
|
||||
passing these coordinates, pass the identity matrix for this parameter.
|
||||
@param cameraMatrix2 Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
|
||||
Note that this function assumes that points1 and points2 are feature points from cameras with the
|
||||
same camera matrix. If this assumption does not hold for your use case, use
|
||||
`undistortPoints()` with `P = cv::NoArray()` for both cameras to transform image points
|
||||
#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points
|
||||
to normalized image coordinates, which are valid for the identity camera matrix. When
|
||||
passing these coordinates, pass the identity matrix for this parameter.
|
||||
@param distCoeffs1 Input vector of distortion coefficients
|
||||
@@ -1573,7 +1573,7 @@ This function estimates essential matrix based on the five-point algorithm solve
|
||||
|
||||
where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the
|
||||
second images, respectively. The result of this function may be passed further to
|
||||
decomposeEssentialMat or recoverPose to recover the relative pose between cameras.
|
||||
#decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
|
||||
*/
|
||||
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
|
||||
InputArray cameraMatrix1, InputArray distCoeffs1,
|
||||
@@ -1635,7 +1635,7 @@ possible pose hypotheses by doing cheirality check. The cheirality check means t
|
||||
triangulated 3D points should have positive depth. Some details can be found in @cite Nister03.
|
||||
|
||||
This function can be used to process the output E and mask from @ref findEssentialMat. In this
|
||||
scenario, points1 and points2 are the same input for findEssentialMat.:
|
||||
scenario, points1 and points2 are the same input for #findEssentialMat :
|
||||
@code
|
||||
// Example. Estimation of fundamental matrix using the RANSAC algorithm
|
||||
int point_count = 100;
|
||||
@@ -1731,14 +1731,14 @@ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray point
|
||||
@param points Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or
|
||||
vector\<Point2f\> .
|
||||
@param whichImage Index of the image (1 or 2) that contains the points .
|
||||
@param F Fundamental matrix that can be estimated using findFundamentalMat or stereoRectify .
|
||||
@param F Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify .
|
||||
@param lines Output vector of the epipolar lines corresponding to the points in the other image.
|
||||
Each line \f$ax + by + c=0\f$ is encoded by 3 numbers \f$(a, b, c)\f$ .
|
||||
|
||||
For every point in one of the two images of a stereo pair, the function finds the equation of the
|
||||
corresponding epipolar line in the other image.
|
||||
|
||||
From the fundamental matrix definition (see findFundamentalMat ), line \f$l^{(2)}_i\f$ in the second
|
||||
From the fundamental matrix definition (see #findFundamentalMat ), line \f$l^{(2)}_i\f$ in the second
|
||||
image for the point \f$p^{(1)}_i\f$ in the first image (when whichImage=1 ) is computed as:
|
||||
|
||||
\f[l^{(2)}_i = F p^{(1)}_i\f]
|
||||
@@ -1798,7 +1798,6 @@ geometric distance between points \f$a\f$ and \f$b\f$ ) subject to the epipolar
|
||||
CV_EXPORTS_W void correctMatches( InputArray F, InputArray points1, InputArray points2,
|
||||
OutputArray newPoints1, OutputArray newPoints2 );
|
||||
|
||||
|
||||
/** @brief Calculates the Sampson Distance between two points.
|
||||
|
||||
The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as:
|
||||
@@ -1810,7 +1809,7 @@ sd( \texttt{pt1} , \texttt{pt2} )=
|
||||
((\texttt{F}^t \cdot \texttt{pt2})(0))^2 +
|
||||
((\texttt{F}^t \cdot \texttt{pt2})(1))^2}
|
||||
\f]
|
||||
The fundamental matrix may be calculated using the cv::findFundamentalMat function. See @cite HartleyZ00 11.4.3 for details.
|
||||
The fundamental matrix may be calculated using the #findFundamentalMat function. See @cite HartleyZ00 11.4.3 for details.
|
||||
@param pt1 first homogeneous 2d point
|
||||
@param pt2 second homogeneous 2d point
|
||||
@param F fundamental matrix
|
||||
@@ -2104,10 +2103,10 @@ CV_EXPORTS_W int decomposeHomographyMat(InputArray H,
|
||||
@param beforePoints Vector of (rectified) visible reference points before the homography is applied
|
||||
@param afterPoints Vector of (rectified) visible reference points after the homography is applied
|
||||
@param possibleSolutions Vector of int indices representing the viable solution set after filtering
|
||||
@param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the findHomography function
|
||||
@param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function
|
||||
|
||||
This function is intended to filter the output of the decomposeHomographyMat based on additional
|
||||
information as described in @cite Malis . The summary of the method: the decomposeHomographyMat function
|
||||
This function is intended to filter the output of the #decomposeHomographyMat based on additional
|
||||
information as described in @cite Malis . The summary of the method: the #decomposeHomographyMat function
|
||||
returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
|
||||
sets of points visible in the camera frame before and after the homography transformation is applied,
|
||||
we can determine which are the true potential solutions and which are the opposites by verifying which
|
||||
@@ -2166,7 +2165,7 @@ CV_EXPORTS_W void undistort( InputArray src, OutputArray dst,
|
||||
/** @brief Computes the undistortion and rectification transformation map.
|
||||
|
||||
The function computes the joint undistortion and rectification transformation and represents the
|
||||
result in the form of maps for remap. The undistorted image looks like original, as if it is
|
||||
result in the form of maps for #remap. The undistorted image looks like original, as if it is
|
||||
captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a
|
||||
monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by
|
||||
#getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera,
|
||||
@@ -2176,7 +2175,7 @@ Also, this new camera is oriented differently in the coordinate space, according
|
||||
example, helps to align two heads of a stereo camera so that the epipolar lines on both images
|
||||
become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
|
||||
|
||||
The function actually builds the maps for the inverse mapping algorithm that is used by remap. That
|
||||
The function actually builds the maps for the inverse mapping algorithm that is used by #remap. That
|
||||
is, for each pixel \f$(u, v)\f$ in the destination (corrected and rectified) image, the function
|
||||
computes the corresponding coordinates in the source image (that is, in the original image from
|
||||
camera). The following process is applied:
|
||||
@@ -2204,7 +2203,7 @@ where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x
|
||||
are the distortion coefficients.
|
||||
|
||||
In case of a stereo camera, this function is called twice: once for each camera head, after
|
||||
stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera
|
||||
#stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera
|
||||
was not calibrated, it is still possible to compute the rectification transformations directly from
|
||||
the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes
|
||||
homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
|
||||
@@ -2230,6 +2229,77 @@ void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs,
|
||||
InputArray R, InputArray newCameraMatrix,
|
||||
Size size, int m1type, OutputArray map1, OutputArray map2);
|
||||
|
||||
/** @brief Computes the projection and inverse-rectification transformation map. In essense, this is the inverse of
|
||||
#initUndistortRectifyMap to accomodate stereo-rectification of projectors ('inverse-cameras') in projector-camera pairs.
|
||||
|
||||
The function computes the joint projection and inverse rectification transformation and represents the
|
||||
result in the form of maps for #remap. The projected image looks like a distorted version of the original which,
|
||||
once projected by a projector, should visually match the original. In case of a monocular camera, newCameraMatrix
|
||||
is usually equal to cameraMatrix, or it can be computed by
|
||||
#getOptimalNewCameraMatrix for a better control over scaling. In case of a projector-camera pair,
|
||||
newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
|
||||
|
||||
The projector is oriented differently in the coordinate space, according to R. In case of projector-camera pairs,
|
||||
this helps align the projector (in the same manner as #initUndistortRectifyMap for the camera) to create a stereo-rectified pair. This
|
||||
allows epipolar lines on both images to become horizontal and have the same y-coordinate (in case of a horizontally aligned projector-camera pair).
|
||||
|
||||
The function builds the maps for the inverse mapping algorithm that is used by #remap. That
|
||||
is, for each pixel \f$(u, v)\f$ in the destination (projected and inverse-rectified) image, the function
|
||||
computes the corresponding coordinates in the source image (that is, in the original digital image). The following process is applied:
|
||||
|
||||
\f[
|
||||
\begin{array}{l}
|
||||
\text{newCameraMatrix}\\
|
||||
x \leftarrow (u - {c'}_x)/{f'}_x \\
|
||||
y \leftarrow (v - {c'}_y)/{f'}_y \\
|
||||
|
||||
\\\text{Undistortion}
|
||||
\\\scriptsize{\textit{though equation shown is for radial undistortion, function implements cv::undistortPoints()}}\\
|
||||
r^2 \leftarrow x^2 + y^2 \\
|
||||
\theta \leftarrow \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}\\
|
||||
x' \leftarrow \frac{x}{\theta} \\
|
||||
y' \leftarrow \frac{y}{\theta} \\
|
||||
|
||||
\\\text{Rectification}\\
|
||||
{[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
|
||||
x'' \leftarrow X/W \\
|
||||
y'' \leftarrow Y/W \\
|
||||
|
||||
\\\text{cameraMatrix}\\
|
||||
map_x(u,v) \leftarrow x'' f_x + c_x \\
|
||||
map_y(u,v) \leftarrow y'' f_y + c_y
|
||||
\end{array}
|
||||
\f]
|
||||
where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$
|
||||
are the distortion coefficients vector distCoeffs.
|
||||
|
||||
In case of a stereo-rectified projector-camera pair, this function is called for the projector while #initUndistortRectifyMap is called for the camera head.
|
||||
This is done after #stereoRectify, which in turn is called after #stereoCalibrate. If the projector-camera pair
|
||||
is not calibrated, it is still possible to compute the rectification transformations directly from
|
||||
the fundamental matrix using #stereoRectifyUncalibrated. For the projector and camera, the function computes
|
||||
homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
|
||||
space. R can be computed from H as
|
||||
\f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f]
|
||||
where cameraMatrix can be chosen arbitrarily.
|
||||
|
||||
@param cameraMatrix Input camera matrix \f$A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
|
||||
@param distCoeffs Input vector of distortion coefficients
|
||||
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$
|
||||
of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
|
||||
@param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2,
|
||||
computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
|
||||
is assumed.
|
||||
@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$.
|
||||
@param size Distorted image size.
|
||||
@param m1type Type of the first output map. Can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
|
||||
@param map1 The first output map for #remap.
|
||||
@param map2 The second output map for #remap.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void initInverseRectificationMap( InputArray cameraMatrix, InputArray distCoeffs,
|
||||
InputArray R, InputArray newCameraMatrix,
|
||||
const Size& size, int m1type, OutputArray map1, OutputArray map2 );
|
||||
|
||||
//! initializes maps for #remap for wide-angle
|
||||
CV_EXPORTS
|
||||
float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs,
|
||||
@@ -2305,10 +2375,10 @@ assumed.
|
||||
@param imageSize Original image size.
|
||||
@param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
|
||||
valid) and 1 (when all the source image pixels are retained in the undistorted image). See
|
||||
stereoRectify for details.
|
||||
#stereoRectify for details.
|
||||
@param newImgSize Image size after rectification. By default, it is set to imageSize .
|
||||
@param validPixROI Optional output rectangle that outlines all-good-pixels region in the
|
||||
undistorted image. See roi1, roi2 description in stereoRectify .
|
||||
undistorted image. See roi1, roi2 description in #stereoRectify .
|
||||
@param centerPrincipalPoint Optional flag that indicates whether in the new camera intrinsic matrix the
|
||||
principal point should be at the image center or not. By default, the principal point is chosen to
|
||||
best fit a subset of the source image (determined by alpha) to the corrected image.
|
||||
@@ -2320,7 +2390,7 @@ image pixels if there is valuable information in the corners alpha=1 , or get so
|
||||
When alpha\>0 , the undistorted result is likely to have some black pixels corresponding to
|
||||
"virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
|
||||
coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
|
||||
initUndistortRectifyMap to produce the maps for remap .
|
||||
#initUndistortRectifyMap to produce the maps for #remap .
|
||||
*/
|
||||
CV_EXPORTS_W Mat getOptimalNewCameraMatrix( InputArray cameraMatrix, InputArray distCoeffs,
|
||||
Size imageSize, double alpha, Size newImgSize = Size(),
|
||||
@@ -2331,7 +2401,7 @@ CV_EXPORTS_W Mat getOptimalNewCameraMatrix( InputArray cameraMatrix, InputArray
|
||||
|
||||
The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
|
||||
sparse set of points instead of a raster image. Also the function performs a reverse transformation
|
||||
to projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
|
||||
to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
|
||||
planar object, it does, up to a translation vector, if the proper R is specified.
|
||||
|
||||
For each observed point coordinate \f$(u, v)\f$ the function computes:
|
||||
@@ -2516,7 +2586,6 @@ public:
|
||||
protected:
|
||||
struct Impl;
|
||||
Ptr<Impl> p;
|
||||
|
||||
};
|
||||
|
||||
//! @} _3d
|
||||
|
||||
Reference in New Issue
Block a user