Monday 15 June 2015

android - How to block a thread until another ends -


I am developing an Android application that is classified by opencv org.opencv.android.JavaCameraView using one The video stream opens. Get libraries, and frames from it, before they are shown on the screen.

The application is organized in such a way:

  1. A main thread, which has the OnCameraFrame method, which gets the frame and sends it to Thread A , And this method is also responsible for displaying the last frame on the screen. Therefore, after the acquisition of the frame, all processing should be done, and before being shown on the screen, in the "middle" of this method.

  2. Thread A, which saves frames created in buffer, blocking linked queue;

  3. Thread B, which takes a frame from the buffer, sends the thread responsible for processing, thread c;

  4. Thread C, which processes the frame, and sends it to the main thread.

    So the question is how can I stop the OnCameraFrame method, so it can not show any frames on the screen, as long as the back of the final thread (C) has not been done? If I do not apply any of this type, then processing requires a little longer, I do not see the last frame on the screen right.

    I hope I am clarifying my problem.

    method will be thread.joint () Thread should not be called, instead you should not show anything in your onCameraFrame () , but at the end of Compass Thread C can call eg activity.runOnUiThread () With the code to show the frame.

No comments:

Post a Comment