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?
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,352 times
Last updated: Nov 12 '13
How to set camera resolution in OpenCV on Android?
VideoCapture parameters CV_CAP_PROP_FOURCC or CV_CAP_PROP_FPS, among others, not working
Access Mobile Camera From Native C++ vs Android
how can I use only the back camera with VideoCapture?
How to decrease the number of processed frames from a live video camera?