- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在 Android 中使用 CMAKE 实现 OpenCV310。我同时使用 dlib 库和 OpenCV 库。 Example project github link
在这个 github 链接中,它调用了 Android NDK 上的 dlib 库中的 opencv 方法。我正在尝试用 CMAKE 自己实现这个项目。我尝试从一个简单的 native-lib.cpp 文件调用 openCV。它的工作。但是当我添加 dlib 时它开始给出错误。
Error:(571) undefined reference to 'cv::fastFree(void*)'
Error:(682) undefined reference to 'cv::Mat::deallocate()'
这是我的 CMAKE 文件。
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(pathToProject C:/Users/lenovo/AndroidStudioProjects/AdviserOpenCV3)
set(pathToOpenCV C:/Users/lenovo/Desktop/openCV310/OpenCV-3.1.0-android-sdk/OpenCV-android-sdk)
set(JNI_DETECTION_INCLUDE src/main/jni/jni_detections)
set(JNI_DETECTION_SRC src/main/jni/jni_detections)
set(JNI_COMMON_INCLUDE src/main/jni)
set(JNI_COMMON_SRC src/main/jni/jni_common)
set(DLIB_DIR src/main/dlib)
set(EXT_DIR src/main/third_party)
include_directories(${pathToOpenCV}/sdk/native/jni/include)
#include_directories(${DLIB_DIR} ${JNI_COMMON_INCLUDE} ${JNI_DETECTION_INCLUDE} include)
add_library( lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION
${pathToProject}/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)
add_library(android_dlib SHARED
${JNI_DETECTION_SRC}/jni_face_det.cpp
${JNI_DETECTION_SRC}/jni_imageutils.cpp
${JNI_DETECTION_SRC}/jni_pedestrian_det.cpp
${JNI_COMMON_SRC}/jni_bitmap2mat.cpp
${JNI_COMMON_SRC}/jni_fileutils.cpp
${JNI_COMMON_SRC}/jni_utils.cpp
${JNI_COMMON_SRC}/rgb2yuv.cpp
${JNI_COMMON_SRC}/yuv2rgb.cpp
${DLIB_DIR}/threads/threads_kernel_shared.cpp
${DLIB_DIR}/entropy_decoder/entropy_decoder_kernel_2.cpp
${DLIB_DIR}/base64/base64_kernel_1.cpp
${DLIB_DIR}/threads/threads_kernel_1.cpp
${DLIB_DIR}/threads/threads_kernel_2.cpp
${EXT_DIR}/glog/logging.cc)
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 )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
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 )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
android_dlib
lib_opencv
# Links the target library to the log library
# included in the NDK.
$\{log-lib} )
我该如何解决这个问题?感谢你的贡献。最好的问候,
最佳答案
您应该声明native-lib 和lib_opencv 之间的依赖关系。你可能也想要 android_dlib:
target_link_libraries(
native-lib
android_dlib
lib_opencv
# Links the target library to the log library
# included in the NDK.
log )
正如您在上面看到的,您的脚本中不需要${log-lib}; Android NDK 为您定义了日志库。
关于android - OpenCV Android 实现与 CMAKE undefined reference 'cv::fastFree(void*) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49981707/
我尝试使用 OpenCV 构建项目,我从官方网站下载了 OpenCV SDK 3.1,但是在构建过程中出现错误 /Users/Mario/Downloads/OpenCV-android-sdk/sd
在我更改了一些代码后,我在让 SWIG 包装器在 python 中工作时遇到了一些问题。我怀疑这与链接器有关。 我的问题是 this github :该文件按照自述文件中的描述进行编译,并且可以在 p
我有一个使用 OpenCV 的 C++ (ImageExtraction.cpp) 文件。这是 C++ 文件的快照。我想从我的 Android java 文件中调用这个 native C++ 文件。我
我在 Win8、最新的 MinGW 和 Eclipse Kepler R1、CDT 上开始了 opencv 2.4.7 的教程。 C++ 编译器包含引用 [path-to-opencv]\open24
我正在尝试让 C 程序调用使用 OpenCV 的 C++ 文件中的函数。我可以让 C 文件调用 C++ 文件中的基本整数函数并返回结果,但每当我尝试向 C++ 文件添加一些 OpenCV 代码时,我都
我正在尝试在 Android 中使用 CMAKE 实现 OpenCV310。我同时使用 dlib 库和 OpenCV 库。 Example project github link 在这个 github
我是一名优秀的程序员,十分优秀!