在CLion下使用Dlib進行人臉檢測+识别
首先編譯Dlib
linux 环境 ubuntu18.04 64位 gcc4.8.1及以上
- 用cmake编译静态库 要用release版,计算效率快
1. cd dlib-19.17
2. mkdir build
3. cd build
4. cmake ..
5. cmake --build .
6. 会在build/dlib/Release目录生成静态链接库libdlib.a
7. 将build/dlib/config.h文件拷贝到源码目录dlib-19.17/dlib进行覆盖
第7步非常重要,解决调用dlib时USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2这个报错
在CLion 上使用DLib
target_link_libraries(TestDlib /opt/Devs/dlib/lib/libdlib.a
/usr/local/jpeg9/lib/libjpeg.so
-lX11
-lpng
-llapack
-lblas
)
期間會出現如下錯誤
exception thrown!
Unable to load image in file /home/z/data/myface/25.jpg.
You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG files.
Do this by following the instructions at http://dlib.net/compile.html.
Note that you must cause DLIB_JPEG_SUPPORT to be defined for your entire project.
So don't #define it in one file. Instead, use a compiler switch like
-DDLIB_JPEG_SUPPORT so it takes effect for your entire application.
CMakeLists.txt上面添加
set(DDLIB_JPEG_SUPPORT ON)
出現 undefined reference to `dgesvd’_ 錯誤
添加編譯選項 -llapack
出錯 undefined reference to `cblas*"_
添加編譯選項 -lblas
出錯 Wrong JPEG library version: library is 80, caller expects 90
建議重新安裝一個,幷將這個jpeg安裝到 /usr/local/jpeg9文件夾
jpeg9下載鏈接 jpeg9
解壓
cd jpeg-9c
./configure --prefix=/usr/local
make
sudo make install
如要卸载
sudo make uninstall
百度人臉識別和Dlib的交叉使用
/usr/lib/x86_64-linux-gnu/liblapack.so: undefined reference to `dtrti2_LN'
/usr/lib/x86_64-linux-gnu/liblapack.so: undefined reference to `dgetf2_k'
/usr/lib/x86_64-linux-gnu/liblapack.so: undefined reference to `slaswp_minus'
...
解決方案最終如
target_link_libraries(BaiduFaceTest
/home/z/test_face_api/facelib/libFaceSDK.so
/home/z/test_face_api/facelib/libBaiduFaceApi-ubuntu16.so
/home/z/test_face_api/lib3/lib64/libpng12.so
/home/z/test_face_api/lib3/lib64/libtiff.so
...
#/home/z/test_face_api/lib3/lib64/libX11.so
#/home/z/test_face_api/lib3/openblas-linux/lib/libopenblas.so
/home/z/Software/dlib/build/dlib/libdlib.a
/usr/local/jpeg9/lib/libjpeg.so
/usr/lib/x86_64-linux-gnu/liblapack.so
/usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
-lX11
-lpng
-pthread
百度人脸識別和系統自帶的liblas在我使用過程當中,經常出現bug問題,於是選擇了自己安裝的libblas 。
liblapack.so.3: undefined symbol: gotoblas
在該項目編譯過程中,出現了這樣的問,具體原因是因爲使用了系統自帶的libblas.so.3的庫,將自己的庫的路徑指定就可以解決錯誤
写在最后:说实话,百度的离线人脸识别系统是真的不好用,基本上是各个地方捡一点,堆在一起,人脸检测的这个功能,正确率放在实际场景效果就很差,确实比不上开源的 insightface.