Ask Your Question

Check for camera disconnection / down

asked 2013-11-12 00:51:28 -0500

swejnc gravatar image

updated 2013-11-12 05:00:23 -0500

berak gravatar image

I was capturing video from camera, I need to know if the camera is disconnected or down, is there a way to check?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-11-12 04:39:52 -0500

updated 2013-11-12 04:42:34 -0500

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

VideoCapture cap;
Mat frame;;

            cout << "failed to read frame";

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

edit flag offensive delete link more


I need to check for more than one time, let say every loop of capturing, I need to know when the camera is down. Once the camera works, IsOpened() always return true even the camera goes down after that. If I use in a loop, it cause memory leak.

swejnc gravatar imageswejnc ( 2013-11-12 18:47:06 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-11-12 00:51:28 -0500

Seen: 1,091 times

Last updated: Nov 12 '13