Ask Your Question

What is the easiest way for camera post estimation

asked 2014-11-03 06:25:30 -0500

neoww gravatar image

I have two images from slighly different viewpoints. For one image I know the camera position.

What is the easiest way with OpenCV to compute the camera position of the second image?

The result does not need to be that accurate. Basically I would like to compute the movement of a phone from the video frames.

edit retag flag offensive close merge delete



You shall detect some features (FAST or GFTT) in the 2 images and then you shall match them, and compute the mean direction of the whole object (phone). Now you have the vector of movement. Now you can compute the new position of the camera

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-11-03 07:00:21 -0500 )edit

Thanks - if this is the most straightforward approach then I'll try it. But when I first looked on OpenCV I think I saw a function that computes the camera position from the images directly without feature detection - and thus might be easier to use. Unfortunately I do not find it anymore. It was something with image pyramids and it reached 12 Hz on the developers machine.

neoww gravatar imageneoww ( 2014-11-03 09:25:52 -0500 )edit

OK, found it - I saw rgbdodometry. It seems to do everything in a single call. Unfortunately it requires depth information from a Kinect sensor.

neoww gravatar imageneoww ( 2014-11-03 11:13:11 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-11-03 18:18:36 -0500

D-Alex gravatar image

If you only have a mono camera you have to use some sort of Structure from Motion. Unfortunately, OpenCV provides you only with some building blocks but not with a complete solution for this problem and I would argue that this problem is sill not solved for all cases. By the way Goolge is trying to do similar things (Goolge Tango).

For two images you can try to do the following:

  • Use Feature Detector + Matcher
  • Calculate Essential Matrix with findEssentialMat (assuming you have a calibrated camera)
  • Recover the pose with decomposeEssentialMat
  • You can find the right rotation by testing all points

For image sequences it is getting a lot more complex (have a look at libmv there was also a project trying to make libmv compatible to opencv libmv2)

  • find frames with enough parallax
  • store matches (for example bipartite graph)
  • track features over multiple images
  • use P3P algorithm and five point algorithm to recover poses (have a look at Visual Odometry by Nister, D.)
  • use bundle adjustment for refinement (ceres solver)
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-11-03 06:25:30 -0500

Seen: 510 times

Last updated: Nov 04 '14