Py之dlib:Python库之dlib库的简介、安装、使用方法详细攻略
Py之dlib:Python庫之dlib庫的簡介、安裝、使用方法詳細(xì)攻略
目錄
dlib庫的簡介
dlib庫的安裝
dlib庫的使用函數(shù)
0、利用dlib.get_frontal_face_detector函數(shù)實現(xiàn)人臉檢測可視化
1、hog提取特征的函數(shù)
2、CNN提取特征的函數(shù)
dlib庫的簡介
? ? 一個機器學(xué)習(xí)的開源庫,包含了機器學(xué)習(xí)的很多算法,使用起來很方便,直接包含頭文件即可,并且不依賴于其他庫(自帶圖像編解碼庫源碼)。Dlib可以幫助您創(chuàng)建很多復(fù)雜的機器學(xué)習(xí)方面的軟件來幫助解決實際問題。目前Dlib已經(jīng)被廣泛的用在行業(yè)和學(xué)術(shù)領(lǐng)域,包括機器人,嵌入式設(shè)備,移動電話和大型高性能計算環(huán)境。
Dlib是一個使用現(xiàn)代C++技術(shù)編寫的跨平臺的通用庫,遵守Boost Software licence. 主要特點如下:?
- 完善的文檔:每個類每個函數(shù)都有詳細(xì)的文檔,并且提供了大量的示例代碼,如果你發(fā)現(xiàn)文檔描述不清晰或者沒有文檔,告訴作者,作者會立刻添加。?
- 可移植代碼:代碼符合ISO C++標(biāo)準(zhǔn),不需要第三方庫支持,支持win32、Linux、Mac OS X、Solaris、HPUX、BSDs 和 POSIX 系統(tǒng)?
- 線程支持:提供簡單的可移植的線程API?
- 網(wǎng)絡(luò)支持:提供簡單的可移植的Socket API和一個簡單的Http服務(wù)器?
- 圖形用戶界面:提供線程安全的GUI API?
- 數(shù)值算法:矩陣、大整數(shù)、隨機數(shù)運算等?
- 機器學(xué)習(xí)算法:
- 圖形模型算法:?
- 圖像處理:支持讀寫Windows BMP文件,不同類型色彩轉(zhuǎn)換?
- 數(shù)據(jù)壓縮和完整性算法:CRC32、Md5、不同形式的PPM算法?
- 測試:線程安全的日志類和模塊化的單元測試框架以及各種測試assert支持
- 一般工具:XML解析、內(nèi)存管理、類型安全的big/little endian轉(zhuǎn)換、序列化支持和容器類
?
dlib pypi
dlib庫
dlib c++ library
dlib庫的安裝
dlib壓縮包集合:Index of /files
本博客提供三種方法進(jìn)行安裝
T1方法:pip install dlib
此方法是需要在你安裝cmake、Boost環(huán)境的計算機使用
T2方法:conda install -c menpo dlib=18.18
此方法適合那些已經(jīng)安裝好conda庫的環(huán)境的計算機使用,conda庫的安裝本博客有詳細(xì)攻略,請自行翻看。
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庫的使用函數(shù)
0、利用dlib.get_frontal_face_detector函數(shù)實現(xiàn)人臉檢測可視化
CV之dlib:利用dlib.get_frontal_face_detector函數(shù)實現(xiàn)人臉檢測
1、hog提取特征的函數(shù)
dlib.get_frontal_face_detector() ? ?#人臉特征提取器,該函數(shù)是在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提取特征的函數(shù)
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()
?
?
總結(jié)
以上是生活随笔為你收集整理的Py之dlib:Python库之dlib库的简介、安装、使用方法详细攻略的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CV:利用cv2自带两步法haarcas
- 下一篇: 成功解决You are using pi