menyusun dlib dan opencv dengan android ndk

bendaf 07/28/2017. 1 answers, 983 views
android android build android-ndk dlib android-studio-2.3

Saya seorang pemaju android, tetapi saya baru untuk Android NDK, tolong bantu, atau beritahu saya apa lagi yang anda perlukan / bagaimana anda akan cuba menyelesaikan masalah jenis ini.

Saya menggunakan dlib ini untuk contoh android dan opencv rasmi untuk pustaka android dan saya ingin menyatukan kedua dalam satu aplikasi. Apabila saya cuba membina projek saya mendapat ralat berikut:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':openCVSamplefacedetection:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /home/feli/Android/Sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Android.mk NDK_APPLICATION_MK=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Application.mk APP_ABI=mips64 NDK_ALL_ABIS=mips64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/lib /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/libdetection_based_tracker.so}
  [mips64] Compile++      : detection_based_tracker <= DetectionBasedTracker_jni.cpp
  [mips64] Prebuilt       : libopencv_java3.so <= /home/feli/Android/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/mips64/
  [mips64] SharedLibrary  : libdetection_based_tracker.so
  /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/objs-debug/detection_based_tracker/DetectionBasedTracker_jni.o: In function `dlib_check_consistent_assert_usage':
  /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/threads/threads_kernel_shared.h:44: undefined reference to `USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/libdetection_based_tracker.so] Error 1


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

Tangkapan pertama saya adalah bahawa saya tidak termasuk sumber.cpp dalam Android.mk saya tetapi meletakkannya ke fail src tidak menyelesaikan porblem. Berikut adalah Android.mk saya:

LOCAL_PATH := $(call my-dir)

## Build dlib to static library
include $(CLEAR_VARS)
LOCAL_MODULE := dlib
LOCAL_C_INCLUDES := $(LOCAL_PATH)/dlib

LOCAL_SRC_FILES += \
                $(LOCAL_PATH)/dlib/dlib/all/source.cpp \
                $(LOCAL_PATH)/dlib//dlib/threads/threads_kernel_shared.cpp \
                $(LOCAL_PATH)/dlib/dlib/entropy_decoder/entropy_decoder_kernel_2.cpp \
                $(LOCAL_PATH)/dlib/dlib/base64/base64_kernel_1.cpp \
                $(LOCAL_PATH)/dlib/dlib/threads/threads_kernel_1.cpp \
                $(LOCAL_PATH)/dlib/dlib/threads/threads_kernel_2.cpp

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)

# Build opencv
include $(CLEAR_VARS)
OPENCVROOT := ~/Android/openCV/OpenCV-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE := SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_MODULE     := detection_based_tracker
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_SRC_FILES  := DetectionBasedTracker_jni.cpp

LOCAL_LDLIBS     += -lm -llog -ldl -lz -ljnigraphics
LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11

# LOCAL_STATIC_LIBRARIES += dlib

include $(BUILD_SHARED_LIBRARY) 

Mungkin NDK_PROJECT_PATH=null adalah masalahnya? Daripada mengapa kedua perpustakaan membina secara berasingan? Atau apa lagi masalahnya? Saya cuba banyak mengubah Android.mk, tetapi ia berfungsi adalah misteri untuk saya. Sebarang bantuan atau pendapat akan berguna.

EDIT:

Apabila saya mengulas LOCAL_STATIC_LIBRARIES += dlib , saya mendapat pengecualian berikut:

Build command failed.
  Error while executing process /home/feli/Android/Sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Android.mk NDK_APPLICATION_MK=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Application.mk APP_ABI=mips64 NDK_ALL_ABIS=mips64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/lib /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/libdetection_based_tracker.so}
  [mips64] Compile++      : detection_based_tracker <= DetectionBasedTracker_jni.cpp
  [mips64] Compile++      : dlib <= source.cpp
  In file included from /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/source.cpp:76:
  In file included from /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/../gui_widgets/fonts.cpp:14:
  /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/../gui_widgets/nativefont.h:27:10: fatal error: 'X11/Xlib.h' file not found
  #include            ^~~~~~~~~~~~
  1 error generated.
  make: *** [/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/objs-debug/dlib//home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/source.o] Error 1 

1 Answers


Alex Cohn 07/31/2017.

dlib menggunakan cmake , dan ia bukan persediaan remeh. Ia mungkin mengambil masa yang lama untuk pengalaman profesional untuk menyediakan skrip ndk-build untuk perpustakaan ini.

Saya cadangkan anda membina perpustakaan asli anda dengan cmake , bukan cmake ndk-build . Anda boleh mencari contoh perpustakaan asli yang menggunakan OpenCv pada GitHub .

Juga, saya cadangkan anda memulakan dengan abiFilters ditetapkan hanya satu ABI yang paling sesuai, dan hanya apabila anda melihat bahawa semuanya berfungsi untuk anda, anda boleh membina projek anda untuk ABI yang lain. Ingat bahawa untuk beberapa perpustakaan yang berpindah ke semua ABI mungkin sukar. Dan jika anda tidak mempunyai platform untuk melakukan sekurang-kurangnya pemeriksaan kewarasan ringkas untuk beberapa ABI, tidak ada rasa untuk membinanya.


HighResolutionMusic.com - Download Hi-Res Songs

1 Alan Walker

Different World flac

Alan Walker. 2018. Writer: Alan Walker;Fredrik Borch Olsen;James Njie;Marcus Arnbekk;Gunnar Greve Pettersen;K-391;Corsak;Shy Martin;Magnus Bertelsen.
2 Ariana Grande

​Thank U, Next flac

Ariana Grande. 2018. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
3 Mesto

Wait Another Day flac

Mesto. 2018.
4 Anne-Marie

Rewrite The Stars flac

Anne-Marie. 2018. Writer: Benj Pasek;Justin Paul.
5 Conor Maynard

How You Love Me flac

Conor Maynard. 2018. Writer: Yoshi Breen;Thom Bridges;Hardwell;Rik Annema;Conor Maynard;Cimo Fränkel;Snoop Dogg.
6 Rita Ora

Let You Love Me flac

Rita Ora. 2018. Writer: Rita Ora;Easyfun;Fred Gibson;Noonie Bao;LotusIV;Ilsey Juber.
7 Fitz And The Tantrums

HandClap flac

Fitz And The Tantrums. 2017. Writer: Fitz And The Tantrums;Eric Frederic;Sam Hollander.
8 Clean Bandit

Baby flac

Clean Bandit. 2018. Writer: Jack Patterson;Kamille;Jason Evigan;Matthew Knott;Marina;Luis Fonsi.
9 (G)I-DLE

POP/STARS flac

(G)I-DLE. 2018. Writer: Riot Music Team;Harloe.
10 Mark Ronson

Nothing Breaks Like A Heart flac

Mark Ronson. 2018. Writer: Thomas Brenneck;Maxime Picard;Ilsey Juber;Conor Szymanski;Clement Picard;Mark Ronson;Miley Cyrus.
11 ZAYN

Good Years flac

ZAYN. 2018. Writer: Anthony Hannides;Michael George Hannides;Khaled Rohaim;ZAYN;Herbie Crichlow.
12 Ava Max

Sweet But Psycho flac

Ava Max. 2018. Writer: Ava Max;TIX;Cirkut;Madison Love;Cook Classics.
13 Imagine Dragons

Bad Liar flac

Imagine Dragons. 2018. Writer: Jorgen Odegard;Daniel Platzman;Ben McKee;Wayne Sermon;Aja Volkman;Dan Reynolds.
14 Cmc

As Long As I'm With You flac

Cmc. 2018.
15 The Chainsmokers

Beach House flac

The Chainsmokers. 2018. Writer: Andrew Taggart.
16 Clean Bandit

Mama flac

Clean Bandit. 2018. Writer: Jason Evigan;Jack Patterson;Grace Chatto;Ellie Goulding;Caroline Ailin.
17 Cat Dealers

My Way flac

Cat Dealers. 2018.
18 Big Boi

Out At Night flac

Big Boi. 2018. Writer: Jack Patterson;John Ryan;Julian Bunetta;Big Boi.
19 Martin Garrix

Dreamer (Nicky Romero Remix) flac

Martin Garrix. 2018. Writer: Yury Parkhomenko;Aleksandr Parkhomenko;Ilsey Juber;Brian Lee;Mike Yung;Martin Garrix.
20 Bhad Bhabie

Playboy Style flac

Bhad Bhabie. 2018. Writer: Jack Patterson;Grace Chatto;Bhad Bhabie;George Astasio;Jason Pebworth;Jon Shave;Ryan Alan;Alex Oriet;David Phelan.

Related questions

Hot questions

Language

Popular Tags