I don’t think there is a cv::distortPoints function for the normal camera models, but if you are using a fisheye model there appears to be a cv::fisheye::distortPoints() function. I haven’t used it, but maybe this is what you want?
For the regular camera models, a few ideas.
- You might be able to come up with a way to compute distortion parameters that encode the inverse distortion. If so you could then just call cv::undistortPoints() (on your undistorted points) with this inverse model and get what you want.
- You could try to use cv::projectPoints (which does 3D → 2D projection based on rvec, tvec, and camera matrix, and then applies the distortion model to get the distorted position) to compute the distortion for you. I think you would just have to use 0 vecs for rvec and tvec, and then assign a Z coordinate that is the same as your focal length.
- you could borrow the code from the projectPoints function that is related to applying the distortion:
r2 = x*x + y*y;
r4 = r2*r2;
r6 = r4*r2;
a1 = 2*x*y;
a2 = r2 + 2*x*x;
a3 = r2 + 2*y*y;
cdist = 1 + k[0]*r2 + k[1]*r4 + k[4]*r6;
icdist2 = 1./(1 + k[5]*r2 + k[6]*r4 + k[7]*r6);
xd0 = x*cdist*icdist2 + k[2]*a1 + k[3]*a2 + k[8]*r2+k[9]*r4;
yd0 = y*cdist*icdist2 + k[2]*a3 + k[3]*a1 + k[10]*r2+k[11]*r4;