Py之dlib:Python库之dlib库的简介、安装、使用方法详细攻略


蜻蜓
蜻蜓 2022-09-20 10:57:23 50399
分类专栏: 资讯

Py之dlib:Python库之dlib库的简介、安装、使用方法详细攻略

目录

dlib库的简介

dlib库的安装

dlib库的使用函数

0、利用dlib.get_frontal_face_detector函数实现人脸检测可视化

1、hog提取特征的函数

2、CNN提取特征的函数


dlib库的简介

    一个机器学习的开源库,包含了机器学习的很多算法,使用起来很方便,直接包含头文件即可,并且不依赖于其他库(自带图像编解码库源码)。Dlib可以帮助您创建很多复杂的机器学习方面的软件来帮助解决实际问题。目前Dlib已经被广泛的用在行业和学术领域,包括机器人,嵌入式设备,移动电话和大型高性能计算环境。

Dlib是一个使用现代C++技术编写的跨平台的通用库,遵守Boost Software licence. 主要特点如下: 

  • 完善的文档:每个类每个函数都有详细的文档,并且提供了大量的示例代码,如果你发现文档描述不清晰或者没有文档,告诉作者,作者会立刻添加。 
  • 可移植代码:代码符合ISO C++标准,不需要第三方库支持,支持win32、Linux、Mac OS X、Solaris、HPUX、BSDs 和 POSIX 系统 
  • 线程支持:提供简单的可移植的线程API 
  • 网络支持:提供简单的可移植的Socket API和一个简单的Http服务器 
  • 图形用户界面:提供线程安全的GUI API 
  • 数值算法:矩阵、大整数、随机数运算等 
  • 机器学习算法:
  • 图形模型算法: 
  • 图像处理:支持读写Windows BMP文件,不同类型色彩转换 
  • 数据压缩和完整性算法:CRC32、Md5、不同形式的PPM算法 
  • 测试:线程安全的日志类和模块化的单元测试框架以及各种测试assert支持
  • 一般工具:XML解析、内存管理、类型安全的big/little endian转换、序列化支持和容器类
     


dlib pypi
dlib库
dlib c++ library

dlib库的安装

dlib压缩包集合Index of /files

本博客提供三种方法进行安装

T1方法:pip install dlib

此方法是需要在你安装cmake、Boost环境的计算机使用

T2方法:conda install -c menpo dlib=18.18

此方法适合那些已经安装好conda库的环境的计算机使用,conda库的安装本博客有详细攻略,请自行翻看。

T3方法:pip install dlib-19.8.1-cp36-cp36m-win_amd64.whl

dlib库的whl文件——dlib-19.7.0-cp36-cp36m-win_amd64.rar

dlib-19.3.1-cp35-cp35m-win_amd64.whl

哈哈,大功告成!如有资料或问题需求,请留言!

dlib库的使用函数

0、利用dlib.get_frontal_face_detector函数实现人脸检测可视化

CV之dlib:利用dlib.get_frontal_face_detector函数实现人脸检测

1、hog提取特征的函数

dlib.get_frontal_face_detector()    人脸特征提取器,该函数是在C++里面定义的

  1. help(dlib.get_frontal_face_detector())
  2. Help on fhog_object_detector in module dlib.dlib object:
  3. class fhog_object_detector(Boost.Python.instance)
  4. | This object represents a sliding window histogram-of-oriented-gradients based object detector.
  5. |
  6. | Method resolution order:
  7. | fhog_object_detector
  8. | Boost.Python.instance
  9. | builtins.object
  10. |
  11. | Methods defined here:
  12. |
  13. | __call__(...)
  14. | __call__( (fhog_object_detector)arg1, (object)image [, (int)upsample_num_times=0]) -> rectangles :
  15. | requires
  16. | - image is a numpy ndarray containing either an 8bit grayscale or RGB
  17. | image.
  18. | - upsample_num_times >= 0
  19. | ensures
  20. | - This function runs the object detector on the input image and returns
  21. | a list of detections.
  22. | - Upsamples the image upsample_num_times before running the basic
  23. | detector.
  24. |
  25. | __getstate__(...)
  26. | __getstate__( (fhog_object_detector)arg1) -> tuple
  27. |
  28. | __init__(...)
  29. | __init__( (object)arg1) -> None
  30. |
  31. | __init__( (object)arg1, (str)arg2) -> object :
  32. | Loads an object detector from a file that contains the output of the
  33. | train_simple_object_detector() routine or a serialized C++ object of type
  34. | object_detector<scan_fhog_pyramid<pyramid_down<6>>>.
  35. |
  36. | __reduce__ = <unnamed Boost.Python function>(...)
  37. |
  38. | __setstate__(...)
  39. | __setstate__( (fhog_object_detector)arg1, (tuple)arg2) -> None
  40. |
  41. | run(...)
  42. | run( (fhog_object_detector)arg1, (object)image [, (int)upsample_num_times=0 [, (float)adjust_threshold=0.0]]) -> tuple :
  43. | requires
  44. | - image is a numpy ndarray containing either an 8bit grayscale or RGB
  45. | image.
  46. | - upsample_num_times >= 0
  47. | ensures
  48. | - This function runs the object detector on the input image and returns
  49. | a tuple of (list of detections, list of scores, list of weight_indices).
  50. | - Upsamples the image upsample_num_times before running the basic
  51. | detector.
  52. |
  53. | save(...)
  54. | save( (fhog_object_detector)arg1, (str)detector_output_filename) -> None :
  55. | Save a simple_object_detector to the provided path.
  56. |
  57. | ----------------------------------------------------------------------
  58. | Static methods defined here:
  59. |
  60. | run_multiple(...)
  61. | run_multiple( (list)detectors, (object)image [, (int)upsample_num_times=0 [, (float)adjust_threshold=0.0]]) -> tuple :
  62. | requires
  63. | - detectors is a list of detectors.
  64. | - image is a numpy ndarray containing either an 8bit grayscale or RGB
  65. | image.
  66. | - upsample_num_times >= 0
  67. | ensures
  68. | - This function runs the list of object detectors at once on the input image and returns
  69. | a tuple of (list of detections, list of scores, list of weight_indices).
  70. | - Upsamples the image upsample_num_times before running the basic
  71. | detector.
  72. |
  73. | ----------------------------------------------------------------------
  74. | Data and other attributes defined here:
  75. |
  76. | __instance_size__ = 160
  77. |
  78. | __safe_for_unpickling__ = True
  79. |
  80. | ----------------------------------------------------------------------
  81. | Methods inherited from Boost.Python.instance:
  82. |
  83. | __new__(*args, **kwargs) from Boost.Python.class
  84. | Create and return a new object. See help(type) for accurate signature.
  85. |
  86. | ----------------------------------------------------------------------
  87. | Data descriptors inherited from Boost.Python.instance:
  88. |
  89. | __dict__
  90. |
  91. | __weakref__

