# Difference between undistortPoints() and projectPoints() in OpenCV

From my understanding, undistortPoints() takes a set of points on a distorted image, and calculates where their coordinates would be on an undistorted version of the same image. projectPoints() maps a set of object coordinates to their corresponding image coordinates.

However, I am unsure if projectPoints() maps the object coordinates to a set of image points on the distorted image (ie. the original image) or one that has been undistorted (straight lines)?

Furthermore, the OpenCV documentation for undistortPoints states that 'the function performs a reverse transformation to projectPoints()'. Could you please explain how this is so?

edit retag close merge delete

Sort by » oldest newest most voted

undistortPoints is a special case of the reverse projectPoints function.

So, if you pass undistortPoints with no P parameter, then projectPoints with rvec=tvec=(0,0,0) and the camera matrix will return them to the original location. If you do give undistortPoints a P parameter, then using the identity matrix will return them to the original location. Note that for both of these you must convert the 2d points to 3d before passing to projectPoints.

projectPoints has several other uses. If you have true 3d points, you can place them onto an image (either distorted or undistorted). Pass in the camera rvec and tvec, as well as the camera matrix. To place them onto a distorted image, also pass the camera distortion matrix. To place them on an undistorted image, pass noArray or zeros.

NOTE: I don't think project points checks direction, so if you have points in front of and behind the camera, you will get answers for both on the plane of the image. I think, I'm not in a place to test right now.

The Jacobian is useful for many things, but if you don't need it, don't worry about it. If you do need it, you ought to already know what it is and what it means.

more

Thank you! This was really helpful

( 2017-02-21 20:30:28 -0500 )edit

Official site

GitHub

Wiki

Documentation