diff --git a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java index 19eeb3b204..339f0c61cc 100644 --- a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java +++ b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java @@ -115,5 +115,5 @@ public class ColorBlobDetector // Color radius for range checking in HSV color space private Scalar mColorRadius = new Scalar(25,50,50,0); private Mat mSpectrum = new Mat(); - private List mContours = new ArrayList();; + private List mContours = new ArrayList(); } diff --git a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/SampleCvViewBase.java b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/SampleCvViewBase.java index 0e2e0459aa..55b41bc69d 100644 --- a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/SampleCvViewBase.java +++ b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/SampleCvViewBase.java @@ -52,7 +52,7 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol } public void setupCamera(int width, int height) { - Log.i(TAG, "setupCamera("+width+", "+height+")"); + Log.i(TAG, "setupCamera("+width+", "+height+")"); synchronized (this) { if (mCamera != null && mCamera.isOpened()) { List sizes = mCamera.getSupportedPreviewSizes(); @@ -111,11 +111,12 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol bmp = processFrame(mCamera); } - + if (bmp != null) { Canvas canvas = mHolder.lockCanvas(); if (canvas != null) { - canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()) / 2, null); + canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR); + canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()) / 2, null); mHolder.unlockCanvasAndPost(canvas); } bmp.recycle(); diff --git a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsView.java b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsView.java index 8ebbf81b64..1506a4b54c 100644 --- a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsView.java +++ b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsView.java @@ -127,7 +127,7 @@ class ImageManipulationsView extends SampleCvViewBase { case ImageManipulationsActivity.VIEW_MODE_HIST: capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); - if (mSizeRgba == null) + if ((mSizeRgba == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height)) CreateAuxiliaryMats(); int thikness = (int) (mSizeRgba.width / (mHistSizeNum + 10) / 5); if(thikness > 5) thikness = 5; @@ -171,7 +171,7 @@ class ImageManipulationsView extends SampleCvViewBase { case ImageManipulationsActivity.VIEW_MODE_CANNY: capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); - if (mRgbaInnerWindow == null || mGrayInnerWindow == null) + if ((mRgbaInnerWindow == null) || (mGrayInnerWindow == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height)) CreateAuxiliaryMats(); Imgproc.Canny(mRgbaInnerWindow, mIntermediateMat, 80, 90); Imgproc.cvtColor(mIntermediateMat, mRgbaInnerWindow, Imgproc.COLOR_GRAY2BGRA, 4); @@ -181,7 +181,7 @@ class ImageManipulationsView extends SampleCvViewBase { capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME); - if (mRgbaInnerWindow == null || mGrayInnerWindow == null) + if ((mRgbaInnerWindow == null) || (mGrayInnerWindow == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height)) CreateAuxiliaryMats(); Imgproc.Sobel(mGrayInnerWindow, mIntermediateMat, CvType.CV_8U, 1, 1); @@ -196,7 +196,7 @@ class ImageManipulationsView extends SampleCvViewBase { case ImageManipulationsActivity.VIEW_MODE_ZOOM: capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); - if (mZoomCorner == null || mZoomWindow == null) + if ((mZoomCorner == null) || (mZoomWindow == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height)) CreateAuxiliaryMats(); Imgproc.resize(mZoomWindow, mZoomCorner, mZoomCorner.size()); @@ -206,7 +206,7 @@ class ImageManipulationsView extends SampleCvViewBase { case ImageManipulationsActivity.VIEW_MODE_PIXELIZE: capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); - if (mRgbaInnerWindow == null) + if ((mRgbaInnerWindow == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height)) CreateAuxiliaryMats(); Imgproc.resize(mRgbaInnerWindow, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST); Imgproc.resize(mIntermediateMat, mRgbaInnerWindow, mSizeRgbaInner, 0., 0., Imgproc.INTER_NEAREST); @@ -214,7 +214,7 @@ class ImageManipulationsView extends SampleCvViewBase { case ImageManipulationsActivity.VIEW_MODE_POSTERIZE: capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); - if (mRgbaInnerWindow == null) + if ((mRgbaInnerWindow == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height)) CreateAuxiliaryMats(); /* Imgproc.cvtColor(mRgbaInnerWindow, mIntermediateMat, Imgproc.COLOR_RGBA2RGB); diff --git a/samples/android/tutorial-0-androidcamera/src/org/opencv/samples/tutorial0/Sample0Base.java b/samples/android/tutorial-0-androidcamera/src/org/opencv/samples/tutorial0/Sample0Base.java index a8b7765989..858e43dc9e 100644 --- a/samples/android/tutorial-0-androidcamera/src/org/opencv/samples/tutorial0/Sample0Base.java +++ b/samples/android/tutorial-0-androidcamera/src/org/opencv/samples/tutorial0/Sample0Base.java @@ -10,12 +10,12 @@ import android.view.MenuItem; import android.view.Window; public class Sample0Base extends Activity { - private static final String TAG = "Sample::Activity"; + + private static final String TAG = "Sample::Activity"; private MenuItem mItemPreviewRGBA; private MenuItem mItemPreviewGray; - private Sample0View mView; - + private Sample0View mView; public Sample0Base() { Log.i(TAG, "Instantiated new " + this.getClass()); diff --git a/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2View.java b/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2View.java index 74d29dd1c2..2fa2b8ff23 100644 --- a/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2View.java +++ b/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2View.java @@ -44,7 +44,7 @@ class Sample2View extends SampleCvViewBase { break; case Sample2NativeCamera.VIEW_MODE_RGBA: capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); - Core.putText(mRgba, "OpenCV + Android", new Point(10, 100), 3, 2, new Scalar(255, 0, 0, 255), 3); + Core.putText(mRgba, "OpenCV+Android", new Point(10, 50), 3, 1, new Scalar(255, 0, 0, 255), 2); break; case Sample2NativeCamera.VIEW_MODE_CANNY: capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME); diff --git a/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/SampleCvViewBase.java b/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/SampleCvViewBase.java index a15f880035..dcce4e5040 100644 --- a/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/SampleCvViewBase.java +++ b/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/SampleCvViewBase.java @@ -115,7 +115,8 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol if (bmp != null) { Canvas canvas = mHolder.lockCanvas(); if (canvas != null) { - canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()) / 2, null); + canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR); + canvas.drawBitmap(bmp, (canvas.getWidth()-bmp.getWidth()) / 2, (canvas.getHeight()-bmp.getHeight()) / 2, null); mHolder.unlockCanvasAndPost(canvas); } bmp.recycle();