Class Calib


  • public class Calib
    extends java.lang.Object
    • Constructor Detail

      • Calib

        public Calib()
    • Method Detail

      • initCameraMatrix2D

        public static Mat initCameraMatrix2D​(java.util.List<MatOfPoint3f> objectPoints,
                                             java.util.List<MatOfPoint2f> imagePoints,
                                             Size imageSize,
                                             double aspectRatio)
        Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points in the calibration pattern coordinate space. In the old interface all the per-view vectors are concatenated. See #calibrateCamera for details.
        imagePoints - Vector of vectors of the projections of the calibration pattern points. In the old interface all the per-view vectors are concatenated.
        imageSize - Image size in pixels used to initialize the principal point.
        aspectRatio - If it is zero or negative, both \(f_x\) and \(f_y\) are estimated independently. Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) . The function estimates and returns an initial camera intrinsic matrix for the camera calibration process. Currently, the function only supports planar calibration patterns, which are patterns where each object point has z-coordinate =0.
        Returns:
        automatically generated
      • initCameraMatrix2D

        public static Mat initCameraMatrix2D​(java.util.List<MatOfPoint3f> objectPoints,
                                             java.util.List<MatOfPoint2f> imagePoints,
                                             Size imageSize)
        Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points in the calibration pattern coordinate space. In the old interface all the per-view vectors are concatenated. See #calibrateCamera for details.
        imagePoints - Vector of vectors of the projections of the calibration pattern points. In the old interface all the per-view vectors are concatenated.
        imageSize - Image size in pixels used to initialize the principal point. Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) . The function estimates and returns an initial camera intrinsic matrix for the camera calibration process. Currently, the function only supports planar calibration patterns, which are patterns where each object point has z-coordinate =0.
        Returns:
        automatically generated
      • findChessboardCorners

        public static boolean findChessboardCorners​(Mat image,
                                                    Size patternSize,
                                                    MatOfPoint2f corners,
                                                    int flags)
        Finds the positions of internal corners of the chessboard.
        Parameters:
        image - Source chessboard view. It must be an 8-bit grayscale or color image.
        patternSize - Number of inner corners per a chessboard row and column ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
        corners - Output array of detected corners.
        flags - Various operation flags that can be zero or a combination of the following values:
        • REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black and white, rather than a fixed threshold level (computed from the average image brightness).
        • REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before applying fixed or adaptive thresholding.
        • REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter, square-like shape) to filter out false quads extracted at the contour retrieval stage.
        • REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners, and shortcut the call if none is found. This can drastically speed up the call in the degenerate condition when no chessboard is observed.
        • REF: CALIB_CB_PLAIN All other flags are ignored. The input image is taken as is. No image processing is done to improve to find the checkerboard. This has the effect of speeding up the execution of the function but could lead to not recognizing the checkerboard if the image is not previously binarized in the appropriate manner.
        The function attempts to determine whether the input image is a view of the chessboard pattern and locate the internal chessboard corners. The function returns a non-zero value if all of the corners are found and they are placed in a certain order (row by row, left to right in every row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example, a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black squares touch each other. The detected coordinates are approximate, and to determine their positions more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with different parameters if returned coordinates are not accurate enough. Sample usage of detecting and drawing chessboard corners: : Size patternsize(8,6); //interior number of corners Mat gray = ....; //source image vector<Point2f> corners; //this will be filled by the detected corners //CALIB_CB_FAST_CHECK saves a lot of time on images //that do not contain any chessboard corners bool patternfound = findChessboardCorners(gray, patternsize, corners, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK); if(patternfound) cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); drawChessboardCorners(img, patternsize, Mat(corners), patternfound); Note: The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails. Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
        Returns:
        automatically generated
      • findChessboardCorners

        public static boolean findChessboardCorners​(Mat image,
                                                    Size patternSize,
                                                    MatOfPoint2f corners)
        Finds the positions of internal corners of the chessboard.
        Parameters:
        image - Source chessboard view. It must be an 8-bit grayscale or color image.
        patternSize - Number of inner corners per a chessboard row and column ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
        corners - Output array of detected corners.
        • REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black and white, rather than a fixed threshold level (computed from the average image brightness).
        • REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before applying fixed or adaptive thresholding.
        • REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter, square-like shape) to filter out false quads extracted at the contour retrieval stage.
        • REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners, and shortcut the call if none is found. This can drastically speed up the call in the degenerate condition when no chessboard is observed.
        • REF: CALIB_CB_PLAIN All other flags are ignored. The input image is taken as is. No image processing is done to improve to find the checkerboard. This has the effect of speeding up the execution of the function but could lead to not recognizing the checkerboard if the image is not previously binarized in the appropriate manner.
        The function attempts to determine whether the input image is a view of the chessboard pattern and locate the internal chessboard corners. The function returns a non-zero value if all of the corners are found and they are placed in a certain order (row by row, left to right in every row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example, a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black squares touch each other. The detected coordinates are approximate, and to determine their positions more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with different parameters if returned coordinates are not accurate enough. Sample usage of detecting and drawing chessboard corners: : Size patternsize(8,6); //interior number of corners Mat gray = ....; //source image vector<Point2f> corners; //this will be filled by the detected corners //CALIB_CB_FAST_CHECK saves a lot of time on images //that do not contain any chessboard corners bool patternfound = findChessboardCorners(gray, patternsize, corners, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK); if(patternfound) cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); drawChessboardCorners(img, patternsize, Mat(corners), patternfound); Note: The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails. Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
        Returns:
        automatically generated
      • checkChessboard

        public static boolean checkChessboard​(Mat img,
                                              Size size)
      • findChessboardCornersSBWithMeta

        public static boolean findChessboardCornersSBWithMeta​(Mat image,
                                                              Size patternSize,
                                                              Mat corners,
                                                              int flags,
                                                              Mat meta)
        Finds the positions of internal corners of the chessboard using a sector based approach.
        Parameters:
        image - Source chessboard view. It must be an 8-bit grayscale or color image.
        patternSize - Number of inner corners per a chessboard row and column ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
        corners - Output array of detected corners.
        flags - Various operation flags that can be zero or a combination of the following values:
        • REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
        • REF: CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate.
        • REF: CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects.
        • REF: CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description).
        • REF: CALIB_CB_MARKER The detected pattern must have a marker (see description). This should be used if an accurate camera calibration is required.
        meta - Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)). Each entry stands for one corner of the pattern and can have one of the following values:
        • 0 = no meta data attached
        • 1 = left-top corner of a black cell
        • 2 = left-top corner of a white cell
        • 3 = left-top corner of a black cell with a white marker dot
        • 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
        The function is analog to #findChessboardCorners but uses a localized radon transformation approximated by box filters being more robust to all sort of noise, faster on larger images and is able to directly return the sub-pixel position of the internal chessboard corners. The Method is based on the paper CITE: duda2018 "Accurate Detection and Localization of Checkerboard Corners for Calibration" demonstrating that the returned sub-pixel positions are more accurate than the one returned by cornerSubPix allowing a precise camera calibration for demanding applications. In the case, the flags REF: CALIB_CB_LARGER or REF: CALIB_CB_MARKER are given, the result can be recovered from the optional meta array. Both flags are helpful to use calibration patterns exceeding the field of view of the camera. These oversized patterns allow more accurate calibrations as corners can be utilized, which are as close as possible to the image borders. For a consistent coordinate system across all images, the optional marker (see image below) can be used to move the origin of the board to the location where the black circle is located. Note: The function requires a white boarder with roughly the same width as one of the checkerboard fields around the whole board to improve the detection in various environments. In addition, because of the localized radon transformation it is beneficial to use round corners for the field corners which are located on the outside of the board. The following figure illustrates a sample checkerboard optimized for the detection. However, any other checkerboard can be used as well. Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard. ![Checkerboard](pics/checkerboard_radon.png)
        Returns:
        automatically generated
      • findChessboardCornersSB

        public static boolean findChessboardCornersSB​(Mat image,
                                                      Size patternSize,
                                                      Mat corners,
                                                      int flags)
      • findChessboardCornersSB

        public static boolean findChessboardCornersSB​(Mat image,
                                                      Size patternSize,
                                                      Mat corners)
      • estimateChessboardSharpness

        public static Scalar estimateChessboardSharpness​(Mat image,
                                                         Size patternSize,
                                                         Mat corners,
                                                         float rise_distance,
                                                         boolean vertical,
                                                         Mat sharpness)
        Estimates the sharpness of a detected chessboard. Image sharpness, as well as brightness, are a critical parameter for accuracte camera calibration. For accessing these parameters for filtering out problematic calibraiton images, this method calculates edge profiles by traveling from black to white chessboard cell centers. Based on this, the number of pixels is calculated required to transit from black to white. This width of the transition area is a good indication of how sharp the chessboard is imaged and should be below ~3.0 pixels.
        Parameters:
        image - Gray image used to find chessboard corners
        patternSize - Size of a found chessboard pattern
        corners - Corners found by #findChessboardCornersSB
        rise_distance - Rise distance 0.8 means 10% ... 90% of the final signal strength
        vertical - By default edge responses for horizontal lines are calculated
        sharpness - Optional output array with a sharpness value for calculated edge responses (see description) The optional sharpness array is of type CV_32FC1 and has for each calculated profile one row with the following five entries: 0 = x coordinate of the underlying edge in the image 1 = y coordinate of the underlying edge in the image 2 = width of the transition area (sharpness) 3 = signal strength in the black cell (min brightness) 4 = signal strength in the white cell (max brightness)
        Returns:
        Scalar(average sharpness, average min brightness, average max brightness,0)
      • estimateChessboardSharpness

        public static Scalar estimateChessboardSharpness​(Mat image,
                                                         Size patternSize,
                                                         Mat corners,
                                                         float rise_distance,
                                                         boolean vertical)
        Estimates the sharpness of a detected chessboard. Image sharpness, as well as brightness, are a critical parameter for accuracte camera calibration. For accessing these parameters for filtering out problematic calibraiton images, this method calculates edge profiles by traveling from black to white chessboard cell centers. Based on this, the number of pixels is calculated required to transit from black to white. This width of the transition area is a good indication of how sharp the chessboard is imaged and should be below ~3.0 pixels.
        Parameters:
        image - Gray image used to find chessboard corners
        patternSize - Size of a found chessboard pattern
        corners - Corners found by #findChessboardCornersSB
        rise_distance - Rise distance 0.8 means 10% ... 90% of the final signal strength
        vertical - By default edge responses for horizontal lines are calculated The optional sharpness array is of type CV_32FC1 and has for each calculated profile one row with the following five entries: 0 = x coordinate of the underlying edge in the image 1 = y coordinate of the underlying edge in the image 2 = width of the transition area (sharpness) 3 = signal strength in the black cell (min brightness) 4 = signal strength in the white cell (max brightness)
        Returns:
        Scalar(average sharpness, average min brightness, average max brightness,0)
      • estimateChessboardSharpness

        public static Scalar estimateChessboardSharpness​(Mat image,
                                                         Size patternSize,
                                                         Mat corners,
                                                         float rise_distance)
        Estimates the sharpness of a detected chessboard. Image sharpness, as well as brightness, are a critical parameter for accuracte camera calibration. For accessing these parameters for filtering out problematic calibraiton images, this method calculates edge profiles by traveling from black to white chessboard cell centers. Based on this, the number of pixels is calculated required to transit from black to white. This width of the transition area is a good indication of how sharp the chessboard is imaged and should be below ~3.0 pixels.
        Parameters:
        image - Gray image used to find chessboard corners
        patternSize - Size of a found chessboard pattern
        corners - Corners found by #findChessboardCornersSB
        rise_distance - Rise distance 0.8 means 10% ... 90% of the final signal strength The optional sharpness array is of type CV_32FC1 and has for each calculated profile one row with the following five entries: 0 = x coordinate of the underlying edge in the image 1 = y coordinate of the underlying edge in the image 2 = width of the transition area (sharpness) 3 = signal strength in the black cell (min brightness) 4 = signal strength in the white cell (max brightness)
        Returns:
        Scalar(average sharpness, average min brightness, average max brightness,0)
      • estimateChessboardSharpness

        public static Scalar estimateChessboardSharpness​(Mat image,
                                                         Size patternSize,
                                                         Mat corners)
        Estimates the sharpness of a detected chessboard. Image sharpness, as well as brightness, are a critical parameter for accuracte camera calibration. For accessing these parameters for filtering out problematic calibraiton images, this method calculates edge profiles by traveling from black to white chessboard cell centers. Based on this, the number of pixels is calculated required to transit from black to white. This width of the transition area is a good indication of how sharp the chessboard is imaged and should be below ~3.0 pixels.
        Parameters:
        image - Gray image used to find chessboard corners
        patternSize - Size of a found chessboard pattern
        corners - Corners found by #findChessboardCornersSB The optional sharpness array is of type CV_32FC1 and has for each calculated profile one row with the following five entries: 0 = x coordinate of the underlying edge in the image 1 = y coordinate of the underlying edge in the image 2 = width of the transition area (sharpness) 3 = signal strength in the black cell (min brightness) 4 = signal strength in the white cell (max brightness)
        Returns:
        Scalar(average sharpness, average min brightness, average max brightness,0)
      • find4QuadCornerSubpix

        public static boolean find4QuadCornerSubpix​(Mat img,
                                                    Mat corners,
                                                    Size region_size)
      • drawChessboardCorners

        public static void drawChessboardCorners​(Mat image,
                                                 Size patternSize,
                                                 MatOfPoint2f corners,
                                                 boolean patternWasFound)
        Renders the detected chessboard corners.
        Parameters:
        image - Destination image. It must be an 8-bit color image.
        patternSize - Number of inner corners per a chessboard row and column (patternSize = cv::Size(points_per_row,points_per_column)).
        corners - Array of detected corners, the output of #findChessboardCorners.
        patternWasFound - Parameter indicating whether the complete board was found or not. The return value of #findChessboardCorners should be passed here. The function draws individual chessboard corners detected either as red circles if the board was not found, or as colored corners connected with lines if the board was found.
      • findCirclesGrid

        public static boolean findCirclesGrid​(Mat image,
                                              Size patternSize,
                                              Mat centers,
                                              int flags)
      • findCirclesGrid

        public static boolean findCirclesGrid​(Mat image,
                                              Size patternSize,
                                              Mat centers)
      • calibrateCameraExtended

        public static double calibrateCameraExtended​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints,
                                                     Size imageSize,
                                                     Mat cameraMatrix,
                                                     Mat distCoeffs,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat stdDeviationsIntrinsics,
                                                     Mat stdDeviationsExtrinsics,
                                                     Mat perViewErrors,
                                                     int flags,
                                                     TermCriteria criteria)
        Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
        Parameters:
        objectPoints - In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer vector contains as many elements as the number of pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns or even different patterns in different views. Then, the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig. In the old interface all the vectors of object points from different views are concatenated together.
        imagePoints - In the new interface it is a vector of vectors of the projections of calibration pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal, respectively. In the old interface all the vectors of object points from different views are concatenated together.
        imageSize - Size of the image used only to initialize the camera intrinsic matrix.
        cameraMatrix - Input/output 3x3 floating-point camera intrinsic matrix \(\cameramatrix{A}\) . If REF: CALIB_USE_INTRINSIC_GUESS and/or REF: CALIB_FIX_ASPECT_RATIO, REF: CALIB_FIX_PRINCIPAL_POINT or REF: CALIB_FIX_FOCAL_LENGTH are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
        distCoeffs - Input/output vector of distortion coefficients \(\distcoeffs\).
        rvecs - Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view (e.g. std::vector<cv::Mat>>). That is, 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. 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. Due to its duality, this tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate space.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description above.
        stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: \((f_x, f_y, c_x, c_y, 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)\) If one of parameters is not estimated, it's deviation is equals to zero.
        stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use REF: solvePnP instead.
        • REF: CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global optimization. It stays at the center or at a different location specified when REF: CALIB_USE_INTRINSIC_GUESS is set too.
        • REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The ratio fx/fy stays the same as in the input cameraMatrix . When REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are ignored, only their ratio is computed and used further.
        • REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) are set to zeros and stay zero.
        • REF: CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if REF: CALIB_USE_INTRINSIC_GUESS is set.
        • REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 The corresponding radial distortion coefficient is not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. 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 or more.
        • REF: CALIB_THIN_PRISM_MODEL Coefficients 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 or more.
        • REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_TILTED_MODEL Coefficients 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.
        • REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        criteria - Termination criteria for the iterative optimization algorithm.
        Returns:
        the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object points and their corresponding 2D projections in each view must be specified. That may be achieved by using an object with known geometry and easily detectable feature points. Such an object is called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also be used as long as initial cameraMatrix is provided. The algorithm performs the following steps:
        • Compute the initial intrinsic parameters (the option only available for planar calibration patterns) or read them from the input parameters. The distortion coefficients are all set to zeros initially unless some of CALIB_FIX_K? are specified.
        • Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using REF: solvePnP .
        • Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points imagePoints and the projected (using the current estimates for camera parameters and the poses) object points objectPoints. See REF: projectPoints for details.
        Note: If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration, and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and \(c_y\) very far from the image center, and/or large differences between \(f_x\) and \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners. Note: The function may throw exceptions, if unsupported combination of parameters is provided or the system is underconstrained. SEE: calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
      • calibrateCameraExtended

        public static double calibrateCameraExtended​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints,
                                                     Size imageSize,
                                                     Mat cameraMatrix,
                                                     Mat distCoeffs,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat stdDeviationsIntrinsics,
                                                     Mat stdDeviationsExtrinsics,
                                                     Mat perViewErrors,
                                                     int flags)
        Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
        Parameters:
        objectPoints - In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer vector contains as many elements as the number of pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns or even different patterns in different views. Then, the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig. In the old interface all the vectors of object points from different views are concatenated together.
        imagePoints - In the new interface it is a vector of vectors of the projections of calibration pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal, respectively. In the old interface all the vectors of object points from different views are concatenated together.
        imageSize - Size of the image used only to initialize the camera intrinsic matrix.
        cameraMatrix - Input/output 3x3 floating-point camera intrinsic matrix \(\cameramatrix{A}\) . If REF: CALIB_USE_INTRINSIC_GUESS and/or REF: CALIB_FIX_ASPECT_RATIO, REF: CALIB_FIX_PRINCIPAL_POINT or REF: CALIB_FIX_FOCAL_LENGTH are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
        distCoeffs - Input/output vector of distortion coefficients \(\distcoeffs\).
        rvecs - Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view (e.g. std::vector<cv::Mat>>). That is, 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. 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. Due to its duality, this tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate space.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description above.
        stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: \((f_x, f_y, c_x, c_y, 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)\) If one of parameters is not estimated, it's deviation is equals to zero.
        stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use REF: solvePnP instead.
        • REF: CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global optimization. It stays at the center or at a different location specified when REF: CALIB_USE_INTRINSIC_GUESS is set too.
        • REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The ratio fx/fy stays the same as in the input cameraMatrix . When REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are ignored, only their ratio is computed and used further.
        • REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) are set to zeros and stay zero.
        • REF: CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if REF: CALIB_USE_INTRINSIC_GUESS is set.
        • REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 The corresponding radial distortion coefficient is not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. 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 or more.
        • REF: CALIB_THIN_PRISM_MODEL Coefficients 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 or more.
        • REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_TILTED_MODEL Coefficients 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.
        • REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        Returns:
        the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object points and their corresponding 2D projections in each view must be specified. That may be achieved by using an object with known geometry and easily detectable feature points. Such an object is called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also be used as long as initial cameraMatrix is provided. The algorithm performs the following steps:
        • Compute the initial intrinsic parameters (the option only available for planar calibration patterns) or read them from the input parameters. The distortion coefficients are all set to zeros initially unless some of CALIB_FIX_K? are specified.
        • Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using REF: solvePnP .
        • Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points imagePoints and the projected (using the current estimates for camera parameters and the poses) object points objectPoints. See REF: projectPoints for details.
        Note: If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration, and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and \(c_y\) very far from the image center, and/or large differences between \(f_x\) and \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners. Note: The function may throw exceptions, if unsupported combination of parameters is provided or the system is underconstrained. SEE: calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
      • calibrateCameraExtended

        public static double calibrateCameraExtended​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints,
                                                     Size imageSize,
                                                     Mat cameraMatrix,
                                                     Mat distCoeffs,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat stdDeviationsIntrinsics,
                                                     Mat stdDeviationsExtrinsics,
                                                     Mat perViewErrors)
        Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
        Parameters:
        objectPoints - In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer vector contains as many elements as the number of pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns or even different patterns in different views. Then, the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig. In the old interface all the vectors of object points from different views are concatenated together.
        imagePoints - In the new interface it is a vector of vectors of the projections of calibration pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal, respectively. In the old interface all the vectors of object points from different views are concatenated together.
        imageSize - Size of the image used only to initialize the camera intrinsic matrix.
        cameraMatrix - Input/output 3x3 floating-point camera intrinsic matrix \(\cameramatrix{A}\) . If REF: CALIB_USE_INTRINSIC_GUESS and/or REF: CALIB_FIX_ASPECT_RATIO, REF: CALIB_FIX_PRINCIPAL_POINT or REF: CALIB_FIX_FOCAL_LENGTH are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
        distCoeffs - Input/output vector of distortion coefficients \(\distcoeffs\).
        rvecs - Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view (e.g. std::vector<cv::Mat>>). That is, 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. 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. Due to its duality, this tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate space.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description above.
        stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: \((f_x, f_y, c_x, c_y, 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)\) If one of parameters is not estimated, it's deviation is equals to zero.
        stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        • REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use REF: solvePnP instead.
        • REF: CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global optimization. It stays at the center or at a different location specified when REF: CALIB_USE_INTRINSIC_GUESS is set too.
        • REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The ratio fx/fy stays the same as in the input cameraMatrix . When REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are ignored, only their ratio is computed and used further.
        • REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) are set to zeros and stay zero.
        • REF: CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if REF: CALIB_USE_INTRINSIC_GUESS is set.
        • REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 The corresponding radial distortion coefficient is not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. 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 or more.
        • REF: CALIB_THIN_PRISM_MODEL Coefficients 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 or more.
        • REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_TILTED_MODEL Coefficients 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.
        • REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        Returns:
        the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object points and their corresponding 2D projections in each view must be specified. That may be achieved by using an object with known geometry and easily detectable feature points. Such an object is called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also be used as long as initial cameraMatrix is provided. The algorithm performs the following steps:
        • Compute the initial intrinsic parameters (the option only available for planar calibration patterns) or read them from the input parameters. The distortion coefficients are all set to zeros initially unless some of CALIB_FIX_K? are specified.
        • Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using REF: solvePnP .
        • Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points imagePoints and the projected (using the current estimates for camera parameters and the poses) object points objectPoints. See REF: projectPoints for details.
        Note: If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration, and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and \(c_y\) very far from the image center, and/or large differences between \(f_x\) and \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners. Note: The function may throw exceptions, if unsupported combination of parameters is provided or the system is underconstrained. SEE: calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
      • calibrateCamera

        public static double calibrateCamera​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints,
                                             Size imageSize,
                                             Mat cameraMatrix,
                                             Mat distCoeffs,
                                             java.util.List<Mat> rvecs,
                                             java.util.List<Mat> tvecs,
                                             int flags,
                                             TermCriteria criteria)
      • calibrateCamera

        public static double calibrateCamera​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints,
                                             Size imageSize,
                                             Mat cameraMatrix,
                                             Mat distCoeffs,
                                             java.util.List<Mat> rvecs,
                                             java.util.List<Mat> tvecs,
                                             int flags)
      • calibrateCamera

        public static double calibrateCamera​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints,
                                             Size imageSize,
                                             Mat cameraMatrix,
                                             Mat distCoeffs,
                                             java.util.List<Mat> rvecs,
                                             java.util.List<Mat> tvecs)
      • calibrateCameraROExtended

        public static double calibrateCameraROExtended​(java.util.List<Mat> objectPoints,
                                                       java.util.List<Mat> imagePoints,
                                                       Size imageSize,
                                                       int iFixedPoint,
                                                       Mat cameraMatrix,
                                                       Mat distCoeffs,
                                                       java.util.List<Mat> rvecs,
                                                       java.util.List<Mat> tvecs,
                                                       Mat newObjPoints,
                                                       Mat stdDeviationsIntrinsics,
                                                       Mat stdDeviationsExtrinsics,
                                                       Mat stdDeviationsObjPoints,
                                                       Mat perViewErrors,
                                                       int flags,
                                                       TermCriteria criteria)
        Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. This function is an extension of #calibrateCamera with the method of releasing object which was proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar targets (calibration plates), this method can dramatically improve the precision of the estimated camera parameters. Both the object-releasing method and standard method are supported by this function. Use the parameter iFixedPoint for method selection. In the internal implementation, #calibrateCamera is a wrapper for this function.
        Parameters:
        objectPoints - Vector of vectors of calibration pattern points in the calibration pattern coordinate space. See #calibrateCamera for details. If the method of releasing object to be used, the identical calibration board must be used in each view and it must be fully visible, and all objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration target has to be rigid, or at least static if the camera (rather than the calibration target) is shifted for grabbing images.
        imagePoints - Vector of vectors of the projections of calibration pattern points. See #calibrateCamera for details.
        imageSize - Size of the image used only to initialize the intrinsic camera matrix.
        iFixedPoint - The index of the 3D object point in objectPoints[0] to be fixed. It also acts as a switch for calibration method selection. If object-releasing method to be used, pass in the parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will make standard calibration method selected. Usually the top-right corner point of the calibration board grid is recommended to be fixed when object-releasing method being utilized. According to \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
        cameraMatrix - Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
        distCoeffs - Output vector of distortion coefficients. See #calibrateCamera for details.
        rvecs - Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera for details.
        tvecs - Output vector of translation vectors estimated for each pattern view.
        newObjPoints - The updated output vector of calibration pattern points. The coordinates might be scaled based on three fixed points. The returned coordinates are accurate only if the above mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter is ignored with standard calibration method.
        stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters. See #calibrateCamera for details.
        stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters. See #calibrateCamera for details.
        stdDeviationsObjPoints - Output vector of standard deviations estimated for refined coordinates of calibration pattern points. It has the same size and order as objectPoints[0] vector. This parameter is ignored with standard calibration method.
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of some predefined values. See #calibrateCamera for details. If the method of releasing object is used, the calibration time may be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially less precise and less stable in some rare cases.
        criteria - Termination criteria for the iterative optimization algorithm.
        Returns:
        the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See #calibrateCamera for other detailed explanations. SEE: calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
      • calibrateCameraROExtended

        public static double calibrateCameraROExtended​(java.util.List<Mat> objectPoints,
                                                       java.util.List<Mat> imagePoints,
                                                       Size imageSize,
                                                       int iFixedPoint,
                                                       Mat cameraMatrix,
                                                       Mat distCoeffs,
                                                       java.util.List<Mat> rvecs,
                                                       java.util.List<Mat> tvecs,
                                                       Mat newObjPoints,
                                                       Mat stdDeviationsIntrinsics,
                                                       Mat stdDeviationsExtrinsics,
                                                       Mat stdDeviationsObjPoints,
                                                       Mat perViewErrors,
                                                       int flags)
        Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. This function is an extension of #calibrateCamera with the method of releasing object which was proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar targets (calibration plates), this method can dramatically improve the precision of the estimated camera parameters. Both the object-releasing method and standard method are supported by this function. Use the parameter iFixedPoint for method selection. In the internal implementation, #calibrateCamera is a wrapper for this function.
        Parameters:
        objectPoints - Vector of vectors of calibration pattern points in the calibration pattern coordinate space. See #calibrateCamera for details. If the method of releasing object to be used, the identical calibration board must be used in each view and it must be fully visible, and all objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration target has to be rigid, or at least static if the camera (rather than the calibration target) is shifted for grabbing images.
        imagePoints - Vector of vectors of the projections of calibration pattern points. See #calibrateCamera for details.
        imageSize - Size of the image used only to initialize the intrinsic camera matrix.
        iFixedPoint - The index of the 3D object point in objectPoints[0] to be fixed. It also acts as a switch for calibration method selection. If object-releasing method to be used, pass in the parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will make standard calibration method selected. Usually the top-right corner point of the calibration board grid is recommended to be fixed when object-releasing method being utilized. According to \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
        cameraMatrix - Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
        distCoeffs - Output vector of distortion coefficients. See #calibrateCamera for details.
        rvecs - Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera for details.
        tvecs - Output vector of translation vectors estimated for each pattern view.
        newObjPoints - The updated output vector of calibration pattern points. The coordinates might be scaled based on three fixed points. The returned coordinates are accurate only if the above mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter is ignored with standard calibration method.
        stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters. See #calibrateCamera for details.
        stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters. See #calibrateCamera for details.
        stdDeviationsObjPoints - Output vector of standard deviations estimated for refined coordinates of calibration pattern points. It has the same size and order as objectPoints[0] vector. This parameter is ignored with standard calibration method.
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of some predefined values. See #calibrateCamera for details. If the method of releasing object is used, the calibration time may be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially less precise and less stable in some rare cases.
        Returns:
        the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See #calibrateCamera for other detailed explanations. SEE: calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
      • calibrateCameraROExtended

        public static double calibrateCameraROExtended​(java.util.List<Mat> objectPoints,
                                                       java.util.List<Mat> imagePoints,
                                                       Size imageSize,
                                                       int iFixedPoint,
                                                       Mat cameraMatrix,
                                                       Mat distCoeffs,
                                                       java.util.List<Mat> rvecs,
                                                       java.util.List<Mat> tvecs,
                                                       Mat newObjPoints,
                                                       Mat stdDeviationsIntrinsics,
                                                       Mat stdDeviationsExtrinsics,
                                                       Mat stdDeviationsObjPoints,
                                                       Mat perViewErrors)
        Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. This function is an extension of #calibrateCamera with the method of releasing object which was proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar targets (calibration plates), this method can dramatically improve the precision of the estimated camera parameters. Both the object-releasing method and standard method are supported by this function. Use the parameter iFixedPoint for method selection. In the internal implementation, #calibrateCamera is a wrapper for this function.
        Parameters:
        objectPoints - Vector of vectors of calibration pattern points in the calibration pattern coordinate space. See #calibrateCamera for details. If the method of releasing object to be used, the identical calibration board must be used in each view and it must be fully visible, and all objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration target has to be rigid, or at least static if the camera (rather than the calibration target) is shifted for grabbing images.
        imagePoints - Vector of vectors of the projections of calibration pattern points. See #calibrateCamera for details.
        imageSize - Size of the image used only to initialize the intrinsic camera matrix.
        iFixedPoint - The index of the 3D object point in objectPoints[0] to be fixed. It also acts as a switch for calibration method selection. If object-releasing method to be used, pass in the parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will make standard calibration method selected. Usually the top-right corner point of the calibration board grid is recommended to be fixed when object-releasing method being utilized. According to \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
        cameraMatrix - Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
        distCoeffs - Output vector of distortion coefficients. See #calibrateCamera for details.
        rvecs - Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera for details.
        tvecs - Output vector of translation vectors estimated for each pattern view.
        newObjPoints - The updated output vector of calibration pattern points. The coordinates might be scaled based on three fixed points. The returned coordinates are accurate only if the above mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter is ignored with standard calibration method.
        stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters. See #calibrateCamera for details.
        stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters. See #calibrateCamera for details.
        stdDeviationsObjPoints - Output vector of standard deviations estimated for refined coordinates of calibration pattern points. It has the same size and order as objectPoints[0] vector. This parameter is ignored with standard calibration method.
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view. #calibrateCamera for details. If the method of releasing object is used, the calibration time may be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially less precise and less stable in some rare cases.
        Returns:
        the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See #calibrateCamera for other detailed explanations. SEE: calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
      • calibrateCameraRO

        public static double calibrateCameraRO​(java.util.List<Mat> objectPoints,
                                               java.util.List<Mat> imagePoints,
                                               Size imageSize,
                                               int iFixedPoint,
                                               Mat cameraMatrix,
                                               Mat distCoeffs,
                                               java.util.List<Mat> rvecs,
                                               java.util.List<Mat> tvecs,
                                               Mat newObjPoints,
                                               int flags,
                                               TermCriteria criteria)
      • calibrateCameraRO

        public static double calibrateCameraRO​(java.util.List<Mat> objectPoints,
                                               java.util.List<Mat> imagePoints,
                                               Size imageSize,
                                               int iFixedPoint,
                                               Mat cameraMatrix,
                                               Mat distCoeffs,
                                               java.util.List<Mat> rvecs,
                                               java.util.List<Mat> tvecs,
                                               Mat newObjPoints,
                                               int flags)
      • calibrateCameraRO

        public static double calibrateCameraRO​(java.util.List<Mat> objectPoints,
                                               java.util.List<Mat> imagePoints,
                                               Size imageSize,
                                               int iFixedPoint,
                                               Mat cameraMatrix,
                                               Mat distCoeffs,
                                               java.util.List<Mat> rvecs,
                                               java.util.List<Mat> tvecs,
                                               Mat newObjPoints)
      • calibrationMatrixValues

        public static void calibrationMatrixValues​(Mat cameraMatrix,
                                                   Size imageSize,
                                                   double apertureWidth,
                                                   double apertureHeight,
                                                   double[] fovx,
                                                   double[] fovy,
                                                   double[] focalLength,
                                                   Point principalPoint,
                                                   double[] aspectRatio)
        Computes useful camera characteristics from the camera intrinsic matrix.
        Parameters:
        cameraMatrix - Input camera intrinsic matrix that can be estimated by #calibrateCamera or #stereoCalibrate .
        imageSize - Input image size in pixels.
        apertureWidth - Physical width in mm of the sensor.
        apertureHeight - Physical height in mm of the sensor.
        fovx - Output field of view in degrees along the horizontal sensor axis.
        fovy - Output field of view in degrees along the vertical sensor axis.
        focalLength - Focal length of the lens in mm.
        principalPoint - Principal point in mm.
        aspectRatio - \(f_y/f_x\) The function computes various useful camera characteristics from the previously estimated camera matrix. Note: Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for the chessboard pitch (it can thus be any value).
      • stereoCalibrateExtended

        public static double stereoCalibrateExtended​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat cameraMatrix1,
                                                     Mat distCoeffs1,
                                                     Mat cameraMatrix2,
                                                     Mat distCoeffs2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     Mat E,
                                                     Mat F,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat perViewErrors,
                                                     int flags,
                                                     TermCriteria criteria)
        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.
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points. The same structure as in REF: 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.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in REF: calibrateCamera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in REF: calibrateCamera.
        cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
        distCoeffs1 - Input/output vector of distortion coefficients, the same as in REF: calibrateCamera.
        cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
        distCoeffs2 - Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
        imageSize - Size of the image used only to initialize the camera intrinsic matrices.
        R - 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.
        T - Output translation vector, see description above.
        E - Output essential matrix.
        F - Output fundamental matrix.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F matrices are estimated.
        • REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters according to the specified flags. Initial values are provided by the user.
        • REF: CALIB_USE_EXTRINSIC_GUESS R 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).
        • REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
        • REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
        • REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\) .
        • REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
        • REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to zeros and fix there.
        • REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial distortion coefficient during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_RATIONAL_MODEL Enable 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.
        • REF: CALIB_THIN_PRISM_MODEL Coefficients 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.
        • REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_TILTED_MODEL Coefficients 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.
        • REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        criteria - Termination 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_1\) \(T_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} R\) where \(T_i\) are components of the translation vector \(T\) : \(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 REF: CALIB_FIX_INTRINSIC flag 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, pass REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, 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.
        Returns:
        automatically generated
      • stereoCalibrateExtended

        public static double stereoCalibrateExtended​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat cameraMatrix1,
                                                     Mat distCoeffs1,
                                                     Mat cameraMatrix2,
                                                     Mat distCoeffs2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     Mat E,
                                                     Mat F,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat perViewErrors,
                                                     int flags)
        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.
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points. The same structure as in REF: 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.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in REF: calibrateCamera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in REF: calibrateCamera.
        cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
        distCoeffs1 - Input/output vector of distortion coefficients, the same as in REF: calibrateCamera.
        cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
        distCoeffs2 - Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
        imageSize - Size of the image used only to initialize the camera intrinsic matrices.
        R - 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.
        T - Output translation vector, see description above.
        E - Output essential matrix.
        F - Output fundamental matrix.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F matrices are estimated.
        • REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters according to the specified flags. Initial values are provided by the user.
        • REF: CALIB_USE_EXTRINSIC_GUESS R 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).
        • REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
        • REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
        • REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\) .
        • REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
        • REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to zeros and fix there.
        • REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial distortion coefficient during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_RATIONAL_MODEL Enable 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.
        • REF: CALIB_THIN_PRISM_MODEL Coefficients 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.
        • REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_TILTED_MODEL Coefficients 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.
        • REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        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_1\) \(T_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} R\) where \(T_i\) are components of the translation vector \(T\) : \(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 REF: CALIB_FIX_INTRINSIC flag 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, pass REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, 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.
        Returns:
        automatically generated
      • stereoCalibrateExtended

        public static double stereoCalibrateExtended​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat cameraMatrix1,
                                                     Mat distCoeffs1,
                                                     Mat cameraMatrix2,
                                                     Mat distCoeffs2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     Mat E,
                                                     Mat F,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat perViewErrors)
        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.
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points. The same structure as in REF: 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.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in REF: calibrateCamera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in REF: calibrateCamera.
        cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
        distCoeffs1 - Input/output vector of distortion coefficients, the same as in REF: calibrateCamera.
        cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
        distCoeffs2 - Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
        imageSize - Size of the image used only to initialize the camera intrinsic matrices.
        R - 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.
        T - Output translation vector, see description above.
        E - Output essential matrix.
        F - Output fundamental matrix.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        • REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F matrices are estimated.
        • REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters according to the specified flags. Initial values are provided by the user.
        • REF: CALIB_USE_EXTRINSIC_GUESS R 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).
        • REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
        • REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
        • REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\) .
        • REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
        • REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to zeros and fix there.
        • REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial distortion coefficient during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_RATIONAL_MODEL Enable 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.
        • REF: CALIB_THIN_PRISM_MODEL Coefficients 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.
        • REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        • REF: CALIB_TILTED_MODEL Coefficients 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.
        • REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
        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_1\) \(T_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} R\) where \(T_i\) are components of the translation vector \(T\) : \(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 REF: CALIB_FIX_INTRINSIC flag 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, pass REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, 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.
        Returns:
        automatically generated
      • stereoCalibrate

        public static double stereoCalibrate​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             Size imageSize,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             int flags,
                                             TermCriteria criteria)
      • stereoCalibrate

        public static double stereoCalibrate​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             Size imageSize,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             int flags)
      • stereoCalibrate

        public static double stereoCalibrate​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             Size imageSize,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F)
      • stereoCalibrate

        public static double stereoCalibrate​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             Size imageSize,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             Mat perViewErrors,
                                             int flags,
                                             TermCriteria criteria)
      • stereoCalibrate

        public static double stereoCalibrate​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             Size imageSize,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             Mat perViewErrors,
                                             int flags)
      • stereoCalibrate

        public static double stereoCalibrate​(java.util.List<Mat> objectPoints,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             Size imageSize,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             Mat perViewErrors)
      • registerCamerasExtended

        public static double registerCamerasExtended​(java.util.List<Mat> objectPoints1,
                                                     java.util.List<Mat> objectPoints2,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat cameraMatrix1,
                                                     Mat distCoeffs1,
                                                     int cameraModel1,
                                                     Mat cameraMatrix2,
                                                     Mat distCoeffs2,
                                                     int cameraModel2,
                                                     Mat R,
                                                     Mat T,
                                                     Mat E,
                                                     Mat F,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat perViewErrors,
                                                     int flags,
                                                     TermCriteria criteria)
        Calibrates a camera pair set up. This function finds the extrinsic parameters between the two cameras.
        Parameters:
        objectPoints1 - Vector of vectors of the calibration pattern points for camera 1. A similar structure as objectPoints in REF: calibrateCamera and for each pattern view, both cameras do not need to see the same object points. objectPoints1.size(), imagePoints1.size() nees to be equal,as well as objectPoints1[i].size(), imagePoints1[i].size() need to be equal for each i.
        objectPoints2 - Vector of vectors of the calibration pattern points for camera 2. A similar structure as objectPoints1. objectPoints2.size(), and imagePoints2.size() nees to be equal, as well as objectPoints2[i].size(), imagePoints2[i].size() need to be equal for each i. However, objectPoints1[i].size() and objectPoints2[i].size() are not required to be equal.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in REF: calibrateCamera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in REF: calibrateCamera.
        cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
        distCoeffs1 - Input/output vector of distortion coefficients, the same as in REF: calibrateCamera.
        cameraModel1 - Flag reflecting the type of model for camera 1 (pinhole / fisheye):
        • REF: CALIB_MODEL_PINHOLE pinhole camera model
        • REF: CALIB_MODEL_FISHEYE fisheye camera model
        cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
        distCoeffs2 - Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
        cameraModel2 - Flag reflecting the type of model for camera 2 (pinhole / fisheye). See description for cameraModel1.
        R - 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.
        T - Output translation vector, see description above.
        E - Output essential matrix.
        F - Output fundamental matrix.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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 the camera coordinate space of the first camera of the stereo pair.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
        criteria - Termination criteria for the iterative optimization algorithm. The function estimates the transformation between two cameras similar to stereo pair calibration. The principle follows closely to REF: stereoCalibrate. To understand the problem of estimating the relative pose between a camera pair, please refer to the description there. The difference for this function is that, camera intrinsics are not optimized and two cameras are not required to have overlapping fields of view as long as they are observing the same calibration target and the absolute positions of each object point are known. ![](pics/register_pair.png) The above illustration shows an example where such a case may become relevant. Additionally, it supports a camera pair with the mixed model (pinhole / fisheye). Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the points in all the available views from both cameras.
        Returns:
        the final value of the re-projection error. SEE: calibrateCamera, stereoCalibrate
      • registerCamerasExtended

        public static double registerCamerasExtended​(java.util.List<Mat> objectPoints1,
                                                     java.util.List<Mat> objectPoints2,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat cameraMatrix1,
                                                     Mat distCoeffs1,
                                                     int cameraModel1,
                                                     Mat cameraMatrix2,
                                                     Mat distCoeffs2,
                                                     int cameraModel2,
                                                     Mat R,
                                                     Mat T,
                                                     Mat E,
                                                     Mat F,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat perViewErrors,
                                                     int flags)
        Calibrates a camera pair set up. This function finds the extrinsic parameters between the two cameras.
        Parameters:
        objectPoints1 - Vector of vectors of the calibration pattern points for camera 1. A similar structure as objectPoints in REF: calibrateCamera and for each pattern view, both cameras do not need to see the same object points. objectPoints1.size(), imagePoints1.size() nees to be equal,as well as objectPoints1[i].size(), imagePoints1[i].size() need to be equal for each i.
        objectPoints2 - Vector of vectors of the calibration pattern points for camera 2. A similar structure as objectPoints1. objectPoints2.size(), and imagePoints2.size() nees to be equal, as well as objectPoints2[i].size(), imagePoints2[i].size() need to be equal for each i. However, objectPoints1[i].size() and objectPoints2[i].size() are not required to be equal.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in REF: calibrateCamera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in REF: calibrateCamera.
        cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
        distCoeffs1 - Input/output vector of distortion coefficients, the same as in REF: calibrateCamera.
        cameraModel1 - Flag reflecting the type of model for camera 1 (pinhole / fisheye):
        • REF: CALIB_MODEL_PINHOLE pinhole camera model
        • REF: CALIB_MODEL_FISHEYE fisheye camera model
        cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
        distCoeffs2 - Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
        cameraModel2 - Flag reflecting the type of model for camera 2 (pinhole / fisheye). See description for cameraModel1.
        R - 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.
        T - Output translation vector, see description above.
        E - Output essential matrix.
        F - Output fundamental matrix.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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 the camera coordinate space of the first camera of the stereo pair.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
        The function estimates the transformation between two cameras similar to stereo pair calibration. The principle follows closely to REF: stereoCalibrate. To understand the problem of estimating the relative pose between a camera pair, please refer to the description there. The difference for this function is that, camera intrinsics are not optimized and two cameras are not required to have overlapping fields of view as long as they are observing the same calibration target and the absolute positions of each object point are known. ![](pics/register_pair.png) The above illustration shows an example where such a case may become relevant. Additionally, it supports a camera pair with the mixed model (pinhole / fisheye). Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the points in all the available views from both cameras.
        Returns:
        the final value of the re-projection error. SEE: calibrateCamera, stereoCalibrate
      • registerCamerasExtended

        public static double registerCamerasExtended​(java.util.List<Mat> objectPoints1,
                                                     java.util.List<Mat> objectPoints2,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat cameraMatrix1,
                                                     Mat distCoeffs1,
                                                     int cameraModel1,
                                                     Mat cameraMatrix2,
                                                     Mat distCoeffs2,
                                                     int cameraModel2,
                                                     Mat R,
                                                     Mat T,
                                                     Mat E,
                                                     Mat F,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     Mat perViewErrors)
        Calibrates a camera pair set up. This function finds the extrinsic parameters between the two cameras.
        Parameters:
        objectPoints1 - Vector of vectors of the calibration pattern points for camera 1. A similar structure as objectPoints in REF: calibrateCamera and for each pattern view, both cameras do not need to see the same object points. objectPoints1.size(), imagePoints1.size() nees to be equal,as well as objectPoints1[i].size(), imagePoints1[i].size() need to be equal for each i.
        objectPoints2 - Vector of vectors of the calibration pattern points for camera 2. A similar structure as objectPoints1. objectPoints2.size(), and imagePoints2.size() nees to be equal, as well as objectPoints2[i].size(), imagePoints2[i].size() need to be equal for each i. However, objectPoints1[i].size() and objectPoints2[i].size() are not required to be equal.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera. The same structure as in REF: calibrateCamera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera. The same structure as in REF: calibrateCamera.
        cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
        distCoeffs1 - Input/output vector of distortion coefficients, the same as in REF: calibrateCamera.
        cameraModel1 - Flag reflecting the type of model for camera 1 (pinhole / fisheye):
        • REF: CALIB_MODEL_PINHOLE pinhole camera model
        • REF: CALIB_MODEL_FISHEYE fisheye camera model
        cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for cameraMatrix1.
        distCoeffs2 - Input/output lens distortion coefficients for the second camera. See description for distCoeffs1.
        cameraModel2 - Flag reflecting the type of model for camera 2 (pinhole / fisheye). See description for cameraModel1.
        R - 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.
        T - Output translation vector, see description above.
        E - Output essential matrix.
        F - Output fundamental matrix.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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 the camera coordinate space of the first camera of the stereo pair.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
        • REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
        The function estimates the transformation between two cameras similar to stereo pair calibration. The principle follows closely to REF: stereoCalibrate. To understand the problem of estimating the relative pose between a camera pair, please refer to the description there. The difference for this function is that, camera intrinsics are not optimized and two cameras are not required to have overlapping fields of view as long as they are observing the same calibration target and the absolute positions of each object point are known. ![](pics/register_pair.png) The above illustration shows an example where such a case may become relevant. Additionally, it supports a camera pair with the mixed model (pinhole / fisheye). Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the points in all the available views from both cameras.
        Returns:
        the final value of the re-projection error. SEE: calibrateCamera, stereoCalibrate
      • registerCameras

        public static double registerCameras​(java.util.List<Mat> objectPoints1,
                                             java.util.List<Mat> objectPoints2,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             int cameraModel1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             int cameraModel2,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             Mat perViewErrors,
                                             int flags,
                                             TermCriteria criteria)
      • registerCameras

        public static double registerCameras​(java.util.List<Mat> objectPoints1,
                                             java.util.List<Mat> objectPoints2,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             int cameraModel1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             int cameraModel2,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             Mat perViewErrors,
                                             int flags)
      • registerCameras

        public static double registerCameras​(java.util.List<Mat> objectPoints1,
                                             java.util.List<Mat> objectPoints2,
                                             java.util.List<Mat> imagePoints1,
                                             java.util.List<Mat> imagePoints2,
                                             Mat cameraMatrix1,
                                             Mat distCoeffs1,
                                             int cameraModel1,
                                             Mat cameraMatrix2,
                                             Mat distCoeffs2,
                                             int cameraModel2,
                                             Mat R,
                                             Mat T,
                                             Mat E,
                                             Mat F,
                                             Mat perViewErrors)
      • fisheye_calibrate

        public static double fisheye_calibrate​(java.util.List<Mat> objectPoints,
                                               java.util.List<Mat> imagePoints,
                                               Size image_size,
                                               Mat K,
                                               Mat D,
                                               java.util.List<Mat> rvecs,
                                               java.util.List<Mat> tvecs,
                                               int flags,
                                               TermCriteria criteria)
        Performs camera calibration
        Parameters:
        objectPoints - vector of vectors of calibration pattern points in the calibration pattern coordinate space.
        imagePoints - vector of vectors of the projections of calibration pattern points. imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to objectPoints[i].size() for each i.
        image_size - Size of the image used only to initialize the camera intrinsic matrix.
        K - Output 3x3 floating-point camera intrinsic matrix \(\cameramatrix{A}\) . If REF: cv::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
        D - Output vector of distortion coefficients \(\distcoeffsfisheye\).
        rvecs - Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
        tvecs - Output vector of translation vectors estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: cv::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion.
        • REF: cv::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration of intrinsic optimization.
        • REF: cv::CALIB_CHECK_COND The functions will check validity of condition number.
        • REF: cv::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
        • REF: cv::CALIB_FIX_K1,..., REF: cv::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay zero.
        • REF: cv::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global optimization. It stays at the center or at a different location specified when REF: cv::CALIB_USE_INTRINSIC_GUESS is set too.
        • REF: cv::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: cv::CALIB_USE_INTRINSIC_GUESS is set too.
        criteria - Termination criteria for the iterative optimization algorithm.
        Returns:
        automatically generated
      • fisheye_calibrate

        public static double fisheye_calibrate​(java.util.List<Mat> objectPoints,
                                               java.util.List<Mat> imagePoints,
                                               Size image_size,
                                               Mat K,
                                               Mat D,
                                               java.util.List<Mat> rvecs,
                                               java.util.List<Mat> tvecs,
                                               int flags)
        Performs camera calibration
        Parameters:
        objectPoints - vector of vectors of calibration pattern points in the calibration pattern coordinate space.
        imagePoints - vector of vectors of the projections of calibration pattern points. imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to objectPoints[i].size() for each i.
        image_size - Size of the image used only to initialize the camera intrinsic matrix.
        K - Output 3x3 floating-point camera intrinsic matrix \(\cameramatrix{A}\) . If REF: cv::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
        D - Output vector of distortion coefficients \(\distcoeffsfisheye\).
        rvecs - Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
        tvecs - Output vector of translation vectors estimated for each pattern view.
        flags - Different flags that may be zero or a combination of the following values:
        • REF: cv::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion.
        • REF: cv::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration of intrinsic optimization.
        • REF: cv::CALIB_CHECK_COND The functions will check validity of condition number.
        • REF: cv::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
        • REF: cv::CALIB_FIX_K1,..., REF: cv::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay zero.
        • REF: cv::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global optimization. It stays at the center or at a different location specified when REF: cv::CALIB_USE_INTRINSIC_GUESS is set too.
        • REF: cv::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: cv::CALIB_USE_INTRINSIC_GUESS is set too.
        Returns:
        automatically generated
      • fisheye_calibrate

        public static double fisheye_calibrate​(java.util.List<Mat> objectPoints,
                                               java.util.List<Mat> imagePoints,
                                               Size image_size,
                                               Mat K,
                                               Mat D,
                                               java.util.List<Mat> rvecs,
                                               java.util.List<Mat> tvecs)
        Performs camera calibration
        Parameters:
        objectPoints - vector of vectors of calibration pattern points in the calibration pattern coordinate space.
        imagePoints - vector of vectors of the projections of calibration pattern points. imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to objectPoints[i].size() for each i.
        image_size - Size of the image used only to initialize the camera intrinsic matrix.
        K - Output 3x3 floating-point camera intrinsic matrix \(\cameramatrix{A}\) . If REF: cv::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
        D - Output vector of distortion coefficients \(\distcoeffsfisheye\).
        rvecs - Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
        tvecs - Output vector of translation vectors estimated for each pattern view.
        • REF: cv::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion.
        • REF: cv::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration of intrinsic optimization.
        • REF: cv::CALIB_CHECK_COND The functions will check validity of condition number.
        • REF: cv::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
        • REF: cv::CALIB_FIX_K1,..., REF: cv::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay zero.
        • REF: cv::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global optimization. It stays at the center or at a different location specified when REF: cv::CALIB_USE_INTRINSIC_GUESS is set too.
        • REF: cv::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: cv::CALIB_USE_INTRINSIC_GUESS is set too.
        Returns:
        automatically generated
      • fisheye_stereoCalibrate

        public static double fisheye_stereoCalibrate​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat K1,
                                                     Mat D1,
                                                     Mat K2,
                                                     Mat D2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     int flags,
                                                     TermCriteria criteria)
        Performs stereo calibration
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera.
        K1 - Input/output first camera intrinsic matrix: \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If any of REF: cv::CALIB_USE_INTRINSIC_GUESS , REF: cv::CALIB_FIX_INTRINSIC are specified, some or all of the matrix components must be initialized.
        D1 - Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
        K2 - Input/output second camera intrinsic matrix. The parameter is similar to K1 .
        D2 - Input/output lens distortion coefficients for the second camera. The parameter is similar to D1 .
        imageSize - Size of the image used only to initialize camera intrinsic matrix.
        R - Output rotation matrix between the 1st and the 2nd camera coordinate systems.
        T - Output translation vector between the coordinate systems of the cameras.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        flags - Different flags that may be zero or a combination of the following values:
        • REF: cv::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices are estimated.
        • REF: cv::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center (imageSize is used), and focal distances are computed in a least-squares fashion.
        • REF: cv::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration of intrinsic optimization.
        • REF: cv::CALIB_CHECK_COND The functions will check validity of condition number.
        • REF: cv::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
        • REF: cv::CALIB_FIX_K1,..., REF: cv::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay zero.
        criteria - Termination criteria for the iterative optimization algorithm.
        Returns:
        automatically generated
      • fisheye_stereoCalibrate

        public static double fisheye_stereoCalibrate​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat K1,
                                                     Mat D1,
                                                     Mat K2,
                                                     Mat D2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs,
                                                     int flags)
        Performs stereo calibration
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera.
        K1 - Input/output first camera intrinsic matrix: \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If any of REF: cv::CALIB_USE_INTRINSIC_GUESS , REF: cv::CALIB_FIX_INTRINSIC are specified, some or all of the matrix components must be initialized.
        D1 - Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
        K2 - Input/output second camera intrinsic matrix. The parameter is similar to K1 .
        D2 - Input/output lens distortion coefficients for the second camera. The parameter is similar to D1 .
        imageSize - Size of the image used only to initialize camera intrinsic matrix.
        R - Output rotation matrix between the 1st and the 2nd camera coordinate systems.
        T - Output translation vector between the coordinate systems of the cameras.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        flags - Different flags that may be zero or a combination of the following values:
        • REF: cv::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices are estimated.
        • REF: cv::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center (imageSize is used), and focal distances are computed in a least-squares fashion.
        • REF: cv::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration of intrinsic optimization.
        • REF: cv::CALIB_CHECK_COND The functions will check validity of condition number.
        • REF: cv::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
        • REF: cv::CALIB_FIX_K1,..., REF: cv::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay zero.
        Returns:
        automatically generated
      • fisheye_stereoCalibrate

        public static double fisheye_stereoCalibrate​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat K1,
                                                     Mat D1,
                                                     Mat K2,
                                                     Mat D2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     java.util.List<Mat> rvecs,
                                                     java.util.List<Mat> tvecs)
        Performs stereo calibration
        Parameters:
        objectPoints - Vector of vectors of the calibration pattern points.
        imagePoints1 - Vector of vectors of the projections of the calibration pattern points, observed by the first camera.
        imagePoints2 - Vector of vectors of the projections of the calibration pattern points, observed by the second camera.
        K1 - Input/output first camera intrinsic matrix: \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If any of REF: cv::CALIB_USE_INTRINSIC_GUESS , REF: cv::CALIB_FIX_INTRINSIC are specified, some or all of the matrix components must be initialized.
        D1 - Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
        K2 - Input/output second camera intrinsic matrix. The parameter is similar to K1 .
        D2 - Input/output lens distortion coefficients for the second camera. The parameter is similar to D1 .
        imageSize - Size of the image used only to initialize camera intrinsic matrix.
        R - Output rotation matrix between the 1st and the 2nd camera coordinate systems.
        T - Output translation vector between the coordinate systems of the cameras.
        rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::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.
        tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description of previous output parameter ( rvecs ).
        • REF: cv::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices are estimated.
        • REF: cv::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image center (imageSize is used), and focal distances are computed in a least-squares fashion.
        • REF: cv::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration of intrinsic optimization.
        • REF: cv::CALIB_CHECK_COND The functions will check validity of condition number.
        • REF: cv::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
        • REF: cv::CALIB_FIX_K1,..., REF: cv::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay zero.
        Returns:
        automatically generated
      • fisheye_stereoCalibrate

        public static double fisheye_stereoCalibrate​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat K1,
                                                     Mat D1,
                                                     Mat K2,
                                                     Mat D2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     int flags,
                                                     TermCriteria criteria)
      • fisheye_stereoCalibrate

        public static double fisheye_stereoCalibrate​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat K1,
                                                     Mat D1,
                                                     Mat K2,
                                                     Mat D2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T,
                                                     int flags)
      • fisheye_stereoCalibrate

        public static double fisheye_stereoCalibrate​(java.util.List<Mat> objectPoints,
                                                     java.util.List<Mat> imagePoints1,
                                                     java.util.List<Mat> imagePoints2,
                                                     Mat K1,
                                                     Mat D1,
                                                     Mat K2,
                                                     Mat D2,
                                                     Size imageSize,
                                                     Mat R,
                                                     Mat T)