There is a function in the camera class

bool Camera::CaptureFrame(bool rotate){ Rotated = rotate; return capGrabFrame(CaptureWindow); } 

An appropriate callback is tied to the capGrabFrame api call. The problem is that if you simply pull the USB camera out of the port, the application freezes and crashes, because, as I understand it, the camera driver that is on the CaptureWindow is lost from the list of devices. And it is necessary that the application does not crash, but fix the error and report it to the user.

The question is how to properly catch driver access errors? There is in vfw.h LRESULT CALLBACK capErrorCallback(HWND hWnd, int nID, LPCTSTR lpsz); , but I don’t understand what kind of error id it requires to enter, if I haven’t received any error yet, and will this callback help solve the problem?

  • If it crashes, it means that you should catch the error through try/catch or __try/__except . Consider that the crash in the API is unlikely, first look for it in yourself. - mega
  • @mega, but the stream doesn’t really try / catch. It crashes only when the driver disappears from the device list, when the usb camera is physically disabled. And because of this, I cannot assume that api crash is unlikely here, since only the call to this function crashes the application. tests are all covered. - Iceman
  • Add a minimally reproducible example to the question. You may even solve your problem. In this case - make out the answer. - mega

0