stereoCalibrateExtended
import { stereoCalibrateExtended } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Calibrates a stereo camera set up. This function finds the intrinsic parameters for each of the two cameras and the extrinsic parameters between the two cameras.
stereoCalibrateExtended(objectPoints: MatVector, imagePoints1: MatVector, imagePoints2: MatVector, cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, E: Mat, F: Mat, rvecs: MatVector, tvecs: MatVector, perViewErrors: Mat, flags: number, criteria: TermCriteria): number;3 available overloads
stereoCalibrateExtended(objectPoints: MatVector, imagePoints1: MatVector, imagePoints2: MatVector, cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, E: Mat, F: Mat, rvecs: MatVector, tvecs: MatVector, perViewErrors: Mat): number;stereoCalibrateExtended(objectPoints: MatVector, imagePoints1: MatVector, imagePoints2: MatVector, cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, E: Mat, F: Mat, rvecs: MatVector, tvecs: MatVector, perViewErrors: Mat, flags: number): number;stereoCalibrateExtended(objectPoints: MatVector, imagePoints1: MatVector, imagePoints2: MatVector, cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, E: Mat, F: Mat, rvecs: MatVector, tvecs: MatVector, perViewErrors: Mat, flags: number, criteria: TermCriteria): number;objectPointsVector of vectors of the calibration pattern points. The same structure as in
calibrateCamera.For each pattern view, both cameras need to see the same object points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to be equal for each i.imagePoints1Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in
calibrateCamera.imagePoints2Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in
calibrateCamera.cameraMatrix1Input/output value, modified by the native operation. Input/output camera intrinsic matrix for the first camera, the same as in
calibrateCamera.Furthermore, for the stereo case, additional flags may be used, see below.distCoeffs1Input/output value, modified by the native operation. Input/output vector of distortion coefficients, the same as in
calibrateCamera.cameraMatrix2Input/output value, modified by the native operation. Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
distCoeffs2Input/output value, modified by the native operation. Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
imageSizeSize of the image used only to initialize the camera intrinsic matrices.
RInput/output value, modified by the native operation. Output rotation matrix. Together with the translation vector T, this matrix brings points given in the first camera's coordinate system to points in the second camera's coordinate system. In more technical terms, the tuple of R and T performs a change of basis from the first camera's coordinate system to the second camera's coordinate system. Due to its duality, this tuple is equivalent to the position of the first camera with respect to the second camera coordinate system.
TInput/output value, modified by the native operation. Output translation vector, see description above.
EOutput destination, filled by the native operation. Output essential matrix.
FOutput destination, filled by the native operation. Output fundamental matrix.
rvecsOutput destination, filled by the native operation. Output vector of rotation vectors (
Rodrigues) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vectorcv::Mat). More in detail, each i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter description) brings the calibration pattern from the object coordinate space (in which object points are specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms, the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space to camera coordinate space of the first camera of the stereo pair.tvecsOutput destination, filled by the native operation. Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
perViewErrorsOutput destination, filled by the native operation. Output vector of the RMS re-projection error estimated for each pattern view.
flagsDifferent flags that may be zero or a combination of the following values:
CALIB_FIX_INTRINSICFix cameraMatrix? and distCoeffs? so that only R, T, E, and F matrices are estimated.CALIB_USE_INTRINSIC_GUESSOptimize some or all of the intrinsic parameters according to the specified flags. Initial values are provided by the user.CALIB_USE_EXTRINSIC_GUESSR and T contain valid initial values that are optimized further. Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).CALIB_FIX_PRINCIPAL_POINTFix the principal points during the optimization.CALIB_FIX_FOCAL_LENGTHFixf^{(j)}_xandf^{(j)}_y.CALIB_FIX_ASPECT_RATIOOptimizef^{(j)}_y. Fix the ratiof^{(j)}_x/f^{(j)}_y.CALIB_SAME_FOCAL_LENGTHEnforcef^{(0)}_x=f^{(1)}_xandf^{(0)}_y=f^{(1)}_y.CALIB_ZERO_TANGENT_DISTSet tangential distortion coefficients for each camera to zeros and fix there.CALIB_FIX_K1,...,CALIB_FIX_K6Do not change the corresponding radial distortion coefficient during the optimization. IfCALIB_USE_INTRINSIC_GUESSis set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.CALIB_RATIONAL_MODELEnable coefficients k4, k5, and k6. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients.CALIB_THIN_PRISM_MODELCoefficients s1, s2, s3 and s4 are enabled. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the thin prism model and return 12 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients.CALIB_FIX_S1_S2_S3_S4The thin prism distortion coefficients are not changed during the optimization. IfCALIB_USE_INTRINSIC_GUESSis set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.CALIB_TILTED_MODELCoefficients tauX and tauY are enabled. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the tilted sensor model and return 14 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients.CALIB_FIX_TAUX_TAUYThe coefficients of the tilted sensor model are not changed during the optimization. IfCALIB_USE_INTRINSIC_GUESSis set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
criteriaTermination criteria for the iterative optimization algorithm.
The function estimates the transformation between two cameras making a stereo pair. If one computes the poses of an object relative to the first camera and to the second camera, (
R_1,T_1) and (R_2,T_2), respectively, for a stereo camera where the relative position and orientation between the two cameras are fixed, then those poses definitely relate to each other. This means, if the relative position and orientation (R,T) of the two cameras is known, it is possible to compute (R_2,T_2) when (R_1,T_1) is given. This is what the described function does. It computes (R,T) such that:R_2=R R_1T_2=R T_1 + T.Therefore, one can compute the coordinate representation of a 3D point for the second camera's coordinate system when given the point's coordinate representation in the first camera's coordinate system:
\begin{bmatrix} X_2 \\ Y_2 \\ Z_2 \\ 1 \end{bmatrix} = \begin{bmatrix} R & T \\ 0 & 1 \end{bmatrix} \begin{bmatrix} X_1 \\ Y_1 \\ Z_1 \\ 1 \end{bmatrix}.Optionally, it computes the essential matrix E:
E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} Rwhere
T_iare components of the translation vectorT:T=[T_0, T_1, T_2]^T. And the function can also compute the fundamental matrix F:F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}Besides the stereo-related information, the function can also perform a full calibration of each of the two cameras. However, due to the high dimensionality of the parameter space and noise in the input data, the function can diverge from the correct solution. If the intrinsic parameters can be estimated with high accuracy for each of the cameras individually (for example, using #calibrateCamera ), you are recommended to do so and then pass
CALIB_FIX_INTRINSICflag to the function along with the computed intrinsic parameters. Otherwise, if all the parameters are estimated at once, it makes sense to restrict some parameters, for example, passCALIB_SAME_FOCAL_LENGTHandCALIB_ZERO_TANGENT_DISTflags, which is usually a reasonable assumption.Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the points in all the available views from both cameras. The function returns the final value of the re-projection error.
The number result.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.