Merge pull request #2411 from asmorkalov:android_mat_leak_fix
This commit is contained in:
commit
7dc549f166
@ -22,6 +22,7 @@ public class NativeCameraView extends CameraBridgeViewBase {
|
|||||||
private Thread mThread;
|
private Thread mThread;
|
||||||
|
|
||||||
protected VideoCapture mCamera;
|
protected VideoCapture mCamera;
|
||||||
|
protected NativeCameraFrame mFrame;
|
||||||
|
|
||||||
public NativeCameraView(Context context, int cameraId) {
|
public NativeCameraView(Context context, int cameraId) {
|
||||||
super(context, cameraId);
|
super(context, cameraId);
|
||||||
@ -97,6 +98,8 @@ public class NativeCameraView extends CameraBridgeViewBase {
|
|||||||
if (mCamera.isOpened() == false)
|
if (mCamera.isOpened() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
mFrame = new NativeCameraFrame(mCamera);
|
||||||
|
|
||||||
java.util.List<Size> sizes = mCamera.getSupportedPreviewSizes();
|
java.util.List<Size> sizes = mCamera.getSupportedPreviewSizes();
|
||||||
|
|
||||||
/* Select the size that fits surface considering maximum size allowed */
|
/* Select the size that fits surface considering maximum size allowed */
|
||||||
@ -127,9 +130,8 @@ public class NativeCameraView extends CameraBridgeViewBase {
|
|||||||
|
|
||||||
private void releaseCamera() {
|
private void releaseCamera() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mCamera != null) {
|
if (mFrame != null) mFrame.release();
|
||||||
mCamera.release();
|
if (mCamera != null) mCamera.release();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +155,11 @@ public class NativeCameraView extends CameraBridgeViewBase {
|
|||||||
mRgba = new Mat();
|
mRgba = new Mat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void release() {
|
||||||
|
if (mGray != null) mGray.release();
|
||||||
|
if (mRgba != null) mRgba.release();
|
||||||
|
}
|
||||||
|
|
||||||
private VideoCapture mCapture;
|
private VideoCapture mCapture;
|
||||||
private Mat mRgba;
|
private Mat mRgba;
|
||||||
private Mat mGray;
|
private Mat mGray;
|
||||||
@ -167,7 +174,7 @@ public class NativeCameraView extends CameraBridgeViewBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
deliverAndDrawFrame(new NativeCameraFrame(mCamera));
|
deliverAndDrawFrame(mFrame);
|
||||||
|
|
||||||
} while (!mStopThread);
|
} while (!mStopThread);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user