2016-10-02 2 views
2

Ich kann mein Projekt zu öffnen OpenCV die Header-Dateien nicht erhalten:Wie referenziere ich hpp-Dateien für OpenCV mit NDK?

enter image description here

Allerdings kann ich sehen, dass OpenCV gut läuft durch den Aufruf OpenCVLoader.initDebug() (wenn ich diejenigen enthält auf Kommentar) in onCreate():

enter image description here

I read, die Sie Android.mk bearbeiten müssen, die ich in erster Linie nicht haben. Also was fehlt mir?


EDIT (3 Stunden später):

Ok, also ich herausgefunden, wie .hpp Dateien, die ich dies von CMakeLists.txt bis zum Ende hinzugefügt sind:

include_directories("${CMAKE_SOURCE_DIR}/include" 
    "${CMAKE_SOURCE_DIR}/include/opencv" 
    "${CMAKE_SOURCE_DIR}/include/opencv2" 
    "${CMAKE_SOURCE_DIR}/include/opencv2/core" 
    "${CMAKE_SOURCE_DIR}/include/opencv2/features2d" 
    "${CMAKE_SOURCE_DIR}/include/opencv2/imgproc") 

    add_library(opencv_core STATIC IMPORTED) 
    set_target_properties(opencv_core PROPERTIES 
     IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/prebuilt/libs/armeabi/libopencv_core.a) 

    add_library(opencv_imgproc STATIC IMPORTED) 
    set_target_properties(opencv_imgproc PROPERTIES 
     IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/prebuilt/libs/armeabi/libopencv_imgproc.a) 

    add_library(opencv_features2d STATIC IMPORTED) 
    set_target_properties(opencv_features2d PROPERTIES 
     IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/prebuilt/libs/armeabi/libopencv_features2d.a) 

I Now erhalten undefined reference Fehler beim Verknüpfen:

> Build command failed. 
Error while executing 'C:\Users\kfjier\AppData\Local\Android\sdk\cmake\3.6.3155560\bin\cmake.exe' with arguments {--build E:\Dropbox\Freelance\BowlingOpenCV\Bowlingtrainer\app\.externalNativeBuild\cmake\debug\mips64 --target native-lib} 
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o 
[2/2] Linking CXX shared library ..\obj\mips64\libnative-lib.so 
FAILED: cmd.exe /C "cd . && C:\Users\kfjier\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe -target mips64el-none-linux-android -gcc-toolchain C:/Users/kfjier/AppData/Local/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/kfjier/AppData/Local/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64 -fPIC -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -O0 -fno-limit-debug-info -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ..\obj\mips64\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o -llog -lm "C:/Users/kfjier/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/libgnustl_static.a" && cd ." 
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o: In function `Java_eu_codehunter_bowlingtrainer_MainActivity_FindFeatures': 
    E:\Dropbox\Freelance\BowlingOpenCV\Bowlingtrainer\app\src\main\cpp/native-lib.cpp:18: undefined reference to `cv::FastFeatureDetector::create(int, bool, int)' 
    E:\Dropbox\Freelance\BowlingOpenCV\Bowlingtrainer\app\src\main\cpp/native-lib.cpp:19: undefined reference to `cv::noArray()' 
    E:\Dropbox\Freelance\BowlingOpenCV\Bowlingtrainer\app\src\main\cpp/native-lib.cpp:23: undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)' 
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation) 
    ninja: build stopped: subcommand failed. 

Warum?

Antwort

0

Ich denke, die cv :: FastFeatureDetector Klasse gehört zu libopencv_features2d.a und cv :: circle() -Funktion gehört zu libopencv_highgui.a. Sie müssen also diese Bibliotheken einbeziehen. Ein einfacherer Weg besteht darin, einzelne libopencv_java3.so als gemeinsam genutzte Bibliothek hinzuzufügen, die alle OpenCV-Bibliotheken enthält.

Verwandte Themen