How to run slow video processing algorithms in background while showing camera output?
In more detail, on my iPad I'm trying to
- start the videoCamera;
- take a frame and process it in background (say object detection, which is quite slow)
- in the meanwhile, continuing to show the video output (e.g. at 15 fps)
- when the algorithm terminates on the frame previously taken, take the current frame and run again;
- always show the video output
- when the algorithm terminates, take the current frame...
... and so on.
I tried with dispatch_queues but it gives me errors, I think because I'm not able to say to the processing algorithm "Take the current frame only when you have finished with the frame previously taken".
How can I do that?
Thanks
Learn to use multithreading.
boost::thread
is a good starting point. Follow some of the tutorials there, then start to work on your own solution. boost::asio is a very nice solution, but you may need more time to grasp it. If you work on iOS (which seems to be the case) learn how to usedispatch_queues
or other multithreading mechanisms for iOS. Did you complete a tutorial on iOS multithreading? Are you able to write a simple multithreaded app?