欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實現(xiàn)圖片,視頻人臉識別(dlib版)

 更新時間:2020年11月18日 16:54:10   作者:https://github.com/LeonPython/faceai/blob/master/doc/videoOpenCV.md  
這篇文章主要介紹了python實現(xiàn)圖像,視頻人臉識別(dlib版)的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)python,感興趣的朋友可以了解下

圖片人臉檢測

#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個標(biāo)定點
  # 遍歷所有點,打印出其坐標(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)的人類識別器模型


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的視頻識別對比,有兩個地方是不同的:

1.Dlib模型識別的準(zhǔn)確率和效果要好于OpenCV;

2.Dlib識別的性能要比OpenCV差,使用視頻測試的時候Dlib有明顯的卡頓,但是OpenCV就好很多,基本看不出來;

以上就是python實現(xiàn)圖片,視頻人臉識別(dlib版)的詳細(xì)內(nèi)容,更多關(guān)于python 人臉識別的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論