Items with no label
3335 Discussions

Get the number of frames saved in a rosbag

FChau1
Beginner
4,557 Views

Hello,

I'm working on a Python program having a saved Rosbag as an input.

I would like to know if there is a simple way to get the number of frames present on the Rosbag and then to be able to be sure to treat every frame.

To go from one frame to the next one, what is the most simple solution ? using a pause command ?

thanks

0 Kudos
7 Replies
idata
Employee
2,048 Views

Hello 3DScanProduction,

 

 

Thank you for your interest in the Intel RealSense Cameras.

 

 

I would recommend you check this example:

 

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/read_bag_example.py

 

 

Please let me know if it was helpful or if I can assist you with anything else!

 

 

Thank you,

 

Eliza
0 Kudos
FChau1
Beginner
2,048 Views

Thank you...

I know this piece of code but it does not answer the question in anyway.

What I would like to know is:

- is it possible to get the number of frames recorded using the command to record a rosbag file with the command we have in sdk2

- is it possible to pause the stream and play one frame after each other to be sure that you treat every frame presents in the stream recorded.

0 Kudos
idata
Employee
2,048 Views

Hello 3DScanProduction,

We are not experts on ROS but we will help you as much as we can. The tool librealsense\tools\rs-rosbag-inspector.cpp shows how to extract all the data you need from a ROS bag. It uses a third-party library called rosbag_storage (http://wiki.ros.org/rosbag_storage http://wiki.ros.org/rosbag_storage).

Regarding your second question, in read_bag_example.py, the "while True" loop beginning on line 52, loops through each frame 1 by 1. You can do whatever treatment you want on each frame within this loop.

 

 

Regards,

 

Eliza

 

0 Kudos
idata
Employee
2,048 Views

Hello 3DScanProduction,

 

 

Could you please let me know if there is anything else I might assist you with?

 

 

Thank you,

 

Eliza
0 Kudos
FChau1
Beginner
2,048 Views

" in read_bag_example.py, the "while True" loop beginning on line 52, loops through each frame 1 by 1. You can do whatever treatment you want on each frame within this loop."

The problem is that if the treatment is complex and requires time, because you are just treating the stream, you will loose frames.

The good solution would be to go from frame to frame, being able to pause the stream.

0 Kudos
idata
Employee
2,048 Views

Hello 3DScanProduction,

 

 

This page has information that will help you decide the best way to manage frame buffering:

 

https://github.com/IntelRealSense/librealsense/wiki/Frame-Buffering-Management-in-RealSense-SDK-2.0

 

 

Please let me know if this helps you.

 

 

Thank you,

 

Eliza

 

0 Kudos
idata
Employee
2,048 Views

Hello 3DScanProduction,

 

 

You might also want to check the below link: https://github.com/IntelRealSense/librealsense/blob/master/src/media/readme.md# using-rs2config-with-rs2pipeline https://github.com/IntelRealSense/librealsense/blob/master/src/media/readme.md# using-rs2config-with-rs2pipeline and look at section "Playing from file"

 

 

Please let me know if I can assist you with anything else!

 

 

Thank you,

 

Eliza
0 Kudos
Reply