xdspacelab / openvslam

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

Openvslam + ROS + stereo #515

Open kevkid opened 3 years ago

kevkid commented 3 years ago

Is there a way for me to use openvslam for a sets of image pairs as if it were a stereo camera? For example if I have a left image and a right image, can I use these two images as a stereo image and run openvslam on it? Would I be able to do this with the ros wrapper?

dimaxano commented 3 years ago

Generally, yes, you can do SLAM on stereo images with openvslam (images should be prerectified and undistorted or you need intrinsic and extrinsic camera system parameters to do that). But it is currently not implemented in ROS wrapper, but you can do it yourself following this example

mirellameelo commented 3 years ago

Hi. The SLAM system uses a stereo pair of images to estimate depth, and then, map. To estimate it, a triangulation step is necessary, which requires the images to be rectified. So, are your cameras horizontally aligned with each other? Are the baseline (the distance between the lens) constant? Is the resolution the same for both images? Do they have the same opening angle? If it not, then you have to "prepare" your images before use them as input to Openvslam system.

kevkid commented 3 years ago

Hi. The SLAM system uses a stereo pair of images to estimate depth, and then, map. To estimate it, a triangulation step is necessary, which requires the images to be rectified. So, are your cameras horizontally aligned with each other? Are the baseline (the distance between the lens) constant? Is the resolution the same for both images? Do they have the same opening angle? If it not, then you have to "prepare" your images before use them as input to Openvslam system.

All excellent questions. I will be taking the necessary steps to preprocess them. But it looks like the ros wrapper does not have stereo implemented :(

kevkid commented 3 years ago

Generally, yes, you can do SLAM on stereo images with openvslam (images should be prerectified and undistorted or you need intrinsic and extrinsic camera system parameters to do that). But it is currently not implemented in ROS wrapper, but you can do it yourself following this example

Thank you, I will give this a try!

mirellameelo commented 3 years ago

@kevkid Basically what I had to do in order to use my stereo camera was to add a new condition for the stereo setup, such as: https://github.com/mirellameelo/rtabmap_openvslam/blob/7be49f95229691bc4e0d44057dd2da8d5276f231/ros/2/src/openvslam/src/run_slam.cc#L382

Subscribe not one, but the two images (I'm considering they are synchronized), such as: https://github.com/mirellameelo/rtabmap_openvslam/blob/7be49f95229691bc4e0d44057dd2da8d5276f231/ros/2/src/openvslam/src/run_slam.cc#L256

And call "feed_stereo_frame" instead of "feed_monocular_frame", such as: https://github.com/mirellameelo/rtabmap_openvslam/blob/7be49f95229691bc4e0d44057dd2da8d5276f231/ros/2/src/openvslam/src/run_slam.cc#L158

EDIT: the code above was used for another purpose, I used it in here as an example to suggest a flow, but I'd recommend you to extend these steps from the base code.