Using an Unoccupied OpenCV Module in Android

I am trying to use an insecure module with OpenCV on Android. I am following this answer https://stackoverflow.com/a/2126162/2326 , but I have a hard time understanding it since this is my first app with Android and NDK.

At the moment, OpenCV (without proprietary) is working on my application, and I use it in C ++ code with NDK and JNI. I am having problems editing my current Android.mk and Application.mk files in response to compilation without crashes.

Here are my Android.mk and Application.mk files with the structure of my project.

Android.mk:

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) #opencv OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk OPENCV_CAMERA_MODULES:=on OPENCV_INSTALL_MODULES:=on OPENCV_LIB_TYPE:=SHARED include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp LOCAL_LDLIBS += -llog LOCAL_MODULE := MyOpencvLibs include $(BUILD_SHARED_LIBRARY) 

Application.mk:

 APP_STL := gnustl_static APP_CPPFLAGS := -frtti -fexceptions APP_ABI := armeabi-v7a APP_PLATFORM := android-16 

Project Structure: enter image description here

My project crashes with the line #include <opencv2/nonfree/nonfree.hpp> in my jni.h file, so I'm trying to import a non-free module.

So, as I said, I am trying to fulfill the answer linked above, but I have problems.

In the answer:

Creating a proprietary module:

Step 1: I just copy the files.

Step 2: I do not understand where I should create this folder, in my application or on my computer?

Step 3: Here is the big problem, I don’t know how I can combine the Android.mk and Application.mk files provided in response to mine. Also, I don't understand the line " cd in the libnonfree project libnonfree and type ndk-build to build libnonfree.so. "

To “create an example application” I have not been to this part yet, but I figured I did not need to do this. I can just use OpenCV with my application, except that the line #include <opencv2/nonfree/nonfree.hpp> will work.

I tried to make this question clear, if you need more information, I will gladly edit it.

+1
java c ++ android opencv android-ndk
source share
1 answer

Step 2: Create a folder in the jniLibs file or place the file 4 directly.

Step 3:

 LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) #opencv OPENCVROOT:= C:\OpenCV-2.4.10-android-sdk OPENCV_CAMERA_MODULES:=on OPENCV_INSTALL_MODULES:=on OPENCV_LIB_TYPE:=SHARED include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk LOCAL_SRC_FILES := com_example_adrien_ndkopencvtest4_OpencvNativeClass.cpp LOCAL_LDLIBS += -llog LOCAL_MODULE := MyOpencvLibs include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_C_INCLUDES:= ${OPENCVROOT}/sdk/native/jni/include LOCAL_MODULE := nonfree LOCAL_CFLAGS := -Werror -O3 -ffast-math LOCAL_LDLIBS += -llog # for 2.4.8, delete the line precomp.cpp \ LOCAL_SRC_FILES := nonfree_init.cpp \ sift.cpp \ surf.cpp include $(BUILD_SHARED_LIBRARY) 

and you can find how to add an external tool to android studio (ndk-build)

+1
source share

All Articles