Frage

I might have more than one VideoCapture for a Camera. Unfortunately sometimes the connection to the camera seems to get terminated.

Example:

Mat img;
VideoCapture v1(0);
v1.read(img);      //img is a valid picture
VideoCapture v2(0);
v1.read(img);      //img is a valid picture
v2.read(img);      //img is a valid picture
v2 = v1;
v2.read(img);      //img is not a valid picture. Connection seems to be closed

Is this correct behaviour, or is it a bug in OpenCV?

Is there a way to check if a particular devicenumber is already open and get the responsible class?

Pseudocode:

Mat img;
VideoCapture v1(0);
VideoCapture v2 = alreadyOpen(0);

alreadyOpen(0){
    if(VideoCapture(0).isOpen()){ //how do i check that
        return "v1"               //how do i know where v1 is
    }else{
        return VideoCapture(0);
    }
}
War es hilfreich?

Lösung

See Comments:

It's not possible, it might be a bug/not clear if the behavior of OpenCV is intentional.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top