View Full Version : how to know that Camera is Disconnected?

July 27, 2009, 08:26:02
dear Stefan!

after starting live mode, if i need to check that whether the camera is working perfectly, how to do that?

i tried with sLive() function but its not working.

please let me know. i just need to throw the message from my application that if there is any problem in my camera after starting live mode.

thanks in advance.


Sascha Schmidt
July 28, 2009, 16:44:50
Hallo abdul,

you can use the "GrabberListener::deviceLost" method, in order to detect if the device is lost.

Please have a look at:

January 22, 2010, 11:01:49

I am using the Video -> USB converters, and I would like to know if there is a way to be notified if the video cable (and not the device itself) is disconnected or incorrectly inserted?

I checked but the deviceLost method is only called in case the USB cable is disconnected, not if the video signal is disconnected (which makes sense).

From what I tested so far, it looks like when video is disconnected, the wrapper notifies at random frequency some blue/blue and black/black image. I could try to measure the average frequency of notifications to detect the problem but I would be happy if there was an easier way to do it!

Stefan Geissler
January 25, 2010, 08:23:22

the DFG/USB2-lt provides images all the time, even if no video signal is connected to the converter.

Thus the only way to check whether there is a valid video signal, is to look for some pixels in the GrabberListener class. If no video device is connected, then the provided images are black or green. The trick is to check an area on the image, whether the pixels in the area have different colors. They must be different, because there is every time some noise. If the pixel colors are all equal, then obviously no video capture device is connected.

A colleague of mine created a frame filter, that does this check.

January 27, 2010, 16:23:35
Thank you very much for this sample, I will test it ASAP!

February 12, 2010, 08:59:25
It works fine, thanks a lot!

I noticed though, that in case of low exposure some valid images are detected as invalid. To avoid this I changed the tests:

if( Count > 25 && !noDevice)

else if ( Count < 25 && noDevice )
in DeviceLostFilter.cpp by

if( Count > 29 && !noDevice)

else if ( Count < 29 && noDevice )
It might be helpful depending on your exposure conditions!

Stefan Geissler
February 12, 2010, 11:28:56
Duduche, please keep in mind, this filter is only sense full to be used with the DFG/USB2-lt. For all cameras you can use the DeviceLost event. For the DFG/1394 you can use its "Signal Detected" property.