Hi all,

I am doing real time video processing. I have to apply a vision algorithm to every single frame and show it on a view. So far, I managed it. However, it is slow and I am losing most of the image frames, because of the complexities in the processing algorithm. While the algorithm is running, I should continue getting frames and make use of them inside another threads. I had to somehow use multi-threading. I have read through this explanatory doc http://www.develer.com/promo/worksho..._threading.pdf and seen that the best way is concurrency. I thought of a flow using 50 threads pseudo coded as such:

Qt Code:
  1. result[50]; // array of QFuture<QImage>
  2. while(1)
  3. {
  4. result[0] = run(algorithm); // "algorithm" includes getting a frame from camera, process and return
  5.  
  6. for(i = 1; i < 20; i++)
  7. {
  8. if(result[0].isRunning())
  9. {
  10. result[i] = run(algorithm);
  11. }
  12. else
  13. break; // breaking depends on the algorithm time
  14. }
  15.  
  16. for(j = 0; j < i; j++)
  17. {
  18. run(show, result[j].result()); // show results on ui
  19. }
  20. }
To copy to clipboard, switch view to plain text mode 

This flow assumes no time loss when running a concurrent process. My questions are:

- Say I have a video 200 fps = 1 frame per 5 ms. Does "QtConcurrent::run" start its execution faster than ms range, so that I can guarantee not to lose any frames?
- Is concurrency cause memory leaks or any application crashes reported?
- Is there a faster and applicable way of multi-threading for my issue?