日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

人脸识别python face_recognize_【python+face_recognition】人脸识别初始

發布時間:2025/3/20 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 人脸识别python face_recognize_【python+face_recognition】人脸识别初始 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

【python+face_recognition】人臉識別初始

發布時間:2018-09-01 12:03,

瀏覽次數:366

, 標簽:

python

face

recognition

face_recognition 人臉識別初始

說到人臉識別,我們肯定會聯系到機器學習,機器學習說起來可能遙不可及,在python 當道的今天,如何快速實現人臉識別功能,這是個問題

今天我們來了解下python 的 face_recognition 庫,來做一個簡單的人臉識別程序。走進機器學習,人工智能的大門

我們使用face_recognition 來識別圖片中是否是同一個人。

我們使用到的識別素材2.jpg

# -*- coding:utf-8 -*- import cv2 #畫圖用 import face_recognition #人臉識別庫 import

sys face_image = face_recognition.load_image_file("E://pics/2.jpg") #讀取圖片

face_encodings = face_recognition.face_encodings(face_image) face_locations =

face_recognition.face_locations(face_image)# 判斷圖片中出現的人數 n = len(face_encodings)

if n>2 : print("3") sys.exit() try: face1 = face_encodings[0] face2 =

face_encodings[1] except : print("2") sys.exit() results =

face_recognition.compare_faces([face1], face2, tolerance=0.5) if results == [

True]: print("0") name = "PASS" else: print("1") name = "DENIED" #繪圖 繪制出圖片 for i

in range(len(face_encodings)): face_encoding = face_encodings[(i-1)]

face_location = face_locations[(i-1)] top, right, bottom, left = face_location

cv2.rectangle(face_image, (left, top), (right, bottom), (0, 255, 0), 2)

cv2.putText(face_image, name, (left-10, top-10), cv2.FONT_HERSHEY_SIMPLEX, 0.8,

(255, 0, 0), 2) face_image_rgb = cv2.cvtColor(face_image, cv2.COLOR_BGR2RGB)

cv2.imshow("Output", face_image_rgb) cv2.imwrite(

'C:/Users/Administrator/Desktop/fk_model/face/output/intrest.jpg'

,face_image_rgb,[int(cv2.IMWRITE_JPEG_QUALITY),100]) cv2.waitKey(0)

我們看下識別結果

控制臺打印為1 表示不是同一個人

當然大家可以嘗試不同的圖像,也可以做到工業級應用,這就涉及到圖片特征訓練,特征提取,比這種簡單的識別復雜很多,當然這些都是需要訓練自己的模型,在后期不斷完善。

總結

以上是生活随笔為你收集整理的人脸识别python face_recognize_【python+face_recognition】人脸识别初始的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。