Last active
October 2, 2015 15:52
-
-
Save ruslo/4be4a3e3381dd8488771 to your computer and use it in GitHub Desktop.
Process camera frames in parallel manner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Callback from SurfaceTexture.OnFrameAvailableListener. Is called each time a new | |
* camera frame for the SurfaceTexture is available. | |
*/ | |
@Override | |
public void onFrameAvailable(SurfaceTexture) { | |
synchronized (lock) { | |
frameAvailable = true; | |
lock.notify(); | |
} | |
} | |
/** | |
* Thread run loop. Will run until terminate() is called. | |
*/ | |
@Override | |
public void run() { | |
Log.i(TAG, "starting thread CameraProcThread"); | |
while (running) { | |
synchronized (lock) { | |
lock.wait(); | |
if (frameAvailable) { | |
processFrame(); | |
frameAvailable = false; | |
} | |
} | |
} | |
Log.i(TAG, "stopped thread CameraProcThread"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment