Now, we have successfully build on mac os and centos, using Android NDK
- Host machine: linux, mac
- cmake 3.8.2+
- Android NDK r14, download linux version from here
- 2.1 protobuf3.4.0
Download source from https://github.com/google/protobuf/releases/tag/v3.4.0 - 2.1.1 Build protobuf for host
$ tar -xzf protobuf-3.4.0.tar.gz
$ cd protobuf-3.4.0
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ make install
for details, please refer here
- 2.1.2 Build protobuf for ARM
armeabi-v7a
Set your protobuf path here, search anakin_find_protobuf
, and set ARM_RPOTO_ROOT
to your path.
set(ARM_RPOTO_ROOT "${CMAKE_SOURCE_DIR}/third-party/arm-android/protobuf")
- 2.2 opencv 2.4.3+(optional)
We only use opencv in examples
For Android, visit opencv release page, choose Android pack and download, copy libs in3rdparty/libs/armeabi-v7a
tolibs/armeabi-v7a
.
Set your opencv path here, Searchanakin_find_opencv
, and setinclude_directories
andLINK_DIRECTORIES
according to your path.include_directories(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/jni/include/) LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/libs/armeabi-v7a/)
clone the source code
cd your_dir
git clone https://github.com/PaddlePaddle/Anakin.git
cd Anakin
git fetch origin arm
git checkout arm
change the android_build.sh
-
Set NDK path to yours
#modify "your_ndk_path" to your NDK path export ANDROID_NDK=your_ndk_path
-
Set your ARM target platform
For 32bits ARM CPU with NEON, Set ANDROID_ABI to
armeabi-v7a with NEON
, for 64bits ARM CPU, eitherarm64-v8a
orarmeabi-v7a with NEON
can work.
Now, we only supportarmeabi-v7a with NEON
,arm64-v8a
is under developing-DANDROID_ABI="armeabi-v7a with NEON"
-
Set Android API level
Choose your API LEVEL according to your android system version
API Level 21 -> Android 5.0.1-DANDROID_NATIVE_API_LEVEL=21
-
build static or shared lib
if building static lib, setBUILD_SHARED=NO
if building shared lib, setBUILD_SHARED=YES
-DBUILD_SHARED=NO
-
OpenMP for multi-threads
setUSE_OPENMP=YES
to use OpenMP multi-threads-DUSE_OPENMP=YES
-
build unit test
setBUILD_WITH_UNIT_TEST=YES
to build unit tests-DBUILD_WITH_UNIT_TEST=YES
-
build examples
setBUILD_EXAMPLES=YES
to build detection and classification examples-DBUILD_EXAMPLES=YES
-
use opencv in examples
setUSE_OPENCV=YES
to use opencv in examples-DUSE_OPENCV=YES
-
build
runandroid_build.sh
to build the Anakin./android_build.sh
The libs is in ${Anakin_root}/output
, the unit test and benchmark file is in ${Anakin_root}/output/unit_test
and the examples is in ${Anakin_root}/output/examples
Open USB debug mode
in your Android device, Use ADB to push the test files and model files to data/local/tmp/your_dir
run the test