Follow the instructions on the following link.
NOTICE: When creating the new project, on the C++ Support tab, select C++11
from the dropdown.
Link: https://github.com/leadrien/opencv_native_androidstudio#how-to-create-the-native-opencv-project-from-scratch
The most recent version of dlib seems to have problems on Android, download version 19.1
.
Uzip the downloaded dlib zip file to your-project-name/app
. You should now have a dlib-19.1
folder there.
Add after the line set_target_properties( lib_opencv .....
:
set(DLIB_DIR dlib-19.1)
include_directories(${DLIB_DIR} include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
Add inside add_library
, after src/main/cpp/native-lib.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
Notice that dlib will be slow if you compile in Debug mode, I suggest compiling in Release mode.