-
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
Replay of bag file taking a long time #9585
Comments
Hi @naoya-kumagai When playing back a bag file, you will get more stable performance if you set set_real_time to False by adding two lines under your pipe start line. It should look something like this in your particular script: prof = p.start(conf) |
Hi, MartyG-RealSense Thank you for the response. I've added the two lines to my code, and it actually takes a longer time for the code (67 seconds, bag file is 47 seconds). I am trying to implement a real-time vision system so doing things without lag is crucial to this task. If you could tell me how to simulate this in a bag file and how to do this using a camera stream, this would be great! |
The set_real_time function and the effects of using true or false are described in the function's pyrealsense2 documentation entry in the link below. An example of what I mean by stability of bag playback is that when seeking to navigate to a specific frame number of the bag, there is a greater chance of missing the target when set_real_time is True. I note that you are streaming depth, color and IMU frames at the same time. It is a known issue that there can be performance problems when doing so with these three stream types simultaneously. The IMU stream is the cause of it. A solution for this is to set up two separate pipelines, with depth & color on one pipeline and IMU on its own on the other pipeline. A Python script that demonstrates this two pipeline approach is linked below. |
Thank you for the links, I have separated my pipelines. However, the problem addressed in this issue is still not resolved. |
Are the stream configurations that you defined in your conf statements (848x480 depth at 30 FPS and 1280x720 color at 30 FPS) the same stream resolutions and FPS speeds that the data in the bag was recorded at? If not, it is recommended to edit your conf statements to match the recorded data in the bag. You could also similarly match the gyro and accel configuration to the IMU streams recorded in the bag by using an expanded conf instruction that takes account of format and frequency. For example: conf.enable_stream(rs.stream.accel, rs.format.motion_xyz32f, 63) Edit the accel and gyro frequencies to whichever ones the recorded IMU streams use. It may be worth drag-and-dropping your bag file into the center panel of the RealSense Viewer program to play the bag back in the Viewer and see how long it takes to play from start to finish. This will provide indication of whether or not the delay is being caused by something in your script. |
Hi @naoya-kumagai Do you require further assistance with this case, please? Thanks! |
Sorry, yes! |
Dies it make any difference if you move your stream data retrieval statements to the position directly after the wait_for_frames() instruction? while True: except: There was also a past Python case in #8481 that had problems with the IMU streams when using frames.first_or_default to access the data. A successful solution was to access them with as_motion_frame().get_motion_data(), like in the script in the link below. |
Thank you @MartyG-RealSense |
Thanks very much @naoya-kumagai for the update. As you suggest, I will close the case. Thanks again! |
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
Issue Description
<Describe your issue / question / feature request / etc..>
I am replaying a bag file and processing data from it. When I run the following code, running the code takes much longer than the length of the bag file. (Code: 58 seconds, bag file: 47 seconds)
How do I get the data from the bag file "in real time"?
'''
def initialize_camera():
# start the frames pipe
p = rs.pipeline()
conf = rs.config()
rs.config.enable_device_from_file(conf, bag_dir,repeat_playback=False)
conf.enable_stream(rs.stream.accel)
conf.enable_stream(rs.stream.gyro)
conf.enable_stream(rs.stream.depth, 848, 480, rs.format.z16, 30)
conf.enable_stream(rs.stream.color, 1280, 720, rs.format.rgb8, 30)
prof = p.start(conf)
return p
p = initialize_camera()
time_start = time.time()
while True:
print(time.time()-time_start)
try:
frames = p.wait_for_frames()
except:
print('no more frames...')
break
print(frames.get_frame_number())
accel_frame = frames.first_or_default(rs.stream.accel)
gyro_frame = frames.first_or_default(rs.stream.gyro)
depth = frames.get_depth_frame()
color = frames.get_color_frame()
'''
The text was updated successfully, but these errors were encountered: