I'm trying to read the frames in the .bag
files with pyrealsense2
. I followed the read_bag_example by Intel. Here's the full sample that the code that I'm using.
import numpy as np
import pyrealsense2 as rs
import os
import time
import cv2
i = 0
try:
config = rs.config()
rs.config.enable_device_from_file(config, "D:/TEST/test_4.bag", repeat_playback=False)
pipeline = rs.pipeline()
pipeline.start(config)
while True:
frames = pipeline.wait_for_frames()
depth_frame = frames.get_depth_frame()
if not depth_frame:
continue
depth_image = np.asanyarray(depth_frame.get_data())
color_image = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
cv2.imwrite("D:/TEST/image/" + str(i) + ".png", color_image)
i += 1
finally:
pass
The code is working. However I checked the number of frames via realsense-viewer
and its output is 890 frames. However, the output of this code always changes in the range of 500-770 and raise the error:
RuntimeError: Frame didn't arrived within 5000
I searched lots of hours but I was not able to find a solution that would resolve my problem.
I'm also using
- Intel Firmware version - 5.11.15.0
- Python - 3.6.8
- pyrealsense2 - 2.24.0.965
- D435 with 848x480, 90 FPS images
I could add more information if you need. Any help or other suggestions would greatly appriciated!