QVideoFilterRunnable
-
Hello, I am looking for a possible implementation idea for my problem. I want to periodically (200ms) wake up a function to perform some arithmetic computation on the current QVideoFrame.
I am using a QVideoFilterRunnable class to access the QVideoFrame of the current frame. In the QVideoFilterRunnable::run(), I obtain the pixel data for the frame and want to perform some synchronous processing of the pixel data.
Originally, I was going to implement a QTimer within the QVideoFilterRunnable::run() and wait a certain time, obtain the frame and do some arithmetic on it. There were two problems with this approach:
- This will block the main GUI thread until the run() is completed.
- I was hoping to obtain different frames, rather than the same frame. Example: If we execute QVideoFilterRunnable::run(), obtain that QVideoFrame, wait 200ms, then obtain the next QVideoFrame, it will still be same frame; regardless of the time. To obtain the next frame, we need the previous run() to finish and execute QVideoFilterRunnable::run() again for the next frame. This brings me to my problem.
I was hoping to implement some sort of thread that wakes up periodically, checks the QVideoFrame from QVideoFilterRunnable::run(), and performs this arithmetic computation. I have come across a couple possible implementations but not sure which one is the best. People recommended using QtConcurrent::run() in the timer slot to run a method in which you handle this but I am fairly new with QtConcurrent and another approach with using QFutureWatcher.
How would you, the qt experts, go around to solving this problem?
Any ideas will help,
Thanks