我正在尝试使用 realsense 处理 a.bag 文件中的帧。有没有办法从这个包文件中提取所有帧而不丢弃大部分帧。我在网上找不到答案。这是我读取基于英特尔示例的包文件的代码:
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