From 22484872fa7b875b7ba98760d5256bbe46557369 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 30 Nov 2012 18:41:46 +0400 Subject: [PATCH 01/15] Sample Tutorial-5 improved Aditional toasts added; Exception handling improved; Bitmap recycling added. --- .../samples/tutorial5/Sample5CameraControl.java | 11 ++++++++++- .../samples/tutorial5/SampleJavaCameraView.java | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java index 358d527b9..38b6dd7b7 100644 --- a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java +++ b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java @@ -20,6 +20,7 @@ import android.view.SurfaceView; import android.view.View; import android.view.View.OnTouchListener; import android.view.WindowManager; +import android.widget.Toast; public class Sample5CameraControl extends Activity implements CvCameraViewListener, OnTouchListener { private static final String TAG = "OCVSample::Activity"; @@ -100,6 +101,11 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen public boolean onCreateOptionsMenu(Menu menu) { List effects = mOpenCvCameraView.getEffectList(); + if (effects == null) { + Log.e(TAG, "Color effects are not supported by device!"); + return true; + } + mEffectMenuItems = new MenuItem[effects.size()]; int idx = 0; @@ -115,13 +121,16 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, "called onOptionsItemSelected; selected item: " + item); mOpenCvCameraView.setEffect((String) item.getTitle()); + Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show(); return true; } @Override public boolean onTouch(View v, MotionEvent event) { Log.i(TAG,"onTouch event"); - mOpenCvCameraView.takePicture(Environment.getExternalStorageDirectory().getPath() + "/sample_picture.jpg"); + String fileName = Environment.getExternalStorageDirectory().getPath() + "/sample_picture.jpg"; + mOpenCvCameraView.takePicture(fileName); + Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show(); return false; } } diff --git a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java index fa33b8f4b..8cbf312ba 100644 --- a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java +++ b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java @@ -25,6 +25,10 @@ public class SampleJavaCameraView extends JavaCameraView { return mCamera.getParameters().getSupportedColorEffects(); } + public boolean isEffectSupported() { + return (mCamera.getParameters().getColorEffect() != null); + } + public String getEffect() { return mCamera.getParameters().getColorEffect(); } @@ -48,6 +52,7 @@ public class SampleJavaCameraView extends JavaCameraView { try { FileOutputStream out = new FileOutputStream(mPictureFileName); picture.compress(Bitmap.CompressFormat.JPEG, 90, out); + picture.recycle(); mCamera.startPreview(); } catch (Exception e) { e.printStackTrace(); From a0c504aabc8236807013e13087c34bcba733e434 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 4 Dec 2012 14:23:25 +0400 Subject: [PATCH 02/15] Initial stub for OpenCVLibraryInfo class added. --- android/service/engine/build.xml | 2 +- android/service/engine/jni/Android.mk | 3 +- .../jni/JNIWrapper/OpenCVLibraryInfo.cpp | 37 +++++++++++++++ .../engine/jni/JNIWrapper/OpenCVLibraryInfo.h | 30 ++++++++++++ android/service/engine/project.properties | 2 +- .../org/opencv/engine/OpenCVLibraryInfo.java | 47 +++++++++++++++++++ 6 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 android/service/engine/jni/JNIWrapper/OpenCVLibraryInfo.cpp create mode 100644 android/service/engine/jni/JNIWrapper/OpenCVLibraryInfo.h create mode 100644 android/service/engine/src/org/opencv/engine/OpenCVLibraryInfo.java diff --git a/android/service/engine/build.xml b/android/service/engine/build.xml index a16a4fefb..98ddc3eac 100644 --- a/android/service/engine/build.xml +++ b/android/service/engine/build.xml @@ -1,5 +1,5 @@ - +