From maps to camera matrix and distortion coefficients

Hi,

I’ve seen that it is possible to get the maps corresponding to given camera matrix and distortion coefficients (using the initUndistortRectifyMap function).

In my case, I know the map allowing to undistort an image but I don’t know the corresponding camera matrix and distortion coefficients. Is there a way to obtain them ?

Regards,
Romain.

1 Like

that’s a fun problem!

the map only takes care of un/distortion (lens distortion) and rectification (3D rotation, aspect ratio, shear, optical center, …). it is not aware of any depth.

I think it should be possible to extract the distortion, optical centers, rotation, skew, scale ratio… from the maps. I doubt if any focal length can be extracted from these maps.

Hi @crackwitz, thank you for your reply!

I think it would be ok for me to obtain all these parameters except the focal length.
I first thought of doing an optimization problem to get these parameters, but I’m not sure if it would be the best way of doing it. what do you think about it ? Would you have better ideas ?

Regards,
Romain.

I’m sure that at least some least squares stuff would be involved. I can’t predict what would be required.

you could generate a bunch of straight board views, or the points at least, and then map that through the inverted map, then send these points to calibrateCamera

I think that’s a roundabout approach though. there must be something that works with the map’s values directly.