OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Thu, 28 Sep 2017 12:27:55 -0500What is solvePnP() exactly for? (while i already have the projection matrices P)http://answers.opencv.org/question/175301/what-is-solvepnp-exactly-for-while-i-already-have-the-projection-matrices-p/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).***mirnyyThu, 28 Sep 2017 12:27:55 -0500http://answers.opencv.org/question/175301/