OpenCV - native Android integration

风格不统一 提交于 2021-01-29 07:50:18

问题


I have been implemented this project: https://github.com/yaylas/AndroidFaceRecognizer into Android Studio - to my own App. I included OpenCV using tutorial: https://www.youtube.com/watch?v=OTw_GIQNbD8 (this is static initialization) and I created jni folder in src/main and I put these files https://github.com/yaylas/AndroidFaceRecognizer/tree/master/jni into it. This is Android.mk from this folder:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include C:/Users/Piotr/Desktop/Android_App/MyApplication/libraries/opencv/native/jni/OpenCV.mk
LOCAL_SRC_FILES  := DetectionAndRecognition.cpp
LOCAL_C_INCLUDES := C:/Users/Piotr/Desktop/Android_App/MyApplication/libraries/opencv/native/jni/include
LOCAL_LDLIBS     += -llog -ldl

LOCAL_MODULE     := detection_and_recognition_lib

include $(BUILD_SHARED_LIBRARY)

Problem is that, if I try compile project, Android Studio Say:

Error:(2, 33) opencv2/core/core.hpp: No such file or directory

Why it is?


回答1:


this bothers me for while as well, try adding the following:

// begin
sourceSets.main {
    jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
    commandLine "/your-library-folder/Android/sdk/ndk-bundle/ndk-build",
            'NDK_PROJECT_PATH=build/intermediates/ndk',
            'NDK_LIBS_OUT=src/main/jniLibs',
            'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
            'NDK_APPLICATION_MK=src/main/jni/Application.mk'
}
tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn ndkBuild
}
//end

into your build.gradle in app folder of your Android Studio project

reference: https://github.com/quanhua92/NDK_OpenCV_AndroidStudio



来源:https://stackoverflow.com/questions/33154716/opencv-native-android-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!