2、CNN提取特征的函数

cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)

  1. help(dlib.cnn_face_detection_model_v1)
  2. Help on class cnn_face_detection_model_v1 in module dlib.dlib:
  3. class cnn_face_detection_model_v1(Boost.Python.instance)
  4. | This object detects human faces in an image. The constructor loads the face detection model from a file. You can download a pre-trained model from http://dlib.net/files/mmod_human_face_detector.dat.bz2.
  5. |
  6. | Method resolution order:
  7. | cnn_face_detection_model_v1
  8. | Boost.Python.instance
  9. | builtins.object
  10. |
  11. | Methods defined here:
  12. |
  13. | __call__(...)
  14. | __call__( (cnn_face_detection_model_v1)arg1, (object)img [, (int)upsample_num_times=0]) -> mmod_rectangles :
  15. | Find faces in an image using a deep learning model.
  16. | - Upsamples the image upsample_num_times before running the face
  17. | detector.
  18. |
  19. | __call__( (cnn_face_detection_model_v1)arg1, (list)imgs [, (int)upsample_num_times=0 [, (int)batch_size=128]]) -> mmod_rectangless :
  20. | takes a list of images as input returning a 2d list of mmod rectangles
  21. |
  22. | __init__(...)
  23. | __init__( (object)arg1, (str)arg2) -> None
  24. |
  25. | __reduce__ = <unnamed Boost.Python function>(...)
  26. |
  27. | ----------------------------------------------------------------------
  28. | Data and other attributes defined here:
  29. |
  30. | __instance_size__ = 984
  31. |
  32. | ----------------------------------------------------------------------
  33. | Methods inherited from Boost.Python.instance:
  34. |
  35. | __new__(*args, **kwargs) from Boost.Python.class
  36. | Create and return a new object. See help(type) for accurate signature.
  37. |
  38. | ----------------------------------------------------------------------
  39. | Data descriptors inherited from Boost.Python.instance:
  40. |
  41. | __dict__
  42. |
  43. | __weakref__

inline frontal_face_detector get_frontal_face_detector()
 


 

文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树预备知识Python简介123796 人正在系统学习中

网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。

本文链接:https://www.xckfsq.com/news/show.html?id=4155
赞同 0
评论 0 条
蜻蜓L0
粉丝 0 发表 11 + 关注 私信
上周热门
如何使用 StarRocks 管理和优化数据湖中的数据?  2935
【软件正版化】软件正版化工作要点  2854
统信UOS试玩黑神话:悟空  2811
信刻光盘安全隔离与信息交换系统  2702
镜舟科技与中启乘数科技达成战略合作,共筑数据服务新生态  1235
grub引导程序无法找到指定设备和分区  1205
点击报名 | 京东2025校招进校行程预告  162
华为全联接大会2024丨软通动力分论坛精彩议程抢先看!  160
2024海洋能源产业融合发展论坛暨博览会同期活动-海洋能源与数字化智能化论坛成功举办  156
华为纯血鸿蒙正式版9月底见!但Mate 70的内情还得接着挖...  154
本周热议
我的信创开放社区兼职赚钱历程 40
今天你签到了吗? 27
信创开放社区邀请他人注册的具体步骤如下 15
如何玩转信创开放社区—从小白进阶到专家 15
方德桌面操作系统 14
我有15积分有什么用? 13
用抖音玩法闯信创开放社区——用平台宣传企业产品服务 13
如何让你先人一步获得悬赏问题信息?(创作者必看) 12
2024中国信创产业发展大会暨中国信息科技创新与应用博览会 9
中央国家机关政府采购中心:应当将CPU、操作系统符合安全可靠测评要求纳入采购需求 8

加入交流群

请使用微信扫一扫!