Question: I'm attempting to detect if my capture camera gets unplugged. My assumption was that a call to `cvQueryFrame` would return `NULL`, however it continues to return the last valid frame. 

Does anyone know of how to detect camera plug/unplug events with OpenCV? This seems so rudimentary...what am I missing?

Answer: 
This still seems to be an issue.
Another solution would be to compare the returned data with the previous one. For a working camera there should always be flickering. if the data is identical you can be sure, the cam was unplugged.
Martin
I think that I have a good workaround for this problem. I create an auxiliary Mat array with zeros with the same resolution like the output from camera. I assign it to Mat array to which just after is assign the frame captured from camera and at the end I check the norm of this array. If it is equal zero it means that there was no new frame captured from camera.

```
VideoCapture cap(0);
if(!cap.isOpened()) return -1;

Mat frame;
cap >> frame;
Mat emptyFrame = Mat::zeros(CV_CAP_PROP_FRAME_WIDTH,     , CV_32F);

for(;;)
{
   frame = emptyFrame;
   cap >> frame;
   if (norm(frame) == 0) break;
}

```