OpenCV exception during ZED X One stereo calibration

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:

* 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

Hi @carolina
Welcome to the Stereolabs community.

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

What model of ZED X One cameras are you using?

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.

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

and directly call WriteConfFile after stereoRectify.

for dbg only can you print the content of matQ?

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

[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";):

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

 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 (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?

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)