Check for camera disconnection / down
I was capturing video from camera, I need to know if the camera is disconnected or down, is there a way to check?
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, if the VideoCapture object is opened or not.
Asked: 2013-11-12 00:51:28 -0600
Seen: 2,026 times
Last updated: Nov 12 '13