diff --git a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java index d41f980ad6..68d4b7fe80 100644 --- a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java +++ b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java @@ -16,6 +16,7 @@ public class ImageManipulationsActivity extends Activity { public static final int VIEW_MODE_SOBEL = 3; public static final int VIEW_MODE_BLUR = 4; public static final int VIEW_MODE_ZOOM = 5; + public static final int VIEW_MODE_PIXELIZE = 6; private MenuItem mItemPreviewRGBA; private MenuItem mItemPreviewCanny; @@ -23,8 +24,9 @@ public class ImageManipulationsActivity extends Activity { private MenuItem mItemPreviewSobel; private MenuItem mItemPreviewBlur; private MenuItem mItemPreviewZoom; + private MenuItem mItemPreviewPixelize; - public static int viewMode = VIEW_MODE_RGBA; + public static int viewMode = VIEW_MODE_RGBA; public ImageManipulationsActivity() { Log.i(TAG, "Instantiated new " + this.getClass()); @@ -48,6 +50,7 @@ public class ImageManipulationsActivity extends Activity { mItemPreviewSobel = menu.add("Sobel"); mItemPreviewBlur = menu.add("Blur"); mItemPreviewZoom = menu.add("Zoom"); + mItemPreviewPixelize = menu.add("Pixelize"); return true; } @@ -66,6 +69,8 @@ public class ImageManipulationsActivity extends Activity { viewMode = VIEW_MODE_BLUR; else if (item == mItemPreviewZoom) viewMode = VIEW_MODE_ZOOM; + else if (item == mItemPreviewPixelize) + viewMode = VIEW_MODE_PIXELIZE; return true; } } 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 34b233e74f..f979f1403d 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 @@ -17,6 +17,9 @@ import android.util.Log; import android.view.SurfaceHolder; class ImageManipulationsView extends SampleCvViewBase { + private Size mSize0; + private Size mSizeRgbaInner; + private Mat mRgba; private Mat mGray; private Mat mIntermediateMat; @@ -48,6 +51,7 @@ class ImageManipulationsView extends SampleCvViewBase { mGray = new Mat(); mRgba = new Mat(); mIntermediateMat = new Mat(); + mSize0 = new Size(); } } @@ -66,6 +70,7 @@ class ImageManipulationsView extends SampleCvViewBase { if (mRgbaInnerWindow == null) mRgbaInnerWindow = mRgba.submat(top, top + height, left, left + width); + mSizeRgbaInner = mRgbaInnerWindow.size(); if (mGrayInnerWindow == null && !mGray.empty()) mGrayInnerWindow = mGray.submat(top, top + height, left, left + width); @@ -132,6 +137,15 @@ class ImageManipulationsView extends SampleCvViewBase { Size wsize = mZoomWindow.size(); Core.rectangle(mZoomWindow, new Point(1, 1), new Point(wsize.width - 2, wsize.height - 2), new Scalar(255, 0, 0, 255), 2); break; + + case ImageManipulationsActivity.VIEW_MODE_PIXELIZE: + capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); + if (mRgbaInnerWindow == null) + CreateAuxiliaryMats(); + Imgproc.resize(mRgbaInnerWindow, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST); + Imgproc.resize(mIntermediateMat, mRgbaInnerWindow, mSizeRgbaInner, 0., 0., Imgproc.INTER_NEAREST); + break; + } Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);