我正在使用OpenCV执行系统,以通过设备的摄像头检测对象。使用CascadeClassifier进行检测
问题在于,当我运行代码时,会出现以下错误:
Error:(12) undefined reference to `cv::CascadeClassifier::CascadeClassifier()'
Error:(27) undefined reference to `cv::CascadeClassifier::load(cv::String const&)'
Error:(61) undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
Error:(94) undefined reference to `cv::equalizeHist(cv::_InputArray const&, cv::_OutputArray const&)'
Error:(98) undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'
Error:(128) undefined reference to `cv::rectangle(cv::Mat&, cv::Rect_<int>, cv::Scalar_<double> const&, int, int, int)'
我的build.gradle:
android {
...
defaultConfig {
...
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
...
}
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
} ...
这是我的CMakeList.txt文件 cmake_minimum_required(VERSION 3.4.1)
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}")
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )
add_library( # Sets the name of the library.
Detector
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/Detector.cpp )
include_directories(/Users/###/Libs/OpenCV-SDK/sdk/native/jni/include)
add_library( lib-opencv SHARED IMPORTED )
set_target_properties(lib-opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
target_link_libraries( # Specifies the target library.
native-lib
# prebuilt library opencv java.
lib-opencv
# Links the target library to the log library
# included in the NDK.
${log-lib} )
任何人都有任何线索?感谢