Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用OpenCV处理Hololens2实时预览帧_Python_Opencv_Computer Vision_Hololens - Fatal编程技术网

Python 使用OpenCV处理Hololens2实时预览帧

Python 使用OpenCV处理Hololens2实时预览帧,python,opencv,computer-vision,hololens,Python,Opencv,Computer Vision,Hololens,我试图通过设备门户访问Hololens2实时预览,使用OpenCV从我的Hololens2相机(用户看到的)本地捕获帧。实时预览基本上只是一个mp4视频流,可以通过API访问 在开始下面的脚本时,前几帧的处理是平滑的。但是,我突然收到一些错误消息,脚本终止: [tls @ 0000017b5b30e880] Unable to read from socket [NULL @ 0000017b5b3102c0] Invalid NAL unit size (18397 > 14506).

我试图通过设备门户访问Hololens2实时预览,使用OpenCV从我的Hololens2相机(用户看到的)本地捕获帧。实时预览基本上只是一个mp4视频流,可以通过API访问

在开始下面的脚本时,前几帧的处理是平滑的。但是,我突然收到一些错误消息,脚本终止:

[tls @ 0000017b5b30e880] Unable to read from socket
[NULL @ 0000017b5b3102c0] Invalid NAL unit size (18397 > 14506).
[NULL @ 0000017b5b3102c0] missing picture in access unit with size 14516
[h264 @ 0000017b7e321980] Invalid NAL unit size (18397 > 14506).
[h264 @ 0000017b7e321980] Error splitting the input into NAL units.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000017b5b30b380] root atom offset 0x683f9: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000017b5b30b380] root atom offset 0x683f9: partial file
这是我处理实时预览的代码:

import numpy as np
import cv2
import os
import time

vcap = cv2.VideoCapture('https://<Hololens IP address>/api/holographic/stream/live.mp4?pv=true')

i=0

while(vcap.isOpened()):
   
    ret, frame = vcap.read()
    
    if frame is not None:
        path = 'C:/Users/images'
        cv2.imwrite(os.path.join(path, '{}.jpg'.format(str(i))), frame)
        i+=1
    else:
        print("Frame is None")
        break
    time.sleep(2)

vcap.release()
cv2.destroyAllWindows()
将numpy导入为np
进口cv2
导入操作系统
导入时间
vcap=cv2.VideoCapture('https:///api/holographic/stream/live.mp4?pv=true')
i=0
而(vcap.isOpened()):
ret,frame=vcap.read()
如果框架不是无:
路径='C:/Users/images'
imwrite(os.path.join(path,{}.jpg'.格式(str(i))),帧)
i+=1
其他:
打印(“帧为无”)
打破
时间。睡眠(2)
vcap.release()
cv2.destroyAllWindows()
有人知道如何解决这个问题吗?或者有没有更好的方法来访问和处理这些帧?我基本上只想每1-2秒拍一张照片,然后在这张照片上运行一些物体识别算法