stereoCalibrate() updates camera matrices but fails to update the distortion coefficients

Hi,

I am trying to use the cv2.stereoCalibrate() function as in here, I passed in only one flag, cv2.CALIB_USE_INTRINSIC_GUESS, and noticed that the function would update the camera matrices as expected in the documentation. However, it would not update the distortion coefficients and I have to update it manually.

For example, here’s a snippet of my code:

reprojection_error_px, K1_stereo, D1_stereo, K2_stereo, D2_stereo, R, t, E, F = cv2.stereoCalibrate(
            objpoints,
            left_imgpoints_filtered,
            right_imgpoints_filtered,
            left_camera_mtx,
            left_dists,
            right_camera_mtx,
            right_dists,
            (w, h),
            criteria=criteria,
            flags=flags
        )

Where the calibration criteria and flags used are:

STEREO_CALIB_CRITERIA = (cv2.TERM_CRITERIA_MAX_ITER + cv2.TERM_CRITERIA_EPS, 100, 1e-5)
STEREO_CALIB_FLAGS = cv2.CALIB_USE_INTRINSIC_GUESS

After running the code above and do some printing, I found that left_camera_mtx and right_camera_mtx is identical to K1_stereo and K2_stereo respectfully, which is expected from the documentation as they are InputOutputArray according to the documentation. But left_dists and right_dists are still the values I passed into the function, and D1_stereo and D2_stereo is some new values that the function returns.

Shouldn’t left_dists and right_dists be updated, just like the camera internal matrices? I believe I have passed in the correct flag to make it happen, in this case CALIB_USE_INTRINSIC_GUESS.

Could anybody kindly run this function and print out the results, see if the problem is due to some bug of the stereoCalibrate() function? I’m in Ubuntu 22.04, Python version 3.10.12 and cv2 version 4.5.4

Thanks!