資源簡介
Linux下C++ 與python人臉檢測
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
import?sys
import?cv2?
import?dlib
from?skimage?import?io
#使用dlib自帶的frontal_face_detector作為我們的特征提取器
detector?=?dlib.get_frontal_face_detector()
#使用dlib提供的圖片窗口
win?=?dlib.image_window()
#sys.argv[]是用來獲取命令行參數的,sys.argv[0]表示代碼本身文件路徑,所以參數從1開始向后依次獲取圖片路徑
for?f?in?sys.argv[1:]:
???
????#使用skimage的io讀取圖片
????img?=?io.imread(f)
????#使用detector進行人臉檢測?dets為返回的結果
????dets?=?detector(img1)
????????
????#left:人臉左邊距離圖片左邊界的距離?;right:人臉右邊距離圖片左邊界的距離?
????#top:人臉上邊距離圖片上邊界的距離?;bottom:人臉下邊距離圖片上邊界的距離
????for?i?d?in?enumerate(dets):
????????x?=?d.left()
????????y?=?d.top()
????????w?=?d.right()
????????h?=?d.bottom()
????????#print(“w:{}h:{}“.format(d.width()d.height()))
????????cv2.rectangle(img?(x?y)?(w?h)?(0?255?0))
???????#print(“Detection?{}:?Left:?{}?Top:?{}?Right:
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......???????971??2017-02-16?10:27??DlibTest\CMakeLists.txt
????.......????458255??2017-01-24?13:02??DlibTest\data\bush.jpg
????.......????147744??2017-02-17?09:59??DlibTest\data\C_Dlib_test_0.jpg
????.......????147744??2017-02-17?09:48??DlibTest\data\C_Dlib_test_1.jpg
????.......?????50857??2017-02-17?09:51??DlibTest\data\P_Dlib_test_0.jpg
????.......?????51054??2017-02-17?09:54??DlibTest\data\P_Dlib_test_1.jpg
????.......???????157??2017-02-17?10:01??DlibTest\data\readme.txt
????.......??????1701??2017-02-17?09:53??DlibTest\PDlib.py
????.......??????1792??2017-02-17?09:56??DlibTest\src\CDlib.cpp
????.......????????23??2017-02-15?15:24??DlibTest\src\CMakeLists.txt
?????目錄??????????0??2017-02-17?10:04??DlibTest\data
?????目錄??????????0??2017-02-17?10:04??DlibTest\src
?????目錄??????????0??2017-02-17?10:04??DlibTest
-----------?---------??----------?-----??----
???????????????860298????????????????????13
- 上一篇:C++五子棋最簡機器算法代碼
- 下一篇:操作系統模擬移臂調度算法c語言代碼
評論
共有 條評論