sridhar reddy
sridhar reddy

Reputation: 15

Is there any opencv function to calculate reprojected points?

What is the procedure to calculate reprojected points, reprojected errors and mean reprojection error from the given world points (Original coordinates), intrinsic matrix, rotation matrices and translation vector?

Is there any inbuilt opencv function for that or we should calculate manuallay?

If we have to calculate manually, what is the best way to get reprojected points?

Upvotes: 0

Views: 4223

Answers (2)

el psy Congroo
el psy Congroo

Reputation: 361

calibrateCamera() from openCV based on Zhang's calibration paper is what you need https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr98-71.pdf

I cannot explain the math here to keep this answer short.

Here's the short summary of the procedure:

  1. Get multiple views of the same reference object, e.g. a checkerboard
  2. Feed in the objectPoints, imagePoints, and other parameters, you will get the distortion coefficient, 3x3 camera intrinsic matrix, rotation vectors, and translation vector.
  3. With the intrinsic camera matrix calibrated, you would be able to calculate the reprojected points using the function cv.projectPoints which projects the 3D points to the 2D imaging plane

You will need opencv for this, but for simplicity, you can use Python version of opencv to do the same thing at the expense of performance

https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga687a1ab946686f0d85ae0363b5af1d7b

Good Luck!

Upvotes: 0

Alessandro Jacopson
Alessandro Jacopson

Reputation: 18705

projectPoints projects 3D points to an image plane.

calibrateCamera returns the final re-projection error. calibrateCamera finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on [Zhang2000]1 and [BouguetMCT]2. The coordinates of 3D object points and their corresponding 2D projections in each view must be specified. That may be achieved by using an object with a known geometry and easily detectable feature points. Such an object is called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as a calibration rig (see findChessboardCorners() ).

The algorithm performs the following steps:

  1. Compute the initial intrinsic parameters (the option only available for planar calibration patterns) or read them from the input parameters. The distortion coefficients are all set to zeros initially unless some of CV_CALIB_FIX_K? are specified.

  2. Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using solvePnP().

  3. Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points imagePoints and the projected (using the current estimates for camera parameters and the poses) object points objectPoints. See projectPoints() for details. The function returns the final re-projection error.

1ZHANG, Zhengyou. A flexible new technique for camera calibration. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 2000, 22.11: 1330-1334.

2J.Y.Bouguet. MATLAB calibration tool. http://www.vision.caltech.edu/bouguetj/calib_doc/

Upvotes: 0

Related Questions