首页 技术 正文
技术 2022年11月7日
0 收藏 982 点赞 967 浏览 1537 个字

最近的工作中用到了dlib这个库,该库是一个机器学习的开源库,使用起来很方便,直接包含头文件即可,并且不依赖于其他库(自带图像编解码库源码)。不过由于是开源的,所以bug多少有一些,我在example编译和使用时就遇到了一些问题,总结如下:

1.example编译

按照官网的指导,下载最新的18.18版本dlib,然后解压缩到某个路径。dlib库不用单独编译,只需要编译example,即可看到效果。根据README.txt文件中的步骤,在exmaple文件夹下,执行下面命令即可,

mkdir build

cd build

cmake ..

cmake –build .

但是一般在最后一步会遇到一些问题,导致编译失败,解决方法如下:

1.在dlib/CMakeLists.txt中 project(dlib) 的下一行添加set(Boost_USE_STATIC_LIBS ON)

2.把 if (DLIB_PNG_SUPPORT) (227行左右)这一行以下的这些代码进行注释,其余不变

         # try to find libpng
#find_package(PNG QUIET)
# Make sure there isn't something wrong with the version of LIBPNG
# installed on this system.
#if (PNG_FOUND)
#set(CMAKE_REQUIRED_LIBRARIES ${PNG_LIBRARY})
#CHECK_FUNCTION_EXISTS(png_create_read_struct LIBPNG_IS_GOOD)
#endif()
#if (PNG_FOUND AND LIBPNG_IS_GOOD)
#include_directories(${PNG_INCLUDE_DIR})
#set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARY})
#else()
# If we can't find libpng then statically compile it in.

3.把 if (DLIB_JPEG_SUPPORT) (280行左右)这一行以下的这些代码进行注释,其余不变

         # try to find libjpeg
#find_package(JPEG QUIET)
# Make sure there isn't something wrong with the version of libjpeg
# installed on this system. Also don't use the installed libjpeg
# if this is an APPLE system because apparently it's broken (as of 2015/01/01).
#if (JPEG_FOUND)
#set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARY})
#CHECK_FUNCTION_EXISTS(jpeg_read_header LIBJPEG_IS_GOOD)
#endif()
#if (JPEG_FOUND AND LIBJPEG_IS_GOOD AND NOT APPLE)
#include_directories(${JPEG_INCLUDE_DIR})
#set (dlib_needed_libraries ${dlib_needed_libraries} ${JPEG_LIBRARY})
#else()
# If we can't find libjpeg then statically compile it in.

这样应该就可以编译通过了,编译出的二进制文件应该也可以执行,如果执行时依然报错找不到jpeg或png库,再确认一下CMakeLists文件是否按照上述修改。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291