更新时间:2022-08-18 GMT+08:00
是否可以将HiLens Kit摄像头拍摄的画面或者技能运行结果录成视频保存下来?
可以,请使用OpenCV的VideoWriter,注意录制的视频格式必须是MJPG,参考代码如下:
camera = hilens.VideoCapture()
fps = 20
size = (1280, 720)
format = cv2.VideoWriter_fourcc('M','J','P','G')
writer = cv2.VideoWriter("output.avi", format, fps, size)
count = 0
duration = 100 # 录制的视频时长
while True:
input_nv21 = camera.read()
input_bgr = cv2.cvtColor(input_nv21, cv2.COLOR_YUV2BGR_NV21)
writer.write(input_bgr)
if count >= fps * duration:
break
count += 1
writer.release()
父主题: 管理数据