HomeForum Home → Software → Development → Thread


How to obtain Distortion Coeffs


Total Posts: 5

Joined 2017-04-14



While trying to calibrate the DUO MLX manually in OpenCV, the distortion coeffs D1 and D2 produce a 1X14 matrix and this resulted in a slightly distorted image even after the calibration.

Further on I tried to used the D1 and D2 valued obtained from the API documentation: https://duo3d.com/docs/articles/api but this gives me a 1X8 matrix. However, while trying to use the D1 and D2 values from the API, I get black images (probably corrupt images). I am guessing OpenCV is asking for a 1X14 matrix now.

Now I want to calibrate the camera using OpenCV with the factory default Intrinsic parameters. How do I do this?


My basic pipeline
1) get camera feed in IplImage format
2) convert the IplImage to Mat format
3) Apply my CameraMatrix M and DistortionCoeffs D to Undistort the images and eliminate Fisheye effect
Here is the problem:
Condition 1: I do manual camera calibration and obtain M and D to reduce the fish eye effect but I still don’t have a perfect image.
Condition 2: I obtain M and D values from the API, the M and D matrix sizes are correct but the image output I get is a corrupt black image so idk where the issue is. The API clearly says, the the M and D are OpenCV compatible.

Could the problem be that I am passing the undistorted parameters to a converted Mat file ? If so I am unable to find a way to perform the undistort function on the IplImg directly. I am getting a Seg fault error when using the cvUndistort2 function.


Essentially I just wanted to get the final undistorted images in my life feed, and to solve this;
I added “bool SetDUOUndistort(DUOInstance duo, bool val);” from the API into the Sample.h file provided in the OpenCV Samples folder.


Total Posts: 1

Joined 2018-02-28


EDIT: Forget what I said. Somehow my dumped coefficients must have been corrupted. Works fine now.

It would still be interesting in which order the distortion coefficients are stored in the DUO_STEREO structure. OpenCV assumes the order (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) [1]. Some coefficients are optional depending on whether a 4-, 5- or 8-parameter model is used.
However, if I try to use the first 5 or 8 values from the DUO_STEREO.D1 or .D2 array I’m not able to get any meaningful image. Is the order the DUO API uses different?

[1] https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html