Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Trying to re-distort image points using projectPoints

Knowing things about a video-feed from a GoPro camera, I would like to draw on top of the image, which in terms requires me to go from undistorted to distorted image points.

I've tried to use projectPoints, since the documentation states this should suffice, but the results doesn't look correct to me. The following is what I'm trying:

Vec<float,8> d = Vec<float,8>(k1, k2, p1, p2, k3, k4, k5, k6);
            [1740    0 1919.5]
intrinsic = [   0 1745 1079.5]  (3x3 float matrix)
            [   0    0    1  ]

My function takes an undistorted image-point, undistorted, converts into a 1x3 matrix, and i expect an 1x2 matrix containing the distorted point in return.

Mat dmat = Mat_<float>(1,3);
Mat umat = (Mat_<float>(1,3) << undistorted.x, undistorted.y, 1.0);
projectPoints(umat, Vec3f(0,0,0), Vec3f(0,0,0), intr, d, dmat);

A sample input might be Point2f(1920,315), returning [-6.15e+6, -1.86e+6] while manually calculating the distorted point gives me [1919.93, 257.136] which seems more likely.

I am suspecting projectPoints not to play well with my intrinsic matrix, should it (and image points) be normalized first?

Any hints on what might be wrong?