Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 2.24 KB

README.md

File metadata and controls

48 lines (39 loc) · 2.24 KB

Dlib-for-Android

Compile and embed Dlib (and, optionally OpenCV) in your Android projects with ease.

Prerequisites

From AndroidStudio at tool > SDK Manager > SDK Tools install:

  • LLDB
  • CMake
  • NDK.

Usage

  1. Clone the repo recursively (to download Dlib).
  2. Create an Android project with c++11 support.
  3. Edit the setup.sh (Linux user) or setup.ps1 (Windows user) script:
    • Replace AndroidCmake variable with the path to your Android CMake excutable (is usually inside the android sdk folder).
    • Replace NDK variable with the path to your Android NDK (ndk-bundle).
    • Replace TOOLCHAIN variable with the path to your android.toolchain.cmake.
    • Select the ABIs you want to support among: armeabi-v7a, arm64-v8a, x86 and x86_64.
    • Edit the MIN_SDK value, the minimum supported is 16.
    • Set the PROJECT_PATH variable according to your Android project path.
  4. Launch the script and wait until completion (comment what you don't need!). It will:
    • Compile Dlib for multiple ABI,
    • Copy the Dlib headers and libdlib.so to your project,
    • Copy the lib_opencv4.so to your project.
  5. Edit your CMakeLists like this one.
  6. Update your build.gradle (app) file in order to support CMake example.
  7. Build and Enjoy!

A complete tutorial is available here.

Examples

On my github you can find here, a complete Android application that uses Dlib and OpenCV 4.

Prebuilt library

Inside the folder prebuilt you can find a set of ready-to-use libdlib.so, compiled from Dlib 19.16 source code.

The .so are built for the ABIs: armeabi-v7a, arm64-v8a, x86 and x86_64; with a 16 as min-sdk.

Troubleshooting

For Windows users: If the PowerShell complains about the script you can try this:

1. Open the Windows PowerShell
2. Move to the script location
3. type and execute: powershell -ExecutionPolicy ByPass -File setup.ps1

Warning

Bash script NOT TESTED!!