Skip to content
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

Unable to load all recorded frames from a Bag file-D435i #6565

Closed
Wjordan2020 opened this issue Jun 10, 2020 · 12 comments
Closed

Unable to load all recorded frames from a Bag file-D435i #6565

Wjordan2020 opened this issue Jun 10, 2020 · 12 comments

Comments

@Wjordan2020
Copy link

HI
i am new to this field. I used my d435i to record a bag file for a project. I am trying to process this bag file using python 2.7. However, the code crashes before loading all the frames. I used the SDK viewer to play the bag file and it works fine without any errors.
I am using 848X100 with 300 fps as i am trying to capture a fast moving object. Recording duration is 50 secs which makes is around 15000 frames in total. The code crashes when it loads around 6000 frames. When the code crashes, i get the below error. I tried increasing the wait time to 10000 but still received the same error.
RuntimeError: Frame didn't arrive within 5000
I searched online but i could not find a solution for this issue.
Camera: D435i
firmware: 05.12.05
Windows 10/PC
SDK V2.33.1
Python 2.7

Here is the code i am using to read the bag file:

import cv2
import numpy as np
import pyrealsense2 as rs
import pandas as pd
print("Environment Ready")

pipe = rs.pipeline()
cfg = rs.config()
cfg.enable_device_from_file("test2.bag",repeat_playback=False)
profile = pipe.start(cfg)

for x in range(5):
pipe.wait_for_frames()

i=0
try:

while True:
    frameset = pipe.wait_for_frames(30000)
    print("frame# "+str(i))
    i +=1

print("Frames Captured")

finally:
# Stop streaming
pipe.stop()

Thanks

@MartyG-RealSense
Copy link
Collaborator

Another pyrealsense2 user experienced the RuntimeError: Frame didn't arrive within 5000 error when trying to read a bag. They were advised to set up a profile and define a playback time.

https://stackoverflow.com/questions/58482414/frame-didnt-arrived-within-5000-while-reading-bag-file-pyrealsense2

@Wjordan2020
Copy link
Author

Thanks. I tried this code from your answer. However, it is running extremely slow. The code generated 66 frames only in 5 minutes and still running. is there a simple way to find the total number of captured frames in a bag file?

@MartyG-RealSense
Copy link
Collaborator

The most common method that I have seen RealSense users apply to determine the number of captured frames is to extract the frames into other formats such as PNG or a CSV text-based file.

This can be done outside of Python using an SDK tool called rs-convert:

https://github.com/IntelRealSense/librealsense/tree/master/tools/convert

There is a pre-built Windows version called rs-convert.exe at this SDK folder location:

C: > Program Files (x86) > Intel RealSense SDK 2.0 > Tools

image

There is also a simpler bag-reading script for pyrealsense2 here:

#1887 (comment)

@Wjordan2020
Copy link
Author

Thank you for your answer. I tried the rs-convert.exe and it skips many frames (Python could retrieve more frames!!). I spent so much time searching online for a valid way to retrieve all the frames from a bag file without any useful solution. My application is based on analyzing depth at every single frame. The capability of D435 of producing high fps was the main reason to consider it in my project. is there any valid way to retrieve all frames from a bag file?

@MartyG-RealSense
Copy link
Collaborator

There is a Python discussion with a couple of comment links that may be useful. The first is a bag extraction script, and the second has a suggestion for how to read a bag without losing frames.

#1887 (comment)

#1887 (comment)

@vams08
Copy link

vams08 commented Jun 12, 2020

Hey, I am using the rs-convert tool and the generated .csv files it contains 1280 cols,720 rows where can I know which columns corresponds to accelerometer data, gyroscope data

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jun 12, 2020

@vams08 csv is a depth matrix format that stores a text representation of a depth image. I'm not aware of IMU information being stored in it

The link below has an example of a csv that roughly illustrates the characteristics of the original depth image.

#3632 (comment)

@vams08
Copy link

vams08 commented Jun 13, 2020

@MartyG-RealSense is there any way to get IMU data from pre-recorded files(.bag format)

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jun 13, 2020

@vams08 There is not much information on the subject, and what there is refers to the Python language. If you only want the IMU data from the bag then it may be straightforward. If you want to extract both IMU and depth at the same time then it may be more complicated.

The links below offer Python scripting:

#3969

#4018

@MartyG-RealSense
Copy link
Collaborator

Hi @vams08 Do you still require assistance with this case please, or can it be closed? Thanks!

@vams08
Copy link

vams08 commented Jun 25, 2020

@MartyG-RealSense yeah it can be closed thanks for support.

@MartyG-RealSense
Copy link
Collaborator

@vams08 Thanks so much for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants