Search code examples
opencvcamera-calibrationremap

Default values for Remap or InitUndistortRectifyMap in OpenCV


I am implementing a somewhat generic approach to processing images with camera calibration.

I want to have a base routine that always calls remap. Thus, even when I do not have a calibrated camera, I want to call the same routine with default values that I can pass into remap.

Can someone guide me as to what default values to pass into InitUndistortRectifyMap that will result in no image modification when the output is passed into remap?

That would allow me to have a generic approach when either the camera is not calibrated or the saved calibration file is not found.

Thanks for any help.


Solution

  • Well, I have not tested it, but... From the documentation at the OpenCv site, you have the following equations:

    initUndistortRectifyMap

    So, if you set:

    fx = fy = f'x = f'y = 1 
    cx = cy = c'x  =c'y = 0
    

    That is, Camera matrices = 3x3 identity, and

    R = 3x3 identity
    

    And zero distortion:

    k1 = k2 = k3 = p1 = p2 = 0
    

    you should end up with

    mapx(u,v) = u
    mapy(u,v) = v
    

    That is, the original coordinates for each point of the map.