-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Starting from issue #1919, I worked on it a little bit and I made a class that reads bag files using directly the rosbag API. It implements the following functionalities
-
Reads a bag file and outputs a pair of rgb and depth frames asynchronously whenever the function nextFrame is called. The class does not use the realsense pipeline, rather it parses the rosbag messages, so there are no frames dropped
-
Since AFAIK there is no hardware synchronization between rgb and depth streams on the device, the class checks the timestamps and outputs the pair of rgb and depth files that are closest in time (without expensive searches).
-
The depth frame returned is aligned to the camera point of view
-
Depth frame is saved as an xml with the full floating point values in meters for each pixel
-
Together with the frames, the class outputs the frame number and the timestamp for each frame recorded in the rosbag (according to the system clock)
-
It also saves the intrinsic and extrinsic matrices for both sensors in case you want to do some geometry
The code should be quite readable, and the dependencies are opencv 3.x, glog, librealsense, and the part of the ros library included as headers, and boost. The files print_helpers.cpp/h are a modified version of the ones included in the rosbag viewer tool example.
Even if you don't use the class directly, you should be able to copy and paste the methods inside the class to read the rosbag however you want.
Hope it helps
RealSenseHelper.zip