Ask Your Question
0

Undistort image before estimating pose using solvePnP

asked 2016-07-18 16:22:00 -0600

Alek.B gravatar image

I have to estimate the pose of the camera using a known marker. The camera is calibrated and I have all the calibration coefficients.

The current version of the algorithm extracts 4 co-planar points from the frame and uses them to estimate the pose using the solvePnP function.

The algorithms seems to work fine but I have a doubt. Since the solvePnP takes as input also the calibration coefficients, do I need to undistort the image before looking the 4 points?

In the following code, are the initUndistortRectifyMap/remap functions necessary?

while(1) {

    frame = camera->getFrame();

    imshow("frame", frame);

    // Estimation of Map1 and Map2 for image rectification (to be done only on the first iteration)
    if (initRectifyMap_flag)
    {
        // Rectify the image
        // The initialization of the Rectification Parameters will be carried out only at the first frame.
        initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(), getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, frame.size(), 1, frame.size(), 0), frame.size(), CV_16SC2, map1, map2);
        initRectifyMap_flag = false;
    }

    // Remapping of the current frame
    remap(frame, src, map1, map2, INTER_LINEAR, BORDER_TRANSPARENT, Scalar::all(255));

    // Here is the code for the extraction of the 4 points based on the content of the variable src
    ...
    ...

    // Pose estimation
    solvePnP(Mat(refMarkerPoint), Mat(markerPoints), cameraMatrix, distCoeffs, rvec, tvec,false);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-18 17:46:15 -0600

Since the solvePnP takes as input also the calibration coefficients, do I need to undistort the image before looking the 4 points?

If you extract your feature points from the unrectified image, you have to pass the distortion coefficients. Otherwise (features from rectified image) you can just pass an empty matrix for the coefficients [this should be your case]

edit flag offensive delete link more

Comments

Thanks. I got it.

Alek.B gravatar imageAlek.B ( 2016-07-18 17:48:33 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-18 16:22:00 -0600

Seen: 1,647 times

Last updated: Jul 18 '16