The Python witness comparison model has recently been ported to Android. Android requires the use of OpenCV simple portrait extraction processing. Before configuring OPENCV, you need to configure the NDK environment first.
Introduction to the NDK (http://www.cnblogs.com/leaven/archive/2010/05/27/1744855.html)
An NDK in Ubuntu configuration
Reference: http://blog.csdn.net/jq_ak47/article/details/52349189
The configuration of the two ndk in IntelliJ idea
Reference: http://blog.csdn.net/yipatshi/article/details/54585049
Three NDK development examples
Reference: http://www.cnblogs.com/xiaoxiaoqingyi/p/6524165.html
Create a Ndkutils.java class under Main/java:
Public class ndkutils { publicnative String invokecmethod (); Static { system.loadlibrary ("ndkutils");} }
Right-click External Tools---> Javah
A com_lemon_demo_utils_ndkutils.h file in the JNI directory and directory will be generated in the app directory
Copy the. h file to modify the suffix named. C (the file is the C language implementation file)
Modify COM_LEMON_DEMO_UTILS_NDKUTILS.C Content:
jniexport jstring jnicall java_com_lemon_demo_utils_ndkutils_jniinit *env, Jobject obj) { return (*env)->newstringutf (env, "NDK acquires native string"); }
Copy the JNI directory to the Main/java directory.
Create new Android.mk and APPLICATION.MK under the JNI directory:
ANDROID.MK:
local_path:=$ (call my-dir) include $ (clear_vars) Local_module:= ndkutilslocal_src_files:= com_ Lemon_demo_utils_ndkutils.cinclude $ (build_shared_library)
APPLICATION.MK:
App_platform: = android-23App_abi:= Armeabi
The command window for IntelliJ idea (Terminal) executes:
CD app/src/main/
Continue typing:
Ndk-build
The command is to compile the C file and then generate the. so file, which is generated in the App\src\main\libs directory.
After completion, the Libs and obj two directories are generated in the main directory.
Configure the Build.gradle file to add in Android {}:
sourcesets{ main{ // Disable automatic ndk-build call, which ignore our android.mk< /c5> jnilibs.srcdir ' src/main/libs ' } }
Used in mainactivity:
PackageCom.lemoncome.opencvdemo;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;ImportAndroid.widget.TextView; Public classMainopencvactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.LAYOUT.ACTIVITY_MAIN_OPENCV); Ndkutils NDK=Newndkutils (); TextView text=(TextView) Findviewbyid (r.id.tv); Text.settext (Ndk.invokecmethod ()); }}
Run the program output string: NDK gets native string
The above test was successful.
Four ANDROID+OPENCV
First download OPENCV package, Address: http://opencv.org/
The latest 3.3, I downloaded 3.2
OPENCV Configuration Reference: http://www.cnblogs.com/xiaoxiaoqingyi/p/6676096.html
Copy the Sdk/native directory to the JNI directory of the project,
Ubuntu+intellij idea+android Configuring the NDK environment +OPENCV