ret,frame = video_capture.readValueError:太多值无法解包预期2

问题描述

我想在基于微小脸部检测的项目中使用IP cam代替网络摄像头。

listElement = [ "a",["b","c"],[["d"],["e","f"]] ]

tab = [ [2,1,0],[0] ] # "e" and "a" position

element=""
for i in tab :
    # recuperate the element at the position indicate by i

    element = listElement[i]

解决方法

对于Python

capture= cv2.VideoCapture("rtsp://admin:[email protected]:554")

if not capture:
    print("Failed")
else:
   ret,frame= capture.read()

它在C ++中 您需要将代码更改为

VideoCapture capture;
Mat ImageMat;
bool op = capture.open("rtsp://admin:[email protected]:554");
if(op)
{
    capture >> ImageMat;
}

它将从流中读取。要检查流是否正常,可以使用VLC播放器并在网络流中设置IP,它将对其进行验证