OpenCV NDK Link library

Viewed 384

I am performing a system with OpenCV for the detection of objects through the camera of the device. Using CascadeClassifier for detection

The problem is that when I run my code the following errors appear:

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)'

My build.gradle:

android {
...
defaultConfig {
    ...
    externalNativeBuild {
        cmake {
            cppFlags ""
        }
    }
}
buildTypes {
    ...
}
sourceSets {
    main {
        jni.srcDirs = []
        jniLibs.srcDirs = ['src/main/jniLibs']
    }
}
externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
} ...

This is my CMakeList.txt file 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} )

Anyone has any clue? Thanks

0 Answers
Related