I am trying to implement some image processing on iPhone. The program should work as following:
- User touches a button to start the task;
- Take one image from my AVCaptureConnection, process it, do something on camera configuration (like setting the point of interest, letting it refocus then lock the focus) based the processing result;
- Take another image, process it;
- Depending on the processing result above, go to (3) immediately or wait a few millisecond;
- Repeat (3) and (4) until user stops it.
The problem I have in this task is that I don't know how to force these tasks to be run sequentially (taking the next step only after the last one is finished). I can only find the
captureStillImageAsynchronouslyFromConnection()
method to capture an image, which seems to run in the same thread in where it is called. As a result, I cannot call
[NSThread sleepForTimeInterval:sometime]
to wait then check if the processing is completed without "sleeping" the processing as well.
Is there something else I can do to achieve the task, or do I have to use explicit threading myself?