nihalsoans91 / Bag_to_Depth

Python code to extract depth and rgb data from rosbag
MIT License
14 stars 5 forks source link
bag bag-files bag-folder2 depth depth-images1 python python3 rgb rgb-images1 ros ros-kinetic

Bag to Depth and RGB

This code is usefull for grabbing RGB and depth data from BAG file of ros in python and C++

The Python Code saves in both jpg and numpy pickle. Where as the C++ Code saves only in jpg

What is needed

How to execute ?

Pre-Run requirements

Python Code

cd src/bag2rgbdepth/scripts/

Arange the bag files in diffrent folders for each bag file as below

step 2: Open another terminal and run sh truedepthandrgb.sh

step 3: Wait

What after it executes

The folder strcture now will be

C++

First you will need to build the code

Pre-Reqs

Open launch file in launch folder

vim Bag_to_Depth/src/bag2rgbdepth/launch/extractbag_to_rgbd.launch

Edit the line where it says

<param name="folder_extract_location" value="./"/>

Change the value to the folder where you need to extract the images. The code will add the rgb and depth files.

Excute the below bash script

cd Bag_to_Depth/
catkin_make
source devel/setup.bash
roslaunch bag2rgbdepth extractbag_to_rgbd.launch

Meanwhile in another terminal run these two commands

roscore &
rosbag play bagfile1.bag

What after it executes

The folder strcture now will be