參考文章:
ubuntu安裝Dlib(C++與Python)
https://blog.csdn.net/sinat_38354963/article/details/90517321
ubuntu編譯使用Dlib、OpenCV
https://blog.csdn.net/qq_34106574/article/details/85626465
opencv之在Linux下編譯opencv程式的兩種方式g++、cmake(參考性較弱)
https://blog.csdn.net/keith_bb/article/details/52864851
ARM交叉編譯工具下載下傳、或已安裝
https://blog.csdn.net/baidu_38172402/article/details/82908838
ARM編譯Dlib、cmake 交叉編譯防坑指南
https://github.com/david8862/dlib_on_arm
https://blog.csdn.net/cloudybear/article/details/79237137
cmake編譯參數修改,aarch64版本,-mtune=cortex-a35
https://blog.csdn.net/yiran103/article/details/104065490
https://community.arm.com/cn/f/discussions/9924/neon--mfpu-neon-fpu-64bit
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/AArch64-Options.html#AArch64-Options
ubuntu下dlib編譯C++(共享庫)及使用,即cmake編譯dlib開源檔案的步驟和檔案結構(講解詳細,example編譯,好)
https://blog.csdn.net/QTVLC/article/details/83313208
dlib的gpu環境配置(python版)
https://blog.csdn.net/jixinpu/article/details/83010456
Dlib教程docs編譯(編不過,作者用dlib.net的,makedocs報錯)
make: sphinx-build: Command not found
https://blog.csdn.net/Will_Ye/article/details/106319473
linux中沒有dos2UNIX或者UNIX2dos指令怎麼解決辦法(sudo apt-get install dos2unix)
https://blog.csdn.net/w616589292/article/details/38274475/
makedocs前需安裝python版dlib(python setup.py install),下載下傳dlib-master進行編譯,代碼全
奉上我的編譯代碼:
ubuntu主機
編譯安裝Dlib
mkdir x64_build
cd x64_build
cmake .. -DUSE_AVX_INSTRUCTIONS=1
cmake --build . --config Release
sudo make install
sudo ldconfig
build.sh檔案
mkdir build
cd build
cmake ..
make -j8 #用make也行
CMakeLists.txt檔案
cmake_minimum_required(VERSION 2.8.4) #版本最小為2.8.4
PROJECT(dlib_facedetector) #設定工程名
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -DDLIB_JPEG_SUPPORT")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
ENDIF()
#INCLUDE OPENCV
FIND_PACKAGE(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
message(STATUS "Opencv include dir found at ${OpenCV_INCLUDE_DIRS}")
#包含頭檔案
INCLUDE_DIRECTORIES(/home/robert/DeepLearning/Dlib/dlib-19.19.0) #dlib根目錄位址
LINK_DIRECTORIES(/home/robert/DeepLearning/Dlib/dlib-19.19.0/x64_build/dlib/) #dlib編譯後bulid下dlib位址
#生産類似于.exe的可執行檔案
ADD_EXECUTABLE(${PROJECT_NAME} face_detection_dlib_hog.cpp)
#連結庫
TARGET_LINK_LIBRARIES(${PROJECT_NAME} dlib ${OpenCV_LIBS})
#TARGET_LINK_LIBRARIES(dlib_detector libjpeg.so)
ARM闆子編譯Dlib
build.sh檔案
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status.
BuildDir=dlib_build
if [ ! -d "$BuildDir" ]; then
# Take action if $BuildDir doesn‘t exists.
echo "create ${BuildDir}..."
mkdir -p ${BuildDir}
fi
cd ${BuildDir}
echo "building Dlib19.19.0"
export LD_LIBRARY_PATH=/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/usr/lib
source /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DBUILD_SHARED_LIBS=ON –build –config Release ..
make -j$(nproc)
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
get_directory_property(has_parent PERENT_DIRECTORY)
if(NOT has_parent)
set(DLIB_IN_PROJECT_BUILD false)
endif()
add_subdirectory(dlib)
toolchain.cmake
# this is required
SET(CMAKE_SYSTEM_NAME Linux)
# specify the cross compiler
SET(CMAKE_C_COMPILER /opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc)
SET(CMAKE_CXX_COMPILER /opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++)
SET(CMAKE_SYSROOT /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux)
# specify the compiler flag
SET(CMAKE_C_FLAGS -O3 -mtune=cortex-a35)
SET(CMAKE_CXX_FLAGS -std=c++11 -O3 -mtune=cortex-a35)
# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
ARM闆子使用Dlib
build.sh
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status.
BuildDir=dlib_build
if [ ! -d "$BuildDir" ]; then
# Take action if $BuildDir doesn‘t exists.
echo "create ${BuildDir}..."
mkdir -p ${BuildDir}
fi
cd ${BuildDir}
echo "building face_detection_dlib_hog.cpp"
export LD_LIBRARY_PATH=/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux/usr/lib
source /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
#ToolChain=/opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DBUILD_SHARED_LIBS=ON –build –config Release ..
make -j$(nproc)
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.4) #版本最小為2.8.4
PROJECT(dlib_facedetector) #設定工程名
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -DDLIB_JPEG_SUPPORT")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
ENDIF()
#INCLUDE OPENCV
FIND_PACKAGE(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
message(STATUS "Opencv include dir found at ${OpenCV_INCLUDE_DIRS}")
#包含頭檔案
INCLUDE_DIRECTORIES(/home/robert/DeepLearning/NXP-imx8QX/CompileResult/dlib-19.19.0) #dlib根目錄位址
LINK_DIRECTORIES(/home/robert/DeepLearning/NXP-imx8QX/CompileResult/dlib-19.19.0/dlib_build/dlib/) #dlib編譯後bulid下dlib位址
#生産類似于.exe的可執行檔案
ADD_EXECUTABLE(${PROJECT_NAME} face_detection_dlib_hog.cpp)
#連結庫
TARGET_LINK_LIBRARIES(${PROJECT_NAME} dlib ${OpenCV_LIBS})
#TARGET_LINK_LIBRARIES(dlib_detector libjpeg.so)
toolchain.cmake
# this is required
SET(CMAKE_SYSTEM_NAME Linux)
# specify the cross compiler
SET(CMAKE_C_COMPILER /opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc)
SET(CMAKE_CXX_COMPILER /opt/fsl-imx-xwayland/4.14-sumo/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++)
SET(CMAKE_SYSROOT /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux)
# specify the compiler flag
SET(CMAKE_C_FLAGS -O3 -mtune=cortex-a35)
SET(CMAKE_CXX_FLAGS -std=c++11 -O3 -mtune=cortex-a35)
# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)