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

**URL:** <https://forum.opencv.org/t/stereocalibrate-updates-camera-matrices-but-fails-to-update-the-distortion-coefficients/17764>\
**Category:** Python\
**Created:** [May 27, 2024, 4:09pm UTC](https://forum.opencv.org/t/stereocalibrate-updates-camera-matrices-but-fails-to-update-the-distortion-coefficients/17764 "2024-05-27T16:09:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ziye](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/ziye/32/10561_2.png) [@Ziye](https://forum.opencv.org/u/Ziye)\
**Post date:** [May 27, 2024, 4:09pm UTC](https://forum.opencv.org/t/stereocalibrate-updates-camera-matrices-but-fails-to-update-the-distortion-coefficients/17764/1 "2024-05-27T16:09:57Z")

</div>

Hi,

I am trying to use the cv2.stereoCalibrate() function as in [here](https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga91018d80e2a93ade37539f01e6f07de5), 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:

```auto
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:

```auto
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](https://docs.opencv.org/4.x/dc/d84/group __core__ basic.html#gaf77c9a14ef956c50c1efd4547f444e63) 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!
