Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It has to do with how you are creating the points. The projectPoints function doesn't remove the camera matrix and put it back like undistortPoints does, it just puts it back in. You have to normalize your points by the camera matrix manually.

Just replace dist::cameraMatrix and dist::distortion with your variables.

std::vector<Point3f> in;
std::vector<Point2f> out, out2;
std::cout << "[" << 512 << ", " << 200 << ", 1]\n\n";
in.push_back(Point3f((512-dist::cameraMatrix.at<double>(0,2))/dist::cameraMatrix.at<double>(0,0), (200 - dist::cameraMatrix.at<double>(1, 2))/ dist::cameraMatrix.at<double>(1,1), 1));

std::cout << in[0] << "\n\n";

projectPoints(in, Mat::zeros(3, 1, CV_64FC1), Mat::zeros(3, 1, CV_64FC1), dist::cameraMatrix,
    dist::distortion, out);

undistortPoints(out, out2, dist::cameraMatrix, dist::distortion, noArray(), dist::cameraMatrix);

std::cout << out[0] << "\n\n";

std::cout << out2[0] << "\n\n";