c++ - stereoCalibrate() changes focal lengths even when it was not supposed to -


i noticed opencv stereocalibrate() changes focal lengths in camera matrices though i've set appropriate flag (ie cv_calib_fix_focal_length). i'm using 2 identical cameras same focal length set mechanically on lens , furthermore know sensor size can compute intrinsic camera matrix manually do.

here have output form stereo calibration program - camera matrices before , after stereocalibrate().

    std::cout << "before calibration: " << std::endl;     std::cout << "c1: " << _cameramatrixa << std::endl;     std::cout << "c2: " << _cameramatrixb << std::endl;      double error = cv::stereocalibrate(objectpoints, imagepointsa, imagepointsb, _cameramatrixa, _distcoeffsa, _cameramatrixb, _distcoeffsb, _imagesize,         r, t, e, f,          cv::termcriteria((cv::termcriteria::count + cv::termcriteria::eps), 30, 9.999999999999e-7), cv_calib_fix_focal_length | cv_calib_fix_principal_point);      std::cout << "after calibration: " << std::endl;     std::cout << "c1: " << _cameramatrixa << std::endl;     std::cout << "c2: " << _cameramatrixb << std::endl; 

before calibration:

c1: [6203.076923076923, 0, 1280; 0, 6203.076923076923, 960; 0, 0, 1]

c2: [6203.076923076923, 0, 1280; 0, 6203.076923076923, 960; 0, 0, 1]

after calibration:

c1: [6311.77650416514, 0, 1279.5; 0, 6331.34531760757, 959.5; 0, 0, 1]

c2: [6152.655897294907, 0, 1279.5; 0, 6206.591406832492, 959.5; 0, 0, 1]

i think weird opencv behavior. faced similar problem? know easy solve, can set focal lengths camera matrices after stereo calibration.

in order want, have call stereocalibrate flags:

cv_calib_use_intrinsic_guess | cv_calib_fix_focal_length | cv_calib_fix_principal_point 

if not use cv_calib_use_intrinsic_guess flag, stereocalibrate first initialize camera matrices , distortion coefficients , fix part of them in subsequent optimization. stated in documentation, although rather unclearly , without mentionning critical flag:

besides stereo-related information, function can perform full calibration of each of 2 cameras. however, due high dimensionality of parameter space , noise in input data, function can diverge correct solution. if intrinsic parameters can estimated high accuracy each of cameras individually (for example, using calibratecamera() ), recommended [...].

using cv_calib_use_intrinsic_guess in addition of cv_calib_fix_* flags tells function use passing input, otherwise, input ignored , overwritten.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -