Skip to content

Commit

Permalink
Merge pull request opencv#1073 from asmorkalov:android_cvjavaframe
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Donchenko authored and OpenCV Buildbot committed Jul 5, 2013
2 parents c4e5986 + 91b713b commit f508910
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/java/generator/src/java/android+JavaCameraView.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
private boolean mStopThread;

protected Camera mCamera;
protected JavaCameraFrame mCameraFrame;
protected JavaCameraFrame[] mCameraFrame;
private SurfaceTexture mSurfaceTexture;

public static class JavaCameraSizeAccessor implements ListItemAccessor {
Expand Down Expand Up @@ -180,7 +180,9 @@ protected boolean initializeCamera(int width, int height) {

AllocateCache();

mCameraFrame = new JavaCameraFrame(mFrameChain[mChainIdx], mFrameWidth, mFrameHeight);
mCameraFrame = new JavaCameraFrame[2];
mCameraFrame[0] = new JavaCameraFrame(mFrameChain[0], mFrameWidth, mFrameHeight);
mCameraFrame[1] = new JavaCameraFrame(mFrameChain[1], mFrameWidth, mFrameHeight);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID);
Expand Down Expand Up @@ -216,8 +218,10 @@ protected void releaseCamera() {
mFrameChain[0].release();
mFrameChain[1].release();
}
if (mCameraFrame != null)
mCameraFrame.release();
if (mCameraFrame != null) {
mCameraFrame[0].release();
mCameraFrame[1].release();
}
}
}

Expand Down Expand Up @@ -318,7 +322,7 @@ public void run() {

if (!mStopThread) {
if (!mFrameChain[mChainIdx].empty())
deliverAndDrawFrame(mCameraFrame);
deliverAndDrawFrame(mCameraFrame[mChainIdx]);
mChainIdx = 1 - mChainIdx;
}
} while (!mStopThread);
Expand Down

0 comments on commit f508910

Please sign in to comment.