Menu Close

My code that capture frames in burst mode in a GUI application, does not work in a console application

How Can We Help?

< Back
You are here:
Print

My code that capture frames in burst mode in a GUI application, does not work in a console application

In a console application, a waiting loop is needed just after StartPreview(), otherwise, if exiting the app after StartPreview(), this just terminates immediately the background thread, even before the 1st video frame as been received and processed.

The workaround consists to add a waiting loop just after invoking StartPreview():


bool CanClose = false;
VideoGrabber….
VideoGrabber….
VideoGrabber.StartPreview();
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if (CanClose) { /// set CanClose = true to quit the waiting loop
break;
}
}
VideoGrabber.StopPreview();

(In a GUI application this waiting loop already exists, it’s the main thread’s loop that runs in the background and processes the Windows messages)

Table of Contents