I am trying to process frames in a.bag file with realsense. Is there any way to extract all the frames from this bag file without dropping most of the frames. I could not find an answer online. Here is my code to read the bag file which is based on the Intel example:
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, "test.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