python實(shí)現(xiàn)圖片,視頻人臉識(shí)別(dlib版)
圖片人臉檢測
#coding=utf-8
import cv2
import dlib
path = "img/meinv.png"
img = cv2.imread(path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#人臉分類器
detector = dlib.get_frontal_face_detector()
# 獲取人臉檢測器
predictor = dlib.shape_predictor(
"C:\\Python36\\Lib\\site-packages\\dlib-data\\shape_predictor_68_face_landmarks.dat"
)
dets = detector(gray, 1)
for face in dets:
shape = predictor(img, face) # 尋找人臉的68個(gè)標(biāo)定點(diǎn)
# 遍歷所有點(diǎn),打印出其坐標(biāo),并圈出來
for pt in shape.parts():
pt_pos = (pt.x, pt.y)
cv2.circle(img, pt_pos, 2, (0, 255, 0), 1)
cv2.imshow("image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
視頻人臉檢測
# coding=utf-8
import cv2
import dlib
detector = dlib.get_frontal_face_detector() #使用默認(rèn)的人類識(shí)別器模型
def discern(img):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
dets = detector(gray, 1)
for face in dets:
left = face.left()
top = face.top()
right = face.right()
bottom = face.bottom()
cv2.rectangle(img, (left, top), (right, bottom), (0, 255, 0), 2)
cv2.imshow("image", img)
cap = cv2.VideoCapture(0)
while (1):
ret, img = cap.read()
discern(img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
那么,OpenCV和Dlib的視頻識(shí)別對(duì)比,有兩個(gè)地方是不同的:
1.Dlib模型識(shí)別的準(zhǔn)確率和效果要好于OpenCV;
2.Dlib識(shí)別的性能要比OpenCV差,使用視頻測試的時(shí)候Dlib有明顯的卡頓,但是OpenCV就好很多,基本看不出來;
以上就是python實(shí)現(xiàn)圖片,視頻人臉識(shí)別(dlib版)的詳細(xì)內(nèi)容,更多關(guān)于python 人臉識(shí)別的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- python opencv人臉識(shí)別考勤系統(tǒng)的完整源碼
- Python三十行代碼實(shí)現(xiàn)簡單人臉識(shí)別的示例代碼
- 10分鐘學(xué)會(huì)使用python實(shí)現(xiàn)人臉識(shí)別(附源碼)
- 用Python實(shí)現(xiàn)簡單的人臉識(shí)別功能步驟詳解
- python基于opencv實(shí)現(xiàn)人臉識(shí)別
- python實(shí)現(xiàn)圖片,視頻人臉識(shí)別(opencv版)
- python調(diào)用百度API實(shí)現(xiàn)人臉識(shí)別
- 使用python-cv2實(shí)現(xiàn)Harr+Adaboost人臉識(shí)別的示例
- python3.8動(dòng)態(tài)人臉識(shí)別的實(shí)現(xiàn)示例
- Python3 利用face_recognition實(shí)現(xiàn)人臉識(shí)別的方法
- python實(shí)現(xiàn)的人臉識(shí)別打卡系統(tǒng)
相關(guān)文章
python二叉樹的實(shí)現(xiàn)實(shí)例
這篇文章主要介紹了python二叉樹的實(shí)現(xiàn)實(shí)例,大家參考使用吧2013-11-11
Python實(shí)現(xiàn)機(jī)器學(xué)習(xí)算法的分類
今天給大家整理了Python實(shí)現(xiàn)機(jī)器學(xué)習(xí)算法的分類的文章,文中有非常詳細(xì)的代碼示例,對(duì)正在學(xué)習(xí)的小伙伴們很有幫助,需要的朋友可以參考下2021-06-06
修改 CentOS 6.x 上默認(rèn)Python的方法
這篇文章主要介紹了修改 CentOS 6.x 上默認(rèn)Python的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09
python3 BeautifulSoup模塊使用字典的方法抓取a標(biāo)簽內(nèi)的數(shù)據(jù)示例
這篇文章主要介紹了python3 BeautifulSoup模塊使用字典的方法抓取a標(biāo)簽內(nèi)的數(shù)據(jù),結(jié)合實(shí)例形式Fenix了python3 BeautifulSoup模塊進(jìn)行數(shù)據(jù)的抓取相關(guān)操作技巧,需要的朋友可以參考下2019-11-11
對(duì)pandas的dataframe繪圖并保存的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄獙?duì)pandas的dataframe繪圖并保存的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-08-08
pycharm軟件實(shí)現(xiàn)設(shè)置自動(dòng)保存操作
這篇文章主要介紹了pycharm軟件實(shí)現(xiàn)設(shè)置自動(dòng)保存操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-06-06
python openCV實(shí)現(xiàn)攝像頭獲取人臉圖片
這篇文章主要為大家詳細(xì)介紹了python openCV實(shí)現(xiàn)攝像頭獲取人臉圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-08-08

