提问人:Cary H 提问时间:10/26/2023 最后编辑:Christoph RackwitzCary H 更新时间:10/26/2023 访问量:11
如何同步 OAK-D 相机并将 IMU 数据与视频帧一起保存
How to sync OAK-D cameras and save the IMU data with video frames
问:
我有 2 台 OAK-D Pro 相机,我需要同步它们并将 MONO 相机“向左或向右”保存为视频。我想获取每帧的 IMU 数据或保存的 100 hz IMU 输出。
一些只记录视频而不记录IMU数据的代码是这样的:
from depthai_sdk import OakCamera, RecordType
import depthai as dai
from pathlib import Path
import csv
out_path = r"F:\CAMERAS"
OUTPUT_DIR = Path(out_path)
Output_csv = Path.joinpath(OUTPUT_DIR, "CSV")
print("Output", Output_csv)
def write_times(outime, big_array):
print("Writing Timestamp CSV.")
outname = outime.replace(":", "_") + ".csv"
outfile = Path.joinpath(Output_csv, outname)
header = ["Device", "Cam", "Timestamp"]
with open(outfile,"w", newline='') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',')
spamwriter.writerow(header)
for rowi in big_array:
spamwriter.writerow(rowi)
return True
device_infos = dai.Device.getAllAvailableDevices()
for device in device_infos:
print(f"{device.mxid} {device.state} Name {device.name} {device.platform}")
oakL =OakCamera("18443010A123AA0F00")
left = oakL.create_camera('left', resolution='720p', fps=20, encode='H265')
right = oakL.create_camera('right', resolution='720p', fps=20, encode='H265')
# Synchronize & save all (encoded) streams
oakR =OakCamera("1844301081B8AC0F00")
leftR = oakR.create_camera('left', resolution='720p', fps=20, encode='H265')
rightR = oakR.create_camera('right', resolution='720p', fps=20, encode='H265')
imuR = oakR.create_imu()
oakL.record([ left.out.encoded, right.out.encoded], out_path, RecordType.VIDEO)
oakR.record([ leftR.out.encoded, rightR.out.encoded], out_path, RecordType.VIDEO)
# Show left stream
oakL.visualize([left.out.camera], scale=2/3, fps=True)
#oakR.visualize([rightR.out.encoded], scale=2/3, fps=True)
oakL.start()
oakR.start()
left.control.set_exposure_iso(1500, 600) #setting either mono camera controls both
leftR.control.set_exposure_iso(1500, 600)
while oakL.running():
key = oakL.poll()
if key == ord('i'):
left.control.exposure_time_down()
elif key == ord('o'):
left.control.exposure_time_up()
elif key == ord('k'):
left.control.sensitivity_down()
elif key == ord('l'):
left.control.sensitivity_up()
elif key == ord('q'):
oakL.close()
oakR.close()
break
elif key == ord('e'): # Switch to auto exposure
left.control.send_controls({'exposure': {'auto': True}})
print(f"Output folder {out_path}")
oakL.close()
oakR.close()
如果我添加 IMU 数据并尝试将其保存为 MCAP,它会失败并显示未找到模块错误。没有名为 mcap_ros1 的模块。有没有办法保存IMU数据?
答: 暂无答案
评论