Ask Your Question

Revision history [back]

Try to read frame, if you can't it probably means that the camera was disconnected.

VideoCapture cap;
Mat frame;

cap.open(0);

    if( !_cap.read(frame))
        {
            cout << "failed to read frame";
            return;
        }

There's also a cap.IsOpened() method that returns 1 or 0, weather the camera is connected or not

Try to read frame, if you can't it probably means that the camera was disconnected.

VideoCapture cap;
Mat frame;

cap.open(0);

    if( !_cap.read(frame))
if(!cap.read(frame))
        {
            cout << "failed to read frame";
            return;
        }

There's also a cap.IsOpened() method that returns 1 or 0, weather the camera is connected or not

Try to read frame, if you can't it probably means that the camera was disconnected.

VideoCapture cap;
Mat frame;

cap.open(0);

    if(!cap.read(frame))
        {
            cout << "failed to read frame";
            return;
        }

There's also a cap.IsOpened() method that returns 1 or 0, weather if the camera VideoCapture object is connected opened or notnot.