Skip to content

Latest commit

 

History

History
 
 

android

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Android Support

Mini-Caffe now can be corss compiled for Android platform.

Prerequisites

  1. You need to download Android NDK here first. Or if you use Android Studio, you can download Android NDK through SDK Manager.
  2. Set up environment variable NDK_ROOT for Android NDK. NDK_ROOT=/path/to/ndk, if you use Windows, make sure to replace path separator \ to /.
  3. If you use Windows, you also need the GNU toolchain. Usually tdm-gcc should be fine. Download 64bit version of tdm-gcc like tdmgcc64-gcc-x.x.x.exe in the download page. You also need a shell environment to run the build. Usually Git for Windows ship with Git Bash should be fine. IMPORTANT, you need to copy and rename /path/to/TDM-GCC-64/bin/mingw32-make.exe to /path/to/TDM-GCC-64/bin/make.exe.

Build

Run build.sh will automatically cross compile Mini-Caffe and libraries(protobuf and OpenBLAS) it relies on. The default build option is listed below, currently you can directly change them in build.sh file.

ANDROID_NATIVE_API_LEVEL=21  # android native api level
ANDROID_BUILD_JOBS=2  # threads to build
ANDROID_ABIS=(arm64-v8a armeabi x86 x86_64)  # android abi to build

build.sh is tested on Ubuntu 16.04 with Android NDK r13b, Windows 10 with tdmgcc64-gcc-5.1.0-2.exe and Android NDK r12b.

Result

Every library will create a build folder for every ANDROID_ABI. Mini-Caffe output libcaffe.so will be in jniLibs.

How to use libcaffe.so

I have modify Leliana/WhatsThis which uses MXNet as backend. Make Mini-Caffe as its backend, checkout project luoyetx/WhatsThis. What's more, you also need to checkout the Java API here.