【发布时间】:2019-12-24 05:06:01
【问题描述】:
我正在尝试将英特尔 Realsense D435i 摄像头的深度和彩色图像保存在 300 张图像的列表中。然后我将使用多重处理将这 300 张图像的块保存到我的磁盘上。但是每次我尝试时,程序都会成功地在列表中附加 15 张图像,然后我得到这个错误:
Frame didn't arrived within 5000
我确保在 python 3.6 上安装了 64 位版本,并且当我不尝试将图像保存在列表中时,相机的流式传输非常好。真实感的查看器也很棒。我也尝试了不同的分辨率和帧速率,但它似乎也不起作用。有趣的是,如果我只保存彩色图像,我不会得到相同的错误,而是会在列表中一遍又一遍地得到相同的颜色图像。
if __name__ == '__main__':
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 1280, 720, rs.format.bgr8, 30)
profile = pipeline.start(config)
depth_sensor = profile.get_device().first_depth_sensor()
depth_sensor.set_option(
rs.option.visual_preset, 3
) # Set high accuracy for depth sensor
depth_scale = depth_sensor.get_depth_scale()
align_to = rs.stream.color
align = rs.align(align_to)
# Init variables
im_count = 0
image_chunk = []
image_chunk2 = []
# sentinel = True
try:
while True:
# Wait for a coherent pair of frames: depth and color
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
aligned_depth_frame = aligned_frames.get_depth_frame()
color_frame = aligned_frames.get_color_frame()
if not aligned_depth_frame or not color_frame:
print("problem here")
raise RuntimeError("Could not acquire depth or color frames.")
depth_image = np.asanyarray(aligned_depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())
image_chunk.append(color_image)
image_chunk2.append(depth_image)
except Exception as e:
print(e)
finally:
# Stop streaming
pipeline.stop()
我只需要它连续保存 300 张图像,仅此而已,所以我很困扰是什么导致了这个问题。
【问题讨论】:
-
不知何故
.append()导致运行时错误。我也遇到了类似的问题。 -
我很高兴知道我不是唯一的,另一种方法是将流保存到 .bag 文件中
-
我在这里遇到了类似的问题stackoverflow.com/q/63027477/2478346
-
您不能将帧放入列表中,因为它会锁定内存。从框架创建的 numpy 数组仍然指向框架的内存。您必须复制(即克隆)它才能断开链接。如果您以任何方式(USB 缓冲存储器,而不是 PC 内存)存储帧的句柄,最终会耗尽内存。