Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It's not clear if you want to display the processed frames in the video window. So I'll assume you just want to show the original video to the user, and do something else with the processed frame.

The most obvious approach is creating a 2nd thread to do your custom processing.

The idea is that on every iteration of the main loop, your application will perform 2 tasks:

  • display the frame on the screen;
  • and check if the 2nd thread is alive: if it's not, you will start the 2nd thread and pass a copy of the current frame for it to process. When the processing finishes on the 2nd thread the thread will automatically die, but on the next iteration of the main loop it will be started again with a new frame to process.

It's not clear if you want to display the processed frames in the video window. So I'll assume you just want to show the original video to the user, and do something else with the processed frame.

The most obvious approach is creating a 2nd thread to do your custom processing.

The idea is that on every iteration of the main loop, your application will perform 2 tasks:

  • display the frame on the screen;
  • and check if the 2nd thread is alive: if it's not, you will start the 2nd thread and pass a copy of the current frame for it to process. When the processing finishes on the 2nd thread the thread will automatically die, but on the next iteration of the main loop it will be started again with a new frame to process.

On this post I share 2 similar solutions, one using Linux pthreads and the other using Windows threads.