我正在创建一个小项目,以测试在Android Studio 1.4上使用opencv(2.4)的功能,但当我尝试执行应用程序时,我遇到了NDK编译器的一个问题。我认为cpp文件找不到opencv的路径,但我不知道为什么。
有没有想法如何解决这个问题?
错误:
/home/User/AndroidStudioProjects/OpenCV/app/src/main/jni/native_processing.h Error:(10, 33) opencv2/core/core.hpp: No such file or directory
JNI:
OpenCV/app/src/main/jni/native_processing.cpp OpenCV/app/src/main/jni/native_processing.h
有没有想法如何解决这个问题?
错误:
/home/User/AndroidStudioProjects/OpenCV/app/src/main/jni/native_processing.h Error:(10, 33) opencv2/core/core.hpp: No such file or directory
JNI:
OpenCV/app/src/main/jni/native_processing.cpp OpenCV/app/src/main/jni/native_processing.h
#ifndef OPENCV_SAMPLE_NATIVE_PROCESSING_H
#define OPENCV_SAMPLE_NATIVE_PROCESSING_H
#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <vector>
extern "C" {
JNIEXPORT void JNICALL Java_com_projeto_opencv_MainActivity_FindFeatures(JNIEnv *, jobject,
jlong addrGray,
jlong addrRgba);
}
#endif
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=STATIC
PENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include /home/User/AndroidStudioProjects/OpenCV/OpenCV-android-sdk2/sdk/native/jni/OpenCV.mk
LOCAL_C_INCLUDE :=/home/User/Download/OpenCV-android-sdk2/sdk/native/jni/include
LOCAL_SRC_FILES := native_processing.cpp
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE:= native_test
include $(BUILD_SHARED_LIBRARY)
Error: Warning:Native C/C++ source code is found, but it seems that
NDK option is not configured. Note that if you have an Android.mk, it is
not used for compilation. The recommended workaround is to remove the
default jni source code directory by adding:
android {
sourceSets {
main {
jni.srcDirs = []
}
}
}
to build.gradle, manually compile the code with ndk-build, and then
place the resulting shared object in src/main/jniLibs.
/home/User/AndroidStudioProjects/OpenCV/app/src/main/jni/native_processing.cpp
Information:(1) (Unknown) In file included
/home/User/AndroidStudioProjects/OpenCV/app/src/main/jni/native_processing.h
Error:(10, 33) opencv2/core/core.hpp: No such file or directory
compilation terminated.
make: ***
[/home/User/AndroidStudioProjects/OpenCV/app/build/intermediates/ndk/debug/obj/local/arm64-v8a/objs/app//home/geison/AndroidStudioProjects/OpenCV/app/src/main/jni/native_processing.o] Error 1
:app:compileDebugNdk FAILED
Error:Execution failed for task ':app:compileDebugNdk'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/User/Android/Sdk/ndk-bundle/ndk-build'' finished with non-zero exit value 2