# OpenCV exception during ZED X One stereo calibration

**URL:** <https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048>\
**Category:** Software\
**Tags:** calibration\
**Created:** [September 30, 2025, 3:32pm UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048 "2025-09-30T15:32:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![carolina](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@carolina](https://community.stereolabs.com/u/carolina)\
**Post date:** [September 30, 2025, 3:32pm UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048/1 "2025-09-30T15:32:21Z")

</div>

Hello support team,

when running stereo calibration, the process fails with an OpenCV exception after outputting “stereo rectification matrix”.

Environment:

- Jetson AGX Orin (ARM64)

- Argus Capture 1.1.0, OpenCV 4.13.0-dev

- 2x ZED X One cameras

- 3840x2160 @ 25 fps

- Checkerboard 15x10, square size 70 mm

Result:

- Reprojection error: Left 0.3381, Right 0.3491, Stereo 0.3967

- Log:

```auto
* Stereo rectification matrix
0.00360482
terminate called after throwing an instance of 'cv::Exception'
  what(): OpenCV(4.13.0-dev) /usr/local/include/opencv4/opencv2/core/mat.inl.hpp:899:
  error: (-215:Assertion failed) (unsigned)(i1 * DataType<_Tp>::channels) <
  (unsigned)(size.p[1] * channels()) in function 'at'

```

Could you advise on a fix or confirm if this is a known issue? I can share the full log if needed.

Thank you,

Carolina

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [September 30, 2025, 7:16pm UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048/2 "2025-09-30T19:16:52Z")

</div>

Hi @carolina  
Welcome to the [Stereolabs](https://www.stereolabs.com/) community.

Please share a picture of the Checkerboard that you are using.

> [@carolina](#):
>
> 3840x2160 @ 25 fps

What model of ZED X One cameras are you using?

---

<div class="post-metadata">

**Author:** ![carolina](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@carolina](https://community.stereolabs.com/u/carolina)\
**Post date:** [October 1, 2025, 8:46am UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048/3 "2025-10-01T08:46:30Z")

</div>

Hi @Myzhar, thank you for the fast reply.

I’ve attached a picture of the checkerboard.

The model we’re using is the ZED X One 4K HDR RS Wide.

 ![IMG_6145](https://community.stereolabs.com/uploads/default/original/2X/f/f9ffb017e0a66d96cb45d2c40b6a289d1e026a8b.jpeg)

---

<div class="post-metadata">

**Author:** ![SL-PY](https://community.stereolabs.com/user_avatar/community.stereolabs.com/sl-py/32/3_2.png) [@SL-PY](https://community.stereolabs.com/u/SL-PY)\
**Post date:** [October 3, 2025, 12:29pm UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048/4 "2025-10-03T12:29:22Z")

</div>

Hello @carolina ,  
Can you skip (comment) the part to compute the Field of view:

> <https://github.com/stereolabs/zedx-one-capture/blob/main/stereo_calibration/main.cpp#L642-L652>

and directly call `WriteConfFile` after `stereoRectify`.

for dbg only can you print the content of `matQ`?

---

<div class="post-metadata">

**Author:** ![carolina](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@carolina](https://community.stereolabs.com/u/carolina)\
**Post date:** [October 6, 2025, 1:42pm UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048/5 "2025-10-06T13:42:38Z")

</div>

Hey @SL-PY ,  
I’ve commented out the block and was able to print matQ:

```auto
[1, 0, 0, -1866.378479003906;
 0, 1, 0, -1052.041397094727;
 0, 0, 0, 1587.334816667074;
 0, 0, 0.003604818995919432, -0]

```

But as soon as I try to save the distortion parameters, another exception is thrown after `outfile << "k4 = " << distortion_left.at<double>(5) << "\n";)`:

```auto
terminate called after throwing an instance of ‘cv::Exception’what(): OpenCV(4.13.0-dev) /usr/local/include/opencv4/opencv2/core/mat.inl.hpp:942: error: (-215:Assertion failed) (unsigned)i0 < (unsigned)(size.p[0] * size.p[1]) in function ‘at’

```

After printing the vectors, I noticed that `distortion_left` and `distortion_right` both have only five entries instead of eight `k1`,…`k6`

```auto
 distortion_left
[-0.01244016112943664;
 -0.07318124688870557;
 0.0003943722341370349;
 -0.0002872823397780006;
 0.03007179337926875]

distortion_right
[-0.02322516071418135;
 -0.05095318658973153;
 0.0005344149067437637;
 -0.0002761644861793466;
 0.01895889737256499]

```

By commenting out the lines with the parameters `k4` to `k6` I was able to create a conf file:

[SN100819890.conf](https://community.stereolabs.com/uploads/short-url/33HiGmaK6YoqBmXjS4G7hUvWUi7.conf) (1.1 KB)

Should I set `k4`, `k5` and `k6` to 0 instead, or add the flag `cv::CALIB_RATIONAL_MODEL`? Or is this calibration file fine as it is?

---

<div class="post-metadata">

**Author:** ![SL-PY](https://community.stereolabs.com/user_avatar/community.stereolabs.com/sl-py/32/3_2.png) [@SL-PY](https://community.stereolabs.com/u/SL-PY)\
**Post date:** [October 7, 2025, 7:27am UTC](https://community.stereolabs.com/t/opencv-exception-during-zed-x-one-stereo-calibration/10048/6 "2025-10-07T07:27:06Z")

</div>

You can use both solutions,

- enable CALIB\_RATIONAL\_MODEL to have 8 disto parameter
- simply let k4,k5,k6 to 0 (or leave them empty as it is right now on you conf file, it is not an use for the ZED SDK)
