xdspacelab / openvslam

OpenVSLAM: A Versatile Visual SLAM Framework
https://openvslam.readthedocs.io/
2.97k stars 869 forks source link

Retrieve Camera Postion #307

Open Zumbalamambo opened 4 years ago

Zumbalamambo commented 4 years ago

I'm not able to retrieve the camera position. How do I retrieve the camera position in run_video_localization ?

Shashika007 commented 4 years ago

@Zumbalamambo use this to get the position. Then you can convert it to an odom message.

auto camera_pose = mappublisher->get_current_cam_pose().inverse().eval();

Zumbalamambo commented 4 years ago

It gives me the following matrix,


  0.923833  -0.115088  -0.365086  -0.143865
-0.0427792    -0.9788   0.200302  0.0126258
  0.380399   0.169427   0.909171   -0.10293
        -0          0         -0         -1
  1. How do I interpret them? Where is the rotation matrix, xyz param, orientation of the camera?

if my understanding is right, [-0.143865 0.0126258 -0.10293] are the xyz positions and the rotation matrix is represented as,

> 0.923833 -0.115088  -0.365086 
> -0.0427792   -0.9788 0.200302
> 0.380399  0.169427  0.909171 
  1. Is this matrix relative to the world? or do I have to calculate the world matrix again with these values?
dimaxano commented 4 years ago
  1. Yes, you are right
  2. This is position of your camera on your map. I think, it is possible to say that these are world coordinates
chyohoo commented 4 years ago

rot_cw_ = cam_pose_cw_.block<3, 3>(0, 0); rot_wc_ = rot_cw_.transpose(); trans_cw_ = cam_pose_cw_.block<3, 1>(0, 3); cam_center_ = -rot_cw_.transpose() * trans_cw_;

Zumbalamambo commented 4 years ago

@dimaxano @chyohoo is cam_center the origin?

AndrewSerbin commented 4 years ago

Hi guys, @dimaxano @chyohoo . Do you know how to get camera position, rotation matrix, xyz param, orientation of the camera from the saved map (map.msg)? There are rot_cw and trans cw arrays but how to use them? "trans_cw": [ 0.001168138611814195, 0.001744156806106644, -0.04382340588891053 ], "rot_cw": [ -0.013637094956248765, 0.00030411659091322845, -0.001853422243378439, 0.9999052465010078 ],

dimaxano commented 4 years ago

Hi, @AndrewSerbin! Use code @chyohoo posted above: you alredy have rot_cw_ and trans_cw_ variables. After running the code, rot_wc_ will contain your camera orientation and cam_center_ will contain your camera position

Zumbalamambo commented 4 years ago

@dimaxano how can I use this camera pose information, when the map has got scale drift?..let's say for indoor navigation