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

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

dlib库的使用函数


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


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


image.png

image.png



1、hog提取特征的函数


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


help(dlib.get_frontal_face_detector())

Help on fhog_object_detector in module dlib.dlib object:

class fhog_object_detector(Boost.Python.instance)

|  This object represents a sliding window histogram-of-oriented-gradients based object detector.

|

|  Method resolution order:

|      fhog_object_detector

|      Boost.Python.instance

|      builtins.object

|

|  Methods defined here:

|

|  __call__(...)

|      __call__( (fhog_object_detector)arg1, (object)image [, (int)upsample_num_times=0]) -> rectangles :

|          requires

|              - image is a numpy ndarray containing either an 8bit grayscale or RGB

|                image.

|              - upsample_num_times >= 0

|          ensures

|              - This function runs the object detector on the input image and returns

|                a list of detections.

|              - Upsamples the image upsample_num_times before running the basic

|                detector.

|

|  __getstate__(...)

|      __getstate__( (fhog_object_detector)arg1) -> tuple

|

|  __init__(...)

|      __init__( (object)arg1) -> None

|

|      __init__( (object)arg1, (str)arg2) -> object :

|          Loads an object detector from a file that contains the output of the

|          train_simple_object_detector() routine or a serialized C++ object of type

|          object_detector<scan_fhog_pyramid<pyramid_down<6>>>.

|

|  __reduce__ = <unnamed Boost.Python function>(...)

|

|  __setstate__(...)

|      __setstate__( (fhog_object_detector)arg1, (tuple)arg2) -> None

|

|  run(...)

|      run( (fhog_object_detector)arg1, (object)image [, (int)upsample_num_times=0 [, (float)adjust_threshold=0.0]]) -> tuple :

|          requires

|              - image is a numpy ndarray containing either an 8bit grayscale or RGB

|                image.

|              - upsample_num_times >= 0

|          ensures

|              - This function runs the object detector on the input image and returns

|                a tuple of (list of detections, list of scores, list of weight_indices).

|              - Upsamples the image upsample_num_times before running the basic

|                detector.

|

|  save(...)

|      save( (fhog_object_detector)arg1, (str)detector_output_filename) -> None :

|          Save a simple_object_detector to the provided path.

|

|  ----------------------------------------------------------------------

|  Static methods defined here:

|

|  run_multiple(...)

|      run_multiple( (list)detectors, (object)image [, (int)upsample_num_times=0 [, (float)adjust_threshold=0.0]]) -> tuple :

|          requires

|              - detectors is a list of detectors.

|              - image is a numpy ndarray containing either an 8bit grayscale or RGB

|                image.

|              - upsample_num_times >= 0

|          ensures

|              - This function runs the list of object detectors at once on the input image and returns

|                a tuple of (list of detections, list of scores, list of weight_indices).

|              - Upsamples the image upsample_num_times before running the basic

|                detector.

|

|  ----------------------------------------------------------------------

|  Data and other attributes defined here:

|

|  __instance_size__ = 160

|

|  __safe_for_unpickling__ = True

|

|  ----------------------------------------------------------------------

|  Methods inherited from Boost.Python.instance:

|

|  __new__(*args, **kwargs) from Boost.Python.class

|      Create and return a new object.  See help(type) for accurate signature.

|

|  ----------------------------------------------------------------------

|  Data descriptors inherited from Boost.Python.instance:

|

|  __dict__

|

|  __weakref__

2、CNN提取特征的函数


cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)


help(dlib.cnn_face_detection_model_v1)

Help on class cnn_face_detection_model_v1 in module dlib.dlib:

class cnn_face_detection_model_v1(Boost.Python.instance)

|  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.

|

|  Method resolution order:

|      cnn_face_detection_model_v1

|      Boost.Python.instance

|      builtins.object

|

|  Methods defined here:

|

|  __call__(...)

|      __call__( (cnn_face_detection_model_v1)arg1, (object)img [, (int)upsample_num_times=0]) -> mmod_rectangles :

|          Find faces in an image using a deep learning model.

|                    - Upsamples the image upsample_num_times before running the face

|                      detector.

|

|      __call__( (cnn_face_detection_model_v1)arg1, (list)imgs [, (int)upsample_num_times=0 [, (int)batch_size=128]]) -> mmod_rectangless :

|          takes a list of images as input returning a 2d list of mmod rectangles

|

|  __init__(...)

|      __init__( (object)arg1, (str)arg2) -> None

|

|  __reduce__ = <unnamed Boost.Python function>(...)

|

|  ----------------------------------------------------------------------

|  Data and other attributes defined here:

|

|  __instance_size__ = 984

|

|  ----------------------------------------------------------------------

|  Methods inherited from Boost.Python.instance:

|

|  __new__(*args, **kwargs) from Boost.Python.class

|      Create and return a new object.  See help(type) for accurate signature.

|

|  ----------------------------------------------------------------------

|  Data descriptors inherited from Boost.Python.instance:

|

|  __dict__

|

|  __weakref__


inline frontal_face_detector get_frontal_face_detector()


相关文章
|
3天前
|
JSON Shell 数据格式
使用 pipx 安装并执行 Python 应用程序 (1)
使用 pipx 安装并执行 Python 应用程序 (1)
41 17
|
22天前
|
IDE 测试技术 项目管理
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
PyCharm是由JetBrains开发的Python集成开发环境(IDE),专为Python开发者设计,支持Web开发、调试、语法高亮、项目管理、代码跳转、智能提示、自动完成、单元测试和版本控制等功能。它有专业版、教育版和社区版三个版本,其中社区版免费且适合个人和小型团队使用,包含基本的Python开发功能。安装PyCharm前需先安装Python解释器,并配置环境变量。通过简单的步骤即可在PyCharm中创建并运行Python项目,如输出“Hello World”。
197 13
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
|
29天前
|
人工智能 Java Python
python安装、vscode安装、conda安装:一文搞定Python的开发环境(史上最全)
尼恩架构团队推出了一系列《LLM大模型学习圣经》PDF,旨在帮助读者深入理解并掌握大型语言模型(LLM)及其相关技术。该系列包括Python基础、Transformer架构、LangChain框架、RAG架构及LLM智能体等内容,覆盖从理论到实践的各个方面。此外,尼恩还提供了配套视频教程,计划于2025年5月前发布,助力更多人成为大模型应用架构师,冲击年薪百万目标。
|
1月前
|
Shell Linux iOS开发
使用 pipx 安装并执行 Python 应用程序 (1)
使用 pipx 安装并执行 Python 应用程序 (1)
52 0
使用 pipx 安装并执行 Python 应用程序 (1)
|
算法 UED Python
<LeetCode天梯>攻略集合部分 | 初级算法 | Python(U can save)
<LeetCode天梯>攻略集合部分 | 初级算法 | Python(U can save)
<LeetCode天梯>攻略集合部分 | 初级算法 | Python(U can save)
|
2月前
|
人工智能 数据可视化 数据挖掘
探索Python编程:从基础到高级
在这篇文章中,我们将一起深入探索Python编程的世界。无论你是初学者还是有经验的程序员,都可以从中获得新的知识和技能。我们将从Python的基础语法开始,然后逐步过渡到更复杂的主题,如面向对象编程、异常处理和模块使用。最后,我们将通过一些实际的代码示例,来展示如何应用这些知识解决实际问题。让我们一起开启Python编程的旅程吧!
|
2月前
|
存储 数据采集 人工智能
Python编程入门:从零基础到实战应用
本文是一篇面向初学者的Python编程教程,旨在帮助读者从零开始学习Python编程语言。文章首先介绍了Python的基本概念和特点,然后通过一个简单的例子展示了如何编写Python代码。接下来,文章详细介绍了Python的数据类型、变量、运算符、控制结构、函数等基本语法知识。最后,文章通过一个实战项目——制作一个简单的计算器程序,帮助读者巩固所学知识并提高编程技能。
|
2月前
|
Unix Linux 程序员
[oeasy]python053_学编程为什么从hello_world_开始
视频介绍了“Hello World”程序的由来及其在编程中的重要性。从贝尔实验室诞生的Unix系统和C语言说起,讲述了“Hello World”作为经典示例的起源和流传过程。文章还探讨了C语言对其他编程语言的影响,以及它在系统编程中的地位。最后总结了“Hello World”、print、小括号和双引号等编程概念的来源。
126 80
|
23天前
|
存储 缓存 Java
Python高性能编程:五种核心优化技术的原理与Python代码
Python在高性能应用场景中常因执行速度不及C、C++等编译型语言而受质疑,但通过合理利用标准库的优化特性,如`__slots__`机制、列表推导式、`@lru_cache`装饰器和生成器等,可以显著提升代码效率。本文详细介绍了这些实用的性能优化技术,帮助开发者在不牺牲代码质量的前提下提高程序性能。实验数据表明,这些优化方法能在内存使用和计算效率方面带来显著改进,适用于大规模数据处理、递归计算等场景。
58 5
Python高性能编程:五种核心优化技术的原理与Python代码
|
2月前
|
Python
[oeasy]python055_python编程_容易出现的问题_函数名的重新赋值_print_int
本文介绍了Python编程中容易出现的问题,特别是函数名、类名和模块名的重新赋值。通过具体示例展示了将内建函数(如`print`、`int`、`max`)或模块名(如`os`)重新赋值为其他类型后,会导致原有功能失效。例如,将`print`赋值为整数后,无法再用其输出内容;将`int`赋值为整数后,无法再进行类型转换。重新赋值后,这些名称失去了原有的功能,可能导致程序错误。总结指出,已有的函数名、类名和模块名不适合覆盖赋新值,否则会失去原有功能。如果需要使用类似的变量名,建议采用其他命名方式以避免冲突。
52 14

热门文章

最新文章

推荐镜像

更多