Convert OpenCV calibration (.xml) to ZED calibration (.conf)

I need to use the result of OpenCV calibration with the ZED sdk, and for that I need to convert the resulting .xml file from the OpenCV calibration to a .conf file (ZED calibration format).

The .conf file is divided in 3 sections: [LEFT_CAM_HD], [RIGHT_CAM_HD] and [STEREO].

The LEFT_CAM_HD and RIGHT_CAM_HD sections contains the intrinsic parameters of the cameras fx, fy, cx, cy, k1, k2, k3, p1, p2. These parameters I was able to get from the Intrinsics and Distortion group of the xml file of the OpenCV calibration for each camera.

However, I’m not sure how to get the parameters from the STEREO section, that contains the extrinsic parameters.

In a ZED .conf file, the [STEREO] block is something like this:


But the extrinsics result of the OpenCV calibration is a 3x4 matrix [R | T] like that:

<CameraMatrix type_id="opencv-matrix">
    9.9997883153235922e-01 7.3748315035248343e-04 -6.4647200852331324e-03 -1.1915658468526300e-01
    -7.9486280185082892e-04 9.9996027615040162e-01 -8.8777426375674651e-03 -1.8262554804596392e-03
    6.4579160960564009e-03 8.8826932748798451e-03 9.9993969472157707e-01 -2.9897274913539143e-03

I’m not sure how to use this matrix to get the Baseline, TX, TY, TZ, RX_HD, CV_HD and RZ_HD to build my ZED .conf file. I would appreciate some help.

you did a single camera calibration ? it won’t have values for a stereo baseline

also, the extrinsic Mat’s you get from there are from a single cam to the board, not from one stereo cam to the other

last: opencv’s distortion coeffs are: k1,k2,p1,p2,k3 (note the weird order !)

I actually executed the Open Pose calibration. I run the calibration to get the intrinsics for the right lens, and for the left lens. Then, I execute the extrinsic calibration with both lenses, and it returned the CameraMatrix from above.
I’m aware of the order of the distortion coeffs, thanks!

Baseline is “TX”

looks similar, doesn’t it? it’s the same value, in meters and millimeters.

as for the rotation part: What is the calibration file? – Help Center | Stereolabs

only unknown is in which order the rotations need to be composed.

Yes, I suppose the TX, TY, and TZ are straightforward, and the baseline being TX, but I’m not sure about the rotation coefficients…

since they’re almost 0, see if you can live with them being 0, i.e. the R part being an identity matrix.

if you need to figure that out, I’d suggest bending the stereo camera (or putting a prism in front of one camera, something to change the extrinsics) and observing how the values change.

here’s some more discussion on the rotation axes: Camera Calibration Parameters and Rectification · Issue #39 · stereolabs/zed-ros-wrapper · GitHub

oh, and I doubt these people are right about cv::Rodrigues([Rx, Ry, Rz] /*in*/, RotMatrix3x3 /*out*/) because the docs state that each is a rotation (in radians, presumably) around each given axis. they are not components of one rodrigues vector.

I think it’s one of those (matrix multiplications, not element-wise!), and which can be determined from “experiment”:

  1. Rotational matrix = Rodrigues([Rx, 0, 0]))*Rodrigues([0, Ry, 0]))*Rodrigues([0, 0, Rz]))
  2. Rotational matrix = Rodrigues([0, 0, Rz]))*Rodrigues([0, Ry, 0]))*Rodrigues([Rx, 0, 0]))

I will check that, thank you.

what is this ? please explain

I used the calibration module from OpenPose library (GitHub - CMU-Perceptual-Computing-Lab/openpose: OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation)

Calibration module: openpose/ at master · CMU-Perceptual-Computing-Lab/openpose · GitHub