dlib-android

https://travis-ci.org/tzutalin/dlib-android

https://github.com/tzutalin/dlib-android-app

https://github.com/tzutalin/dlib-android

安卓之Android.mk多文件以及动态库编译

https://www.cnblogs.com/ywjfx/p/10004564.html

终极Android.mk模板,遍历头文件和源文件目录

https://blog.csdn.net/as929015918/article/details/78885094

build.txt

export ANDROID_NDK_HOME=/DATA/Android/Ndk/android-ndk-r13b
export PATH=$PATH:$ANDROID_NDK_HOME


Error:Could not find com.android.support:appcompat-v7:25.3.1.
Required by:
    project :app
    project :app > project :dlib

Please install the Android Support Repository from the Android SDK Manager.
<a href="openAndroidSdkManager">Open Android SDK Manager</a>



Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':dlib'.
      > Could not resolve all dependencies for configuration ':dlib:_debugPublishCopy'.
         > Could not find com.android.support:appcompat-v7:25.3.1.
           Required by:
               project :dlib
         > Could not find com.android.support:support-annotations:25.3.1.
           Required by:
               project :dlib


第一次编译步骤
./envsetup
python build.py
cp -r libs/* ../dlib-android-app/dlib/src/main/jniLibs

后面的编译
python build.py
或者ndk-build -j 2
cp -r libs/* ../dlib-android-app/dlib/src/main/jniLibs


libandroid_dlib.so

Readme

# dlib-android

[![Build Status](https://travis-ci.org/tzutalin/dlib-android.png)](https://travis-ci.org/tzutalin/dlib-android)

### Purpose
* Port [dlib](http://dlib.net/) to Android platform

* You can build it to dynamic or static library for Android. You can also build dlib's sample to Android executable file.

* You can refer to [dlib-android-app](https://github.com/tzutalin/dlib-android-app) which demonstrates dlib-android features

### Grab the source

$ git clone --recursive https://github.com/tzutalin/dlib-android.git
$ cd dlib-android
$ ./envsetup

### Prerequisites
* Download Android-NDK from [Android website](https://developer.android.com/ndk/downloads/index.html).

After downloading, go to the directory to which you downloaded the package to extract it

Export ANDROID_NDK_HOME in ~/.bashrc
`$ vim ~/.bashrc`

`export ANDROID_NDK_HOME=[NDK_PATH]/android-ndk-[version]`

`export PATH=$PATH:$ANDROID_NDK_HOME`

* Install Android Debug Bride (ADB). You can download it via [Android SDK Manager](https://developer.android.com/sdk/installing/index.html) or $ sudo apt-get install android-tools-adb

* Prepare an Android device for test

### Build JNI code and shared library for Android application
* You can change the compiler architecture in dlib-android/jni/Application.mk

* The way to build the shared library for Android application

```sh
$ cd [dlib-android]
$ python build.py
```

Alternative way to build native code and copy to the Android Studio's project manually:
```sh
$ cd [dlib-android]
$ ndk-build -j 2
$ cp -r libs/* androidstudio-examples/dlib-android-app/dlib/src/main/jniLibs
```

### Run Android application
* Open Android Studio's projects in androidstudio-examples/dlib-android-app to run face detection, face landmark, and so on

### Folder structure

```
├── data # Test data or the models for detection and landmarks
├── dlib # Source files of dlib. It is a submodule
├── jni # Source files of JNI codes and their make files
├── androidstudio-examples # Android Studio's projects use the shared library built by this repo
├── tools # Tools and utilities
├── third_party # Like OpenCV and [miniglog](https://github.com/tzutalin/miniglog)
├── CMakeLists.txt # Use CMake to build instead of using Android.mk
├── LICENSE
└── README.md
```

### Do you want to contribute
* If you have any improvement or you've found any bug, send a pull request with the code.
* Give me a star on this repository
* <a href='https://ko-fi.com/A4263TV2' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

### Future tasks
* Add more examples to [dlib-android-app](https://github.com/tzutalin/dlib-android-app)

CmakeList

cmake_minimum_required(VERSION 3.4.1)

message("Checking CMAKE_SYSTEM_NAME = '${CMAKE_SYSTEM_NAME}'")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  add_definitions(-DOS_OSX)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  add_definitions(-DOS_LINUX)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
  add_definitions(-DOS_WIN)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Android")
  add_definitions(-DOS_ANDROID)
  message("Checking CMAKE_ABI_NAME = '${CMAKE_ANDROID_ARCH_ABI}'")
else()
  message("OS not detected.")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")

## Define each subfolders
set(JNI_DETECTION_INCLUDE jni/jni_detections)
set(JNI_DETECTION_SRC jni/jni_detections)
set(JNI_COMMON_INCLUDE jni)
set(JNI_COMMON_SRC jni/jni_common)
set(DLIB_DIR dlib)
set(EXT_DIR third_party)
set(GLOG_INCLUDE_DIR ${EXT_DIR}/miniglog)
set(OPENCV_PREBUILT ${EXT_DIR}/OpenCV-android-sdk/sdk/native/jni)

# Opencv and it will use static import
set(ANDROID_NDK_ABI_NAME ${CMAKE_ANDROID_ARCH_ABI})
include(${OPENCV_PREBUILT}/OpenCVConfig.cmake)

# Include headers
include_directories(${DLIB_DIR} ${OpenCV_INCLUDE_DIRS} ${GLOG_INCLUDE_DIR} ${JNI_COMMON_INCLUDE} ${JNI_DETECTION_INCLUDE} include)

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}//dlib/threads/threads_kernel_shared.cpp
            ${DLIB_DIR}/dlib/entropy_decoder/entropy_decoder_kernel_2.cpp
            ${DLIB_DIR}/dlib/base64/base64_kernel_1.cpp
            ${DLIB_DIR}/dlib/threads/threads_kernel_1.cpp
            ${DLIB_DIR}/dlib/threads/threads_kernel_2.cpp
            ${EXT_DIR}/miniglog/glog/logging.cc)

target_link_libraries(android_dlib
                      android
                      jnigraphics
                      z
                      m
                      dl
                      log)
原文地址:https://www.cnblogs.com/adong7639/p/11335370.html