2

我正在使用 OpenCV 来获取一些视频帧。这是相机捕获的初始化方式:

VideoCapture capture;
capture.open(0);  //Read from camera #0

如果我想切换到不同的相机,我会这样做:

capture.release();  //Release the stream
capture.open(1);    //Open different stream

想象一下,您有几个摄像头连接到您的计算机,并且您想使用两个按钮Previous cameraNext camera. 在不将当前相机 ID 保存到变量的情况下,我需要从VideoCapture对象中获取实际值。
那么有没有办法找出当前使用的设备的id呢?

伪代码:

int current = capture.deviceId;
capture.release();
capture.open(current++);
4

1 回答 1

0

So is there a way how to find out the id of currently used device?

There's no way to do this because class VideoCapture doesn't contain such variable or method. It actually contains protected pointer to CvCapture (take a look at highgui.h) so you could try to play with it but you don't have access to this field.

于 2013-05-20T05:52:08.220 回答