Commit 09383580 authored by Andrey Kamaev's avatar Andrey Kamaev

Merge pull requests #136, #142, #150, #152 from…

Merge pull requests #136, #142, #150, #152 from asmorkalov/new_framework_tutorial, asmorkalov/fd_package_fix, asmorkalov/java_test_fix and asmorkalov/engine_build_fix
...@@ -468,7 +468,7 @@ if(BUILD_ANDROID_PACKAGE) ...@@ -468,7 +468,7 @@ if(BUILD_ANDROID_PACKAGE)
add_subdirectory(android/package) add_subdirectory(android/package)
endif() endif()
if (ANDROID AND NOT BUILD_ANDROID_SERVICE AND NOT BUILD_ANDROID_PACKAGE AND NOT BUILD_CAMERA_WRAPER) if (ANDROID)
add_subdirectory(android/libinfo) add_subdirectory(android/libinfo)
endif() endif()
......
...@@ -7,7 +7,7 @@ const char* GetLibraryList(void); ...@@ -7,7 +7,7 @@ const char* GetLibraryList(void);
JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass); JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass);
#define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" ANDROID_PACKAGE_PLATFORM #define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" ANDROID_PACKAGE_PLATFORM
#define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) CVAUX_STR(ANDROID_PACKAGE_RELEASE) #define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE)
const char* GetPackageName(void) const char* GetPackageName(void)
{ {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine" package="org.opencv.engine"
android:versionCode="20" android:versionCode="20@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.0" > android:versionName="2.0" >
<uses-sdk android:minSdkVersion="8" /> <uses-sdk android:minSdkVersion="8" />
......
...@@ -4,6 +4,24 @@ set(JNI_LIB_NAME ${engine} ${engine}_jni) ...@@ -4,6 +4,24 @@ set(JNI_LIB_NAME ${engine} ${engine}_jni)
unset(__android_project_chain CACHE) unset(__android_project_chain CACHE)
add_android_project(opencv_engine "${CMAKE_CURRENT_SOURCE_DIR}" SDK_TARGET 8 ${ANDROID_SDK_TARGET} IGNORE_JAVA ON) add_android_project(opencv_engine "${CMAKE_CURRENT_SOURCE_DIR}" SDK_TARGET 8 ${ANDROID_SDK_TARGET} IGNORE_JAVA ON)
set(ANDROID_PLATFORM_VERSION_CODE "0")
if(ARMEABI_V7A)
set(ANDROID_PLATFORM_VERSION_CODE "2")
elseif(ARMEABI_V6)
set(ANDROID_PLATFORM_VERSION_CODE "1")
elseif(ARMEABI)
set(ANDROID_PLATFORM_VERSION_CODE "1")
elseif(X86)
set(ANDROID_PLATFORM_VERSION_CODE "3")
elseif(MIPS)
set(ANDROID_PLATFORM_VERSION_CODE "4")
else()
message(WARNING "Can not automatically determine the value for ANDROID_PLATFORM_VERSION_CODE")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/android/service/engine/.build/${ANDROID_MANIFEST_FILE}" @ONLY)
link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}") link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}")
# -D__SUPPORT_ARMEABI_FEATURES key is also available # -D__SUPPORT_ARMEABI_FEATURES key is also available
......
...@@ -260,224 +260,119 @@ To build your own Android application, which uses OpenCV from native part, the f ...@@ -260,224 +260,119 @@ To build your own Android application, which uses OpenCV from native part, the f
#. Either use :ref:`manual <NDK_build_cli>` ``ndk-build`` invocation or :ref:`setup Eclipse CDT Builder <CDT_Builder>` to build native JNI lib before Java part [re]build and APK creation. #. Either use :ref:`manual <NDK_build_cli>` ``ndk-build`` invocation or :ref:`setup Eclipse CDT Builder <CDT_Builder>` to build native JNI lib before Java part [re]build and APK creation.
Hello OpenCV Sample "Hello OpenCV" Sample
=================== =====================
Here are basic steps to guide you trough the process of creating a simple OpenCV-centric application. Here are basic steps to guide you trough the creation process of a simple OpenCV-centric application.
It will be capable of accessing camera output, processing it and displaying the result. It will be capable of accessing camera output, processing it and displaying the result.
#. Open Eclipse IDE, create a new clean workspace, create a new Android project (*File -> New -> Android Project*). #. Open Eclipse IDE, create a new clean workspace, create a new Android project (:guilabel:`File -> New -> Android Project`).
#. Set name, target, package and minSDKVersion accordingly. #. Set name, target, package and ``minSDKVersion`` accordingly.
#. Create a new class (*File -> New -> Class*). Name it for example: *HelloOpenCVView*. #. Add the following permissions to the ``AndroidManifest.xml`` file:
.. image:: images/dev_OCV_new_class.png
:alt: Add a new class.
:align: center
* It should extend *SurfaceView* class.
* It also should implement *SurfaceHolder.Callback*, *Runnable*.
#. Edit *HelloOpenCVView* class.
* Add an *import* line for *android.content.context*.
* Modify autogenerated stubs: *HelloOpenCVView*, *surfaceCreated*, *surfaceDestroyed* and *surfaceChanged*.
.. code-block:: java
:linenos:
package com.hello.opencv.test;
import android.content.Context;
public class HelloOpenCVView extends SurfaceView implements Callback, Runnable {
public HelloOpenCVView(Context context) {
super(context);
getHolder().addCallback(this);
}
public void surfaceCreated(SurfaceHolder holder) {
(new Thread(this)).start();
}
public void surfaceDestroyed(SurfaceHolder holder) {
cameraRelease();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
cameraSetup(width, height);
}
//...
* Add *cameraOpen*, *cameraRelease* and *cameraSetup* voids as shown below.
* Also, don't forget to add the public void *run()* as follows:
.. code-block:: java
:linenos:
public void run() {
// TODO: loop { getFrame(), processFrame(), drawFrame() }
}
public boolean cameraOpen() {
return false; //TODO: open camera
}
private void cameraRelease() {
// TODO release camera
}
private void cameraSetup(int width, int height) {
// TODO setup camera
}
#. Create a new *Activity* (*New -> Other -> Android -> Android Activity*) and name it, for example: *HelloOpenCVActivity*. For this activity define *onCreate*, *onResume* and *onPause* voids.
.. code-block:: java
:linenos:
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mView = new HelloOpenCVView(this);
setContentView (mView);
}
protected void onPause() {
super.onPause();
mView.cameraRelease();
}
protected void onResume() {
super.onResume();
if( !mView.cameraOpen() ) {
// MessageBox and exit app
AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setCancelable(false); // This blocks the "BACK" button
ad.setMessage("Fatal error: can't open camera!");
ad.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
ad.show();
}
}
#. Add the following permissions to the AndroidManifest.xml file:
.. code-block:: xml .. code-block:: xml
:linenos: :linenos:
</application> <uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
#. Reference OpenCV library within your project properties. #. Reference the OpenCV library within your project properties.
.. image:: images/dev_OCV_reference.png .. image:: images/dev_OCV_reference.png
:alt: Reference OpenCV library. :alt: Reference OpenCV library.
:align: center :align: center
#. We now need some code to handle the camera. Update the *HelloOpenCVView* class as follows: #. Create new view layout for your application, lets name it ``hello_opencv.xml``, and add the following to it:
.. code-block:: java .. code-block:: xml
:linenos: :linenos:
private VideoCapture mCamera; <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
public boolean cameraOpen() { android:layout_width="match_parent"
synchronized (this) { android:layout_height="match_parent" >
cameraRelease();
mCamera = new VideoCapture(Highgui.CV_CAP_ANDROID);
if (!mCamera.isOpened()) {
mCamera.release();
mCamera = null;
Log.e("HelloOpenCVView", "Failed to open native camera");
return false;
}
}
return true;
}
public void cameraRelease() { <org.opencv.android.JavaCameraView
synchronized(this) { android:layout_width="fill_parent"
if (mCamera != null) { android:layout_height="fill_parent"
mCamera.release(); android:visibility="gone"
mCamera = null; android:id="@+id/java_surface_view" />
}
}
}
private void cameraSetup(int width, int height) { </LinearLayout>
synchronized (this) {
if (mCamera != null && mCamera.isOpened()) { #. Remove default auto generated layout, if exists.
List<Size> sizes = mCamera.getSupportedPreviewSizes();
int mFrameWidth = width;
int mFrameHeight = height;
{ // selecting optimal camera preview size
double minDiff = Double.MAX_VALUE;
for (Size size : sizes) {
if (Math.abs(size.height - height) < minDiff) {
mFrameWidth = (int) size.width;
mFrameHeight = (int) size.height;
minDiff = Math.abs(size.height - height);
}
}
}
mCamera.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, mFrameWidth);
mCamera.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, mFrameHeight);
}
}
}
#. The last step would be to update the *run()* void in *HelloOpenCVView* class as follows: #. Create a new ``Activity`` (:guilabel:`New -> Other -> Android -> Android Activity`) and name it, for example: ``HelloOpenCVActivity``.
Add ``CvCameraViewListener`` interface to ``implements`` list of ``HelloOpenCVActivity`` class. Add the following code to activity implementation:
.. code-block:: java .. code-block:: java
:linenos: :linenos:
public void run() { public class Sample1Java extends Activity implements CvCameraViewListener {
while (true) {
Bitmap bmp = null;
synchronized (this) {
if (mCamera == null)
break;
if (!mCamera.grab())
break;
bmp = processFrame(mCamera);
}
if (bmp != null) {
Canvas canvas = getHolder().lockCanvas();
if (canvas != null) {
canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2,
(canvas.getHeight() - bmp.getHeight()) / 2, null);
getHolder().unlockCanvasAndPost(canvas);
}
bmp.recycle();
}
}
}
protected Bitmap processFrame(VideoCapture capture) { private CameraBridgeViewBase mOpenCvCameraView;
Mat mRgba = new Mat();
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
//process mRgba @Override
Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888); public void onManagerConnected(int status) {
try { switch (status) {
Utils.matToBitmap(mRgba, bmp); case LoaderCallbackInterface.SUCCESS: {
} catch(Exception e) { Log.i(TAG, "OpenCV loaded successfully");
Log.e("processFrame", "Utils.matToBitmap() throws an exception: " + e.getMessage()); mOpenCvCameraView.enableView();
bmp.recycle(); } break;
bmp = null; default:
} super.onManagerConnected(status);
return bmp; }
} }
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.hello_opencv);
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.java_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
}
@Override
public void onPause()
{
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
super.onPause();
}
@Override
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
public void onDestroy() {
super.onDestroy();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
public void onCameraViewStarted(int width, int height) {
}
public void onCameraViewStopped() {
}
public Mat onCameraFrame(Mat inputFrame) {
return inputFrame;
}
}
...@@ -23,15 +23,20 @@ import org.opencv.features2d.DMatch; ...@@ -23,15 +23,20 @@ import org.opencv.features2d.DMatch;
import org.opencv.features2d.KeyPoint; import org.opencv.features2d.KeyPoint;
import org.opencv.highgui.Highgui; import org.opencv.highgui.Highgui;
public class OpenCVTestCase extends TestCase { import android.util.Log;
public class OpenCVTestCase extends TestCase {
//change to 'true' to unblock fail on fail("Not yet implemented") //change to 'true' to unblock fail on fail("Not yet implemented")
public static final boolean passNYI = true; public static final boolean passNYI = true;
protected static boolean isTestCaseEnabled = true;
protected static final int matSize = 10; protected static final int matSize = 10;
protected static final double EPS = 0.001; protected static final double EPS = 0.001;
protected static final double weakEPS = 0.5; protected static final double weakEPS = 0.5;
private static final String TAG = "OpenCVTestCase";
protected Mat dst; protected Mat dst;
protected Mat truth; protected Mat truth;
...@@ -173,6 +178,16 @@ public class OpenCVTestCase extends TestCase { ...@@ -173,6 +178,16 @@ public class OpenCVTestCase extends TestCase {
super.tearDown(); super.tearDown();
} }
@Override
protected void runTest() throws Throwable {
// Do nothing if the precondition does not hold.
if (isTestCaseEnabled) {
super.runTest();
} else {
Log.e(TAG, "Test case \"" + this.getClass().getName() + "\" disabled!");
}
}
protected Mat getMat(int type, double... vals) protected Mat getMat(int type, double... vals)
{ {
return new Mat(matSize, matSize, type, new Scalar(vals)); return new Mat(matSize, matSize, type, new Scalar(vals));
......
...@@ -2,9 +2,6 @@ package org.opencv.test; ...@@ -2,9 +2,6 @@ package org.opencv.test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import junit.framework.TestCase;
import junit.framework.Assert; import junit.framework.Assert;
import org.opencv.android.Utils; import org.opencv.android.Utils;
...@@ -72,16 +69,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { ...@@ -72,16 +69,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
//List<TestCase> testCases = androidTestRunner.getTestCases(); //List<TestCase> testCases = androidTestRunner.getTestCases();
//Collections.shuffle(testCases); //shuffle the tests order //Collections.shuffle(testCases); //shuffle the tests order
if(OpenCVTestCase.passNYI) { // Note: VideoCapture tests turned off by flag field in VideoCaptureTest class
// turn off problematic camera tests
Iterator<TestCase> it = androidTestRunner.getTestCases().iterator();
while (it.hasNext()) {
String name = it.next().toString();
if (name.contains("VideoCaptureTest"))
it.remove();
}
}
super.onStart(); super.onStart();
} }
......
...@@ -13,6 +13,8 @@ import org.opencv.features2d.KeyPoint; ...@@ -13,6 +13,8 @@ import org.opencv.features2d.KeyPoint;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner; import org.opencv.test.OpenCVTestRunner;
import android.util.Log;
public class FASTFeatureDetectorTest extends OpenCVTestCase { public class FASTFeatureDetectorTest extends OpenCVTestCase {
FeatureDetector detector; FeatureDetector detector;
...@@ -127,9 +129,9 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase { ...@@ -127,9 +129,9 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename); detector.write(filename);
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n</opencv_storage>\n"; String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n<type>2</type>\n</opencv_storage>\n";
String data = readFile(filename); String data = readFile(filename);
Log.d("qqq", "\"" + data + "\"");
assertEquals(truth, data); assertEquals(truth, data);
} }
...@@ -138,9 +140,10 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase { ...@@ -138,9 +140,10 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename); detector.write(filename);
String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\n"; String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\ntype: 2\n";
String data = readFile(filename); String data = readFile(filename);
Log.d("qqq", "\"" + data + "\"");
assertEquals(truth, data); assertEquals(truth, data);
} }
} }
...@@ -22,10 +22,10 @@ public class HighguiTest extends OpenCVTestCase { ...@@ -22,10 +22,10 @@ public class HighguiTest extends OpenCVTestCase {
public void testImencodeStringMatListOfByteListOfInteger() { public void testImencodeStringMatListOfByteListOfInteger() {
MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40); MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90); MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
/* or /* or
MatOfInt params = new MatOfInt(); MatOfInt params = new MatOfInt();
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40); params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
*/ */
MatOfByte buff40 = new MatOfByte(); MatOfByte buff40 = new MatOfByte();
MatOfByte buff90 = new MatOfByte(); MatOfByte buff90 = new MatOfByte();
......
...@@ -19,13 +19,13 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -19,13 +19,13 @@ public class VideoCaptureTest extends OpenCVTestCase {
super.setUp(); super.setUp();
capture = null; capture = null;
isTestCaseEnabled = false;
isSucceed = false; isSucceed = false;
isOpened = false; isOpened = false;
} }
public void testGet() { public void testGet() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
double frameWidth = capture.get(Highgui.CV_CAP_PROP_FRAME_WIDTH); double frameWidth = capture.get(Highgui.CV_CAP_PROP_FRAME_WIDTH);
assertTrue(0 != frameWidth); assertTrue(0 != frameWidth);
...@@ -35,8 +35,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -35,8 +35,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testGetSupportedPreviewSizes() { public void testGetSupportedPreviewSizes() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
List<Size> sizes = capture.getSupportedPreviewSizes(); List<Size> sizes = capture.getSupportedPreviewSizes();
assertNotNull(sizes); assertNotNull(sizes);
...@@ -68,8 +67,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -68,8 +67,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testIsOpenedRealCamera() { public void testIsOpenedRealCamera() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
isOpened = capture.isOpened(); isOpened = capture.isOpened();
assertTrue(isOpened); assertTrue(isOpened);
...@@ -79,8 +77,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -79,8 +77,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testOpen() { public void testOpen() {
try try {
{
capture = new VideoCapture(); capture = new VideoCapture();
capture.open(Highgui.CV_CAP_ANDROID); capture.open(Highgui.CV_CAP_ANDROID);
isOpened = capture.isOpened(); isOpened = capture.isOpened();
...@@ -91,8 +88,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -91,8 +88,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testRead() { public void testRead() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
isSucceed = capture.read(dst); isSucceed = capture.read(dst);
assertTrue(isSucceed); assertTrue(isSucceed);
...@@ -104,8 +100,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -104,8 +100,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testRelease() { public void testRelease() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.release(); capture.release();
assertFalse(capture.isOpened()); assertFalse(capture.isOpened());
...@@ -116,8 +111,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -116,8 +111,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testRetrieveMat() { public void testRetrieveMat() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.grab(); capture.grab();
isSucceed = capture.retrieve(dst); isSucceed = capture.retrieve(dst);
...@@ -130,8 +124,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -130,8 +124,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testRetrieveMatInt() { public void testRetrieveMatInt() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.grab(); capture.grab();
isSucceed = capture.retrieve(dst, Highgui.CV_CAP_ANDROID_GREY_FRAME); isSucceed = capture.retrieve(dst, Highgui.CV_CAP_ANDROID_GREY_FRAME);
...@@ -144,8 +137,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -144,8 +137,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testSet() { public void testSet() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 640); capture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 480); capture.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 480);
...@@ -165,8 +157,7 @@ public class VideoCaptureTest extends OpenCVTestCase { ...@@ -165,8 +157,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
} }
public void testVideoCaptureInt() { public void testVideoCaptureInt() {
try try {
{
capture = new VideoCapture(Highgui.CV_CAP_ANDROID); capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
assertNotNull(capture); assertNotNull(capture);
assertTrue(capture.isOpened()); assertTrue(capture.isOpened());
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.samples.fd" package="org.opencv.samples.facedetect"
android:versionCode="21" android:versionCode="21"
android:versionName="2.1"> android:versionName="2.1">
......
...@@ -65,15 +65,15 @@ struct DetectorAgregator ...@@ -65,15 +65,15 @@ struct DetectorAgregator
} }
}; };
JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject
(JNIEnv * jenv, jclass, jstring jFileName, jint faceSize) (JNIEnv * jenv, jclass, jstring jFileName, jint faceSize)
{ {
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject enter"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject enter");
const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL); const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL);
string stdFileName(jnamestr); string stdFileName(jnamestr);
jlong result = 0; jlong result = 0;
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject");
try try
{ {
...@@ -98,18 +98,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeC ...@@ -98,18 +98,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeC
{ {
LOGD("nativeCreateObject catched unknown exception"); LOGD("nativeCreateObject catched unknown exception");
jclass je = jenv->FindClass("java/lang/Exception"); jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject(...)}"); jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject(...)}");
return 0; return 0;
} }
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject exit"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject exit");
return result; return result;
} }
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject
(JNIEnv * jenv, jclass, jlong thiz) (JNIEnv * jenv, jclass, jlong thiz)
{ {
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject");
try try
{ {
...@@ -131,15 +131,15 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe ...@@ -131,15 +131,15 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe
{ {
LOGD("nativeDestroyObject catched unknown exception"); LOGD("nativeDestroyObject catched unknown exception");
jclass je = jenv->FindClass("java/lang/Exception"); jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject(...)}"); jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject(...)}");
} }
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject exit"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject exit");
} }
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart
(JNIEnv * jenv, jclass, jlong thiz) (JNIEnv * jenv, jclass, jlong thiz)
{ {
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart");
try try
{ {
...@@ -157,15 +157,15 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt ...@@ -157,15 +157,15 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
{ {
LOGD("nativeStart catched unknown exception"); LOGD("nativeStart catched unknown exception");
jclass je = jenv->FindClass("java/lang/Exception"); jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart(...)}"); jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart(...)}");
} }
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart exit"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart exit");
} }
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop
(JNIEnv * jenv, jclass, jlong thiz) (JNIEnv * jenv, jclass, jlong thiz)
{ {
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop");
try try
{ {
...@@ -183,15 +183,15 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt ...@@ -183,15 +183,15 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
{ {
LOGD("nativeStop catched unknown exception"); LOGD("nativeStop catched unknown exception");
jclass je = jenv->FindClass("java/lang/Exception"); jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop(...)}"); jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop(...)}");
} }
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop exit"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop exit");
} }
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize
(JNIEnv * jenv, jclass, jlong thiz, jint faceSize) (JNIEnv * jenv, jclass, jlong thiz, jint faceSize)
{ {
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize -- BEGIN"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize -- BEGIN");
try try
{ {
...@@ -213,16 +213,16 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSe ...@@ -213,16 +213,16 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSe
{ {
LOGD("nativeSetFaceSize catched unknown exception"); LOGD("nativeSetFaceSize catched unknown exception");
jclass je = jenv->FindClass("java/lang/Exception"); jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize(...)}"); jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize(...)}");
} }
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize -- END"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize -- END");
} }
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect
(JNIEnv * jenv, jclass, jlong thiz, jlong imageGray, jlong faces) (JNIEnv * jenv, jclass, jlong thiz, jlong imageGray, jlong faces)
{ {
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect");
try try
{ {
...@@ -243,7 +243,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe ...@@ -243,7 +243,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe
{ {
LOGD("nativeDetect catched unknown exception"); LOGD("nativeDetect catched unknown exception");
jclass je = jenv->FindClass("java/lang/Exception"); jclass je = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect(...)}"); jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect(...)}");
} }
LOGD("Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect END"); LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect END");
} }
...@@ -12,7 +12,7 @@ extern "C" { ...@@ -12,7 +12,7 @@ extern "C" {
* Method: nativeCreateObject * Method: nativeCreateObject
* Signature: (Ljava/lang/String;F)J * Signature: (Ljava/lang/String;F)J
*/ */
JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject
(JNIEnv *, jclass, jstring, jint); (JNIEnv *, jclass, jstring, jint);
/* /*
...@@ -20,7 +20,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeC ...@@ -20,7 +20,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeC
* Method: nativeDestroyObject * Method: nativeDestroyObject
* Signature: (J)V * Signature: (J)V
*/ */
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject
(JNIEnv *, jclass, jlong); (JNIEnv *, jclass, jlong);
/* /*
...@@ -28,7 +28,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe ...@@ -28,7 +28,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe
* Method: nativeStart * Method: nativeStart
* Signature: (J)V * Signature: (J)V
*/ */
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart
(JNIEnv *, jclass, jlong); (JNIEnv *, jclass, jlong);
/* /*
...@@ -36,7 +36,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt ...@@ -36,7 +36,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
* Method: nativeStop * Method: nativeStop
* Signature: (J)V * Signature: (J)V
*/ */
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop
(JNIEnv *, jclass, jlong); (JNIEnv *, jclass, jlong);
/* /*
...@@ -44,7 +44,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt ...@@ -44,7 +44,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
* Method: nativeSetFaceSize * Method: nativeSetFaceSize
* Signature: (JI)V * Signature: (JI)V
*/ */
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize
(JNIEnv *, jclass, jlong, jint); (JNIEnv *, jclass, jlong, jint);
/* /*
...@@ -52,7 +52,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt ...@@ -52,7 +52,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
* Method: nativeDetect * Method: nativeDetect
* Signature: (JJJ)V * Signature: (JJJ)V
*/ */
JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect
(JNIEnv *, jclass, jlong, jlong, jlong); (JNIEnv *, jclass, jlong, jlong, jlong);
#ifdef __cplusplus #ifdef __cplusplus
......
package org.opencv.samples.fd; package org.opencv.samples.facedetect;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import org.opencv.core.MatOfRect; import org.opencv.core.MatOfRect;
......
package org.opencv.samples.fd; package org.opencv.samples.facedetect;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
......
package org.opencv.samples.fd; package org.opencv.samples.facedetect;
import java.text.DecimalFormat; import java.text.DecimalFormat;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment