Ask Your Question
0

What is solvePnP() exactly for? (while i already have the projection matrices P)

asked 2017-09-28 12:27:55 -0500

mirnyy gravatar image

updated 2017-09-28 12:46:41 -0500

I already know that solvePnP() finds the position (rotation and translation) of the camera using the 2d point coordinates and corresponding 3d point coordinates, but i don't really understand why i have to use it after i triangulated some 3d points with 2 cameras and their corresponding 2d points.

Because while triangulating a new 3D point, i already have (need) the projection matrices P1 and P2 of the two cameras (which contains of the R1, R2 and t1, t2 rotation and translations and is already the location of the cameras w.r.t. the new triangulating 3D point).

My workflow is:

  1. Get 2D-correspondences from 2 images.
  2. Get Essential Matrix E using these 2D-correspondences.
  3. Get relative orientation (R, t) of the 2 images from the Essential Matrix E.
  4. Set Projection Matrix P1 of camera1 to

    P1 = (1, 0, 0, 0,
          0, 1, 0, 0, 
          0, 0, 1, 0, 
          0, 0, 0, 0);
    

    and set Projection Matrix P2 of camera2 to

    P2 = (R.at<double>(0, 0), R.at<double>(0, 1), R.at<double>(0, 2), t.at<double>(0),
          R.at<double>(1, 0), R.at<double>(1, 1), R.at<double>(1, 2), t.at<double>(1),
          R.at<double>(2, 0), R.at<double>(2, 1), R.at<double>(2, 2), t.at<double>(2));
    
  5. Solve least squares problem

    P1 * X = x1   
    P2 * X = x2
    

    (solving for X = 3D Point). and so on.....

After that i get a triangulated 3D Point X from these Projection Matrices P1 and P2 and the x1 and x2 2D Point correspondences.

My question is now again:
Why i need to use now solvePnP() to get the camera location? Because I already have P1 and P2 which should be already the locations of the cameras (w.r.t. the triangulated 3D points).

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-09-28 18:02:00 -0500

Tetragramm gravatar image

You don't. You would use solvePnP to get the location of a camera relative to a set of points already known by some other method. For example, if your camera moved, then in the next frame, you would find the same points again, and use solvePnP to locate the camera's new position and orientation.

Or if you have a known set of points, you could use it to get the location of the camera without needing a second camera.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-09-28 12:27:55 -0500

Seen: 201 times

Last updated: Sep 28 '17