2015-10-15 50 views
0

我已經實現了這個項目:https://github.com/yaylas/AndroidFaceRecognizer到Android Studio - 我自己的應用程序。我使用教程:https://www.youtube.com/watch?v=OTw_GIQNbD8(這是靜態初始化)包含OpenCV,並且我在src/main中創建了jni文件夾,並且將這些文件放入其中https://github.com/yaylas/AndroidFaceRecognizer/tree/master/jni。 這是Android.mk從該文件夾:OpenCV - 原生Android集成

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) 

問題是,如果我嘗試編譯項目,Android Studio中說:

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

爲什麼它是什麼?

回答

0

這個困擾我了,同時還有,嘗試添加以下內容:

// 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 

到您的build.gradle在你的Android Studio項目的app文件夾

參考:https://github.com/quanhua92/NDK_OpenCV_AndroidStudio