-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number of frames in a .bag file, and timestamp of each frame #10317
Comments
Hi @hedeya1980 A C++ script at the link below for counting the number of frames in a bag file may be a helpful reference. https://support.intelrealsense.com/hc/en-us/community/posts/360031847974/comments/360007849114 You could also check the frame count with the RealSense SDK's C++ tool called rosbag-inspector. https://github.com/IntelRealSense/librealsense/tree/master/tools/rosbag-inspector In a past case, one of the RealSense support team members suggested the following method for checking frame count with rosbag-inspector: "Open the target bag file, and look at the topics /device_0/sensor_0/depth_0/image/data or /device_0/sensor_1/color_0/image/data and look at the count". In regard to retrieving timestamps, yes, frames.get_timestamp() is the appropriate method to use. #2188 is an excellent reference about different types of timestamp and how they work. System Time is the camera's software timestamp, and is used when hardware timestamps are unavailable (such as when support for hardware metadata has not been enabled in the RealSense SDK). . If hardware timestamps are available, librealsense will take advantage of them. On Windows, metadata support can be added using information in the link below, or more easily by instead using a pop-up box in the RealSense Viewer that may appear when launching it to request if you want to enable metadata support. When global time is enabled, device time and system time are synchronized. |
Thanks a lot @MartyG-RealSense for the detailed and valuable answer. I managed to get the number of frames from using the code snippet you referred to. I'm reading the wonderful resources you referenced, and will get back to you if I still need any clarifications. Thanks a lot. |
You are very welcome, @hedeya1980 - I'm pleased that I could help. Please do feel free to post follow-up questions if you have them. Good luck! |
Hi @MartyG-RealSense, when I compare the frame count obtained using the code snippet, it's different compared to what I obtained from rosbag-inspector. I doubt that it's because of the FPS. In the code snippet, the duration is always multiplied by 30. Is there a C++ method for obtaining the FPS? The differences are sometimes big (rosbag-inspector frame count is sometimes less than half of the count from the C++ code). Also, what is the difference between Hardware FPS, and viewer FPS that's in the sensor metadata, as in the following screenshot? |
An example of C++ scripting for printing FPS is provided by a RealSense user at #7749 In that same case, information about the difference between Hardware FPS and Viewer FPS can be found at #7749 (comment) |
Hi @hedeya1980 Do you require further assistance with this case, please? Thanks! |
Hi @MartyG-RealSense , |
At #7488 (comment) a RealSense team member provides a link to the official C++ code in the RealSense SDK that is responsible for calculating FPS. It may provide some useful insights for your own approach. At #8417 a RealSense user shares their own C++ method for calculating FPS. If you are calculating the difference between the current frame and last frame, conceivably '0' could occur each time that the current frame is the last frame. If bag playback does not have repeat disabled then playback could loop back to the beginning and print '0' as the time difference each time that the last frame is reached. |
Hi @hedeya1980 Do you require further assistance with this case, please? Thanks! |
Hi @MartyG-RealSense , which means that sometimes the time between successive frames can be zero. Could you pls advise if I'm missing anything? |
When you earlier said that you are calculating the difference between the "current frame and last frame", did you mean the previous frame, and not the final frame of the bag file, please? If you were referring to the previous frame, then '0' might be an event where there was a bad frame. In that event, the SDK would recover by returning to the last known good frame and then continue the streaming onwards from there. So perhaps the time is 0 because the same frame number is repeating as the SDK recovers from the 'hiccup' in the streaming. For example, frame 1, 2, 3, 3, 4, 5, 6, 6, 7 |
Hi @hedeya1980 Do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
Hi @MartyG-RealSense, |
No problem at all, @hedeya1980 - I'm pleased that I could help. Thanks for the update! |
Issue Description
I'm processing the .bag files saved from the D455 depth camera. I need a method to get the number of frames in the .bag file. I searched a lot, but couldn't find how to get the number of frames.
Also, I need to get the timestamp of each frame. I'm using the '.get_timestamp()', but I don't know whether it's the correct method or not. Also, sometimes the '.get_frame_timestamp_domain()' results in 'Global time', and sometimes it's 'System time', what is the difference?
Thanks in advance.
The text was updated successfully, but these errors were encountered: