Ask Your Question

camera rotation and translation based on two images

asked 2015-08-06 05:40:19 -0500

Alice gravatar image


I'm just starting my little project in OpenCV and I need your help :) I would like to calculate rotation and translation values of the camera basing on two views of the same planar, square object.

I have already found functions such as: getPerspectiveTransform, decomposeEssentialMat, decomposeHomographyMat. Plenty of tools, but I'm not sure which of them to use in my case.

I have a square object of known real-world dimensions [meters]. After simple image processing I can extract pixel values of the vertices and the center of the square.

Now I would like to calculate the relative rotation and translation of the camera which led to obtain the second of two images:
"Reference view" and "View #n"
(please see below).

Any suggestions will be appreciated :)

  1. Reference view:
    image description
    (center of the object is on the optical axis of camera, the camera-object distance is known)
  2. View #1:
    image description
  3. View #2:
    image description
  4. View #3:
    image description
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-08-06 06:24:16 -0500

You can use cv::solvePNP to get the pose of the marker in your camera frame. (Although a symetrical marker is a bad choice for this kind of task).

edit flag offensive delete link more


Thank you for your answer FooBar. I see that cv::solvePNP needs input camera matrix and input vector of distortion coefficients. How can I get these parameters?
I found cv::calibrateCamera() which apears to output what is needed. I will try to use this function.
That's exactly what I was looking for :)

Alice gravatar imageAlice ( 2015-08-06 08:04:25 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-08-06 05:40:19 -0500

Seen: 440 times

Last updated: Aug 06 '15