python人臉識別庫
㈠ 誰用過python中的第三方庫face recognition
簡介
該庫可以通過python或者命令行即可實現人臉識別的功能。使用dlib深度學習人臉識別技術構建,在戶外臉部檢測資料庫基準(Labeled Faces in the Wild)上的准確率為99.38%。
在github上有相關的鏈接和API文檔。
在下方為提供的一些相關源碼或是文檔。當前庫的版本是v0.2.0,點擊docs可以查看API文檔,我們可以查看一些函數相關的說明等。
安裝配置
安裝配置很簡單,按照github上的說明一步一步來就可以了。
根據你的python版本輸入指令:
pip install face_recognition11
或者
pip3 install face_recognition11
正常來說,安裝過程中會出錯,會在安裝dlib時出錯,可能報錯也可能會卡在那不動。因為pip在編譯dlib時會出錯,所以我們需要手動編譯dlib再進行安裝。
按照它給出的解決辦法:
1、先下載下來dlib的源碼。
git clone
2、編譯dlib。
cd dlib
mkdir build
cd build
cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1
cmake --build1234512345
3、編譯並安裝python的拓展包。
cd ..
python3 setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA1212
注意:這個安裝步驟是默認認為沒有GPU的,所以不支持cuda。
在自己手動編譯了dlib後,我們可以在python中import dlib了。
之後再重新安裝,就可以配置成功了。
根據你的python版本輸入指令:
pip install face_recognition11
或者
pip3 install face_recognition11
安裝成功之後,我們可以在python中正常import face_recognition了。
編寫人臉識別程序
編寫py文件:
# -*- coding: utf-8 -*-
#
# 檢測人臉
import face_recognition
import cv2
# 讀取圖片並識別人臉
img = face_recognition.load_image_file("silicon_valley.jpg")
face_locations = face_recognition.face_locations(img)
print face_locations
# 調用opencv函數顯示圖片
img = cv2.imread("silicon_valley.jpg")
cv2.namedWindow("原圖")
cv2.imshow("原圖", img)
# 遍歷每個人臉,並標注
faceNum = len(face_locations)
for i in range(0, faceNum):
top = face_locations[i][0]
right = face_locations[i][1]
bottom = face_locations[i][2]
left = face_locations[i][3]
start = (left, top)
end = (right, bottom)
color = (55,255,155)
thickness = 3
cv2.rectangle(img, start, end, color, thickness)
# 顯示識別結果
cv2.namedWindow("識別")
cv2.imshow("識別", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
注意:這里使用了python-OpenCV,一定要配置好了opencv才能運行成功。
運行結果:
程序會讀取當前目錄下指定的圖片,然後識別其中的人臉,並標注每個人臉。
(使用圖片來自美劇矽谷)
編寫人臉比對程序
首先,我在目錄下放了幾張圖片:
這里用到的是一張喬布斯的照片和一張奧巴馬的照片,和一張未知的照片。
編寫程序:
# 識別圖片中的人臉
import face_recognition
jobs_image = face_recognition.load_image_file("jobs.jpg");
obama_image = face_recognition.load_image_file("obama.jpg");
unknown_image = face_recognition.load_image_file("unknown.jpg");
jobs_encoding = face_recognition.face_encodings(jobs_image)[0]
obama_encoding = face_recognition.face_encodings(obama_image)[0]
unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
results = face_recognition.compare_faces([jobs_encoding, obama_encoding], unknown_encoding )
labels = ['jobs', 'obama']
print('results:'+str(results))
for i in range(0, len(results)):
if results[i] == True:
print('The person is:'+labels[i])
運行結果:
識別出未知的那張照片是喬布斯的。
攝像頭實時識別
代碼:
# -*- coding: utf-8 -*-
import face_recognition
import cv2
video_capture = cv2.VideoCapture(1)
obama_img = face_recognition.load_image_file("obama.jpg")
obama_face_encoding = face_recognition.face_encodings(obama_img)[0]
face_locations = []
face_encodings = []
face_names = []
process_this_frame = True
while True:
ret, frame = video_capture.read()
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
if process_this_frame:
face_locations = face_recognition.face_locations(small_frame)
face_encodings = face_recognition.face_encodings(small_frame, face_locations)
face_names = []
for face_encoding in face_encodings:
match = face_recognition.compare_faces([obama_face_encoding], face_encoding)
if match[0]:
name = "Barack"
else:
name = "unknown"
face_names.append(name)
process_this_frame = not process_this_frame
for (top, right, bottom, left), name in zip(face_locations, face_names):
top *= 4
right *= 4
bottom *= 4
left *= 4
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), 2)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left+6, bottom-6), font, 1.0, (255, 255, 255), 1)
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
cv2.destroyAllWindows()5455
識別結果:
我直接在手機上網路了幾張圖試試,程序識別出了奧巴馬。
這個庫很cool啊!
㈡ python pip 安裝dlib一直失敗
安裝失敗需要檢查幾個問題:
兼容問題,對應的包支持的操作系統,支持的Python版本
安裝問題,部分包只能通過源碼安裝,或者離線的wheel方式安裝
核對包的安裝文檔
㈢ 如何實現人臉識別及其原理
如何實現人臉識別及其原理
只要開人臉識別功能就行了 人臉識別其實很簡單,相機處理器對拍到的物體進行長寬比例的分析,分析出的數值接近人臉的比例就會自動鎖定,其實就是數學上的計算和比例,也許大家認為人臉差別很大,其實都是遵循著固定的比率的,只要不是畸形,不管胖瘦臉部的比例都是人臉特有的那個值,所以即使是素描畫,相機一樣認為他是人臉,只要他的比例是對的
winform如何實現人臉識別
=IF(OR(P9=""),"",Q9&"."&R9&""&LEFT(S9,2)&"")
意思是當P9為空,就顯示空,否則顯示Q9為整數部份,&"."為加上一個小數點,小數部份為R9和S9的前兩位陣列成.這個公式里的OR和後&""是多餘的,寫成這樣就行=IF(P9="","",Q9&"."&R9&""&LEFT(S9,2))
Q9=30 R9=32 S9=1.3255在後面的單元格顯示30.3201,如果是當S9整數小於2位,就在前面添0,大於2位就顯示幾位整,那麼輸入
=Q9&"."&R9&IF(LEN(ROUNDDOWN(S9,0))<2,0&ROUNDDOWN(S9,0),ROUNDDOWN(S9,0))
如何實現人臉表情識別
適合啊,我同學做的就跟你一點差別,她是人臉識別,沒有表情。
蘋果iPhoneX支援人臉識別是如何實現的?
據說,蘋果新品手機可以「在一百萬張臉中識別出你的肥臉」,還可以通過人臉識別解鎖手機,以及訂制動態3D Animojis 表情。
蘋果iPhoneX人臉識別是怎麼實現的呢?
這是一個復雜的技術問題......人臉識別主要包括人臉檢測、特徵提取、人臉分類三個過程。
簡單地說,就是通過人臉檢測,對五官進行一些關鍵點的定位,然後提取計算機能夠識別的人臉特徵,最後進行一個相似度的比對,從而得到一個人臉識別的結果,也就是判斷「刷臉」的是不是你本人。
讓人最為激動還是蘋果在取消home鍵後,替代Touch ID的Face ID功能。有了人臉識別技術加持,抬手秒解鎖iPhone的過程真的是更簡單也更迅速。
不僅如此,蘋果人臉識別解鎖的安全性、可靠性也非常高。運用3D結構光技術,iPhone X 能夠快速對「人臉3D建模」。即使使用者改變發型,戴上眼鏡帽子,或者在晚上,iPhone X都能成功解鎖。
人臉識別技術這么牛,那它是萬能的嗎?只要是人臉都可以識別、辨認出來么?其實,在進行人臉識別的時候,也存在一些難題,比如人的姿態、光照、遮擋等都會對人臉識別造成影響。
如何實現人的面部識別?
首先是面部捕捉。它根據人的頭部的部位進行判定,首先確定頭部,然後判斷眼睛和嘴巴等頭部特徵,通過特徵庫的比對,確認是面部,完成面部捕捉,ai可以這樣做。 不過個人以為這個技術並不好用,特別是在有不止一個人的場景上,比如大合照,對焦點經常亂跑,所以偶的相機基本還是放在中央對焦上,畢竟cpu再聰明,還是人腦更靠譜。。。
mate9pro,可以實現人臉識別嗎
Mate9 Pro會支援人臉解鎖/識別功能,正在努力適配中。版本具體的更新資訊,請您關注花粉論壇官方通知。感謝您對華為產品的一貫支援。
如何用Python實現簡單人臉識別
你可以使用opencv庫提供的人臉識別模組,這樣子會比較快
Win10怎樣用Kinect實現人臉識別功能
具體操作方法:
1、首先你需要一個連線Windows10電腦和Kinect的介面卡;
2、然後還需要給系統做一個小手術以獲取Kinect Beta驅動更新:
- 按Win+R開啟執行,輸入regedit回車開啟登錄檔編輯器;
- 導航至HKLMSofareMicrosoft
- 建立子鍵DriverFlightingPartner
3、在Partner子鍵中新建名為「TargetRing」的專案,將其值設定為「Drivers」。
不需要重啟電腦,之後你就可以在Windows Update或裝置管理器中更新Kinect Beta驅動了。
以上就是Windows10用Kinect實現人臉識別功能的方法了,這樣一來只要給連線一個Kinect就可以使用Windows10人臉識別功能,而不用更換電腦了。
人臉識別技術是怎樣實現人臉精準檢測?
是的,比如雲脈人臉識別中的人臉檢測技術就是採用三維定向,對人臉三維朝向,做精準到「度」的判斷,以及對人臉特徵點進行「畫素級」定位,輕松判斷眼睛開合狀態,還可通過技術對現有人臉識別做技術上的補充和完善,進而達到識別的創新性和嚴謹性。
Win10系統怎麼使用Kinect實現人臉識別
操作方法:
1、首先你需要一個連線Windows10電腦和Kinect的介面卡;
2、然後還需要給系統做一個小手術以獲取Kinect Beta驅動更新:
- 按Win+R開啟執行,輸入regedit回車開啟登錄檔編輯器;
- 導航至HKLMSofareMicrosoft
- 建立子鍵DriverFlightingPartner
3、在Partner子鍵中新建名為「TargetRing」的專案,將其值設定為「Drivers」。
不需要重啟電腦,之後你就可以在Windows Update或裝置管理器中更新Kinect Beta驅動了。
以上就是Windows10用Kinect實現人臉識別功能的方法了,這樣一來只要給連線一個Kinect就可以使用Windows10人臉識別功能,而不用更換電腦了。
㈣ 去哪裡找python的開源項目
GitHub是一個面向開源及私有軟體項目的託管平台,因為只支持git 作為唯一的版本庫格式進行託管,故名GitHub。作為開源代碼庫以及版本控制系統,Github擁有超過900萬開發者用戶。隨著越來越多的應用程序轉移到了雲上,Github已經成為了管理軟體開發以及發現已有代碼的首選方法。在GitHub,用戶可以十分輕易地找到海量的開源代碼。
下面給大家介紹一些GitHub上25個開源項目:
(1)TensorFlow Models
如果你對機器學習和深度學習感興趣,一定聽說過TensorFlow。TensorFlow Models是一個開源存儲庫,可以找到許多與深度學習相關的庫和模型。
(GitHub: https://github.com/tensorflow/models )
(2)Keras
Keras是一個高級神經網路API,用Python編寫,能夠在TensorFlow,CNTK或Theano之上運行。旨在完成深度學習的快速開發(GitHub: https://github.com/keras-team/keras )
(3)Flask
Flask 是一個微型的 Python 開發的 Web 框架,基於Werkzeug WSGI工具箱和Jinja2 模板引擎,使用BSD授權。
(GitHub: https://github.com/pallets/flask )
(4)scikit-learn
scikit-learn是一個用於機器學習的Python模塊,基於 NumPy、SciPy 和 matplotlib 構建。,並遵循 BSD 許可協議。
(GitHub: https://github.com/scikit-learn )
(5)Zulip
Zulip是一款功能強大的開源群聊應用程序,它結合了實時聊天的即時性和線程對話的生產力優勢。Zulip作為一個開源項目,被許多世界500強企業,大型組織以及其他需要實時聊天系統的用戶選擇使用,該系統允許用戶每天輕松處理數百或數千條消息。Zulip擁有超過300名貢獻者,每月合並超過500次提交,也是規模最大,發展最快的開源群聊項目。
(GitHub: https://github.com/zulip/zulip )
相關推薦:《Python入門教程》
(6)Django
Django 是 Python 編程語言驅動的一個開源模型-視圖-控制器(MVC)風格的 Web 應用程序框架,旨在快速開發出清晰,實用的設計。使用 Django,我們在幾分鍾之內就可以創建高品質、易維護、資料庫驅動的應用程序。
(GitHub: https://github.com/django/django )
(7)Rebound
Rebound 是一個當你得到編譯錯誤時即時獲取 Stack Overflow 結果的命令行工具。 就用 rebound 命令執行你的文件。這對程序員來說方便了不少。
(GitHub: https://github.com/shobrook/rebound )
(8)Google Images Download
這是一個命令行python程序,用於搜索Google Images上的關鍵字/關鍵短語,並可選擇將圖像下載到您的計算機。你也可以從另一個python文件調用此腳本。
(GitHub: https://github.com/hardikvasa/google-images-download )
(9)YouTube-dl
youtube-dl 是基於 Python 的命令行媒體文件下載工具,完全開源免費跨平台。用戶只需使用簡單命令並提供在線視頻的網頁地址即可讓程序自動進行嗅探、下載、合並、命名和清理,最終得到已經命名的完整視頻文件。
(GitHub: htt ps://github.com/rg3/youtube-dl )
(10)System Design Primer
此repo是一個系統的資源集合,可幫助你了解如何大規模構建系統。
(GitHub: https://github.com/donnemartin/system-design-primer )
(11)Mask R-CNN
Mask R-CNN用於對象檢測和分割。這是對Python 3,Keras和TensorFlow的Mask R-CNN實現。該模型為圖像中對象的每個實例生成邊界框和分割蒙版。它基於特Feature Pyramid Network(FPN)和 ResNet101 backbone。
(GitHub: https://github.com/matterport/Mask_RCNN )
(12)Face Recognition
Face Recognition 是一個基於 Python 的人臉識別庫,使用十分簡便。這還提供了一個簡單的face_recognition命令行工具,可以讓您從命令行對圖像文件夾進行人臉識別!
(GitHub: https://github.com/ageitgey/face_recognition )
(13)snallygaster
用於掃描HTTP伺服器上的機密文件的工具。
(GitHub: https://github.com/hannob/snallygaster )
(14)Ansible
Ansible是一個極其簡單的IT自動化系統。它可用於配置管理,應用程序部署,雲配置,支持遠程任務執行和多節點發布 - 包括通過負載平衡器輕松實現零停機滾動更新等操作。
(GitHub: https://github.com/ansible/ansible )
(15)Detectron
Detectron是Facebook AI 研究院開源的的軟體系統,它實現了最先進的目標檢測演算法,包括Mask R-CNN。它是用Python編寫的,由Caffe2深度學習框架提供支持。
(16)asciinema
終端會話記錄器和asciinema.org的最佳搭檔。
(GitHub: https://github.com/asciinema/asciinema )
(17)HTTPie
HTTPie 是一個開源的命令行的 HTTP 工具包,其目標是使與Web服務的CLI交互盡可能人性化。它提供了一個簡單的http命令,允許使用簡單自然的語法發送任意HTTP請求,並顯示彩色輸出。HTTPie可用於測試,調試以及通常與HTTP伺服器交互。
(GitHub: https://github.com/jakubroztocil/httpie )
(18)You-Get
You-Get是一個小型命令行實用程序,用於從Web下載媒體內容(視頻,音頻,圖像),支持國內外常用的視頻網站。
(GitHub: https://github.com/soimort/you-get )
(19)Sentry
Sentry從根本上講是一項服務,可以幫助用戶實時監控和修復崩潰。基於Django構建,它包含一個完整的API,用於從任何語言、任何應用程序中發送事件。
(GitHub: https://github.com/getsentry/sentry )
(20)Tornado
Tornado是使用Python開發的全棧式(full-stack)Web框架和非同步網路庫,,最初是由FriendFeed上開發的。通過使用非阻塞網路I / O,Tornado可以擴展到數萬個開放連接,是long polling、WebSockets和其他需要為用戶維護長連接應用的理想選擇。
(GitHub: https://github.com/tornadoweb/tornado )
(21)Magenta
Magenta是一個探索機器學習在創造藝術和音樂過程中的作用的研究項目。這主要涉及開發新的深度學習和強化學習演算法,用於生成歌曲,圖像,繪圖等。但它也是構建智能工具和界面的探索,它允許藝術家和音樂家使用這些模型。
(GitHub: https://github.com/tensorflow/magenta )
(22)ZeroNet
ZeroNet是一個利用比特幣的加密演算法和BitTorrent技術提供的不受審查的網路,完全開源。
(GitHub: https://github.com/HelloZeroNet/ZeroNet )
(23)Gym
OpenAI Gym是一個用於開發和比較強化學習演算法的工具包。這是Gym的開源庫,可讓讓你訪問標准化的環境。
(GitHub: https://github.com/openai/gym )
(24)Pandas
Pandas是一個Python包,提供快速,靈活和富有表現力的數據結構,該工具是為了解決數據分析任務而創建的。Pandas 納入了大量庫和一些標準的數據模型,提供了高效地操作大型數據集所需的工具。此外,它還有更廣泛的目標,即成為所有語言中最強大,最靈活的開源數據分析/操作工具。它目前已經朝著這個目標邁進。
(GitHub: https://github.com/pandas-dev/pandas )
(25)Luigi
Luigi 是一個 Python 模塊,可以幫你構建復雜的批量作業管道。處理依賴決議、工作流管理、可視化展示等等,內建 Hadoop 支持。(GitHub: https://github.com/spotify/luigi )
㈤ python人臉識別所用的優化演算法有什麼
python三步實現人臉識別
Face Recognition軟體包
這是世界上最簡單的人臉識別庫了。你可以通過Python引用或者命令行的形式使用它,來管理和識別人臉。
該軟體包使用dlib中最先進的人臉識別深度學習演算法,使得識別准確率在《Labled Faces in the world》測試基準下達到了99.38%。
它同時提供了一個叫face_recognition的命令行工具,以便你可以用命令行對一個文件夾中的圖片進行識別操作。
特性
在圖片中識別人臉
找到圖片中所有的人臉
這里是一個例子:
1㈥ 如何線上部署用python基於dlib寫的人臉識別演算法
python使用dlib進行人臉檢測與人臉關鍵點標記
Dlib簡介:
首先給大家介紹一下Dlib
我使用的版本是dlib-18.17,大家也可以在我這里下載:
之後進入python_examples下使用bat文件進行編譯,編譯需要先安裝libboost-python-dev和cmake
cd to dlib-18.17/python_examples
./compile_dlib_python_mole.bat 123
之後會得到一個dlib.so,復制到dist-packages目錄下即可使用
這里大家也可以直接用我編譯好的.so庫,但是也必須安裝libboost才可以,不然python是不能調用so庫的,下載地址:
將.so復制到dist-packages目錄下
sudo cp dlib.so /usr/local/lib/python2.7/dist-packages/1
最新的dlib18.18好像就沒有這個bat文件了,取而代之的是一個setup文件,那麼安裝起來應該就沒有這么麻煩了,大家可以去直接安裝18.18,也可以直接下載復制我的.so庫,這兩種方法應該都不麻煩~
有時候還會需要下面這兩個庫,建議大家一並安裝一下
9.安裝skimage
sudo apt-get install python-skimage1
10.安裝imtools
sudo easy_install imtools1
Dlib face landmarks Demo
環境配置結束之後,我們首先看一下dlib提供的示常式序
1.人臉檢測
dlib-18.17/python_examples/face_detector.py 源程序:
#!/usr/bin/python# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt## This example program shows how to find frontal human faces in an image. In# particular, it shows how you can take a list of images from the command# line and display each on the screen with red boxes overlaid on each human# face.## The examples/faces folder contains some jpg images of people. You can run# this program on them and see the detections by executing the# following command:# ./face_detector.py ../examples/faces/*.jpg## This face detector is made using the now classic Histogram of Oriented# Gradients (HOG) feature combined with a linear classifier, an image# pyramid, and sliding window detection scheme. This type of object detector# is fairly general and capable of detecting many types of semi-rigid objects# in addition to human faces. Therefore, if you are interested in making# your own object detectors then read the train_object_detector.py example# program. ### COMPILING THE DLIB PYTHON INTERFACE# Dlib comes with a compiled python interface for python 2.7 on MS Windows. If# you are using another python version or operating system then you need to# compile the dlib python interface before you can use this file. To do this,# run compile_dlib_python_mole.bat. This should work on any operating# system so long as you have CMake and boost-python installed.# On Ubuntu, this can be done easily by running the command:# sudo apt-get install libboost-python-dev cmake## Also note that this example requires scikit-image which can be installed# via the command:# pip install -U scikit-image# Or downloaded from . import sys
import dlib
from skimage import io
detector = dlib.get_frontal_face_detector()
win = dlib.image_window()
print("a");for f in sys.argv[1:]:
print("a");
print("Processing file: {}".format(f))
img = io.imread(f)
# The 1 in the second argument indicates that we should upsample the image
# 1 time. This will make everything bigger and allow us to detect more
# faces.
dets = detector(img, 1)
print("Number of faces detected: {}".format(len(dets))) for i, d in enumerate(dets):
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
i, d.left(), d.top(), d.right(), d.bottom()))
win.clear_overlay()
win.set_image(img)
win.add_overlay(dets)
dlib.hit_enter_to_continue()# Finally, if you really want to you can ask the detector to tell you the score# for each detection. The score is bigger for more confident detections.# Also, the idx tells you which of the face sub-detectors matched. This can be# used to broadly identify faces in different orientations.if (len(sys.argv[1:]) > 0):
img = io.imread(sys.argv[1])
dets, scores, idx = detector.run(img, 1) for i, d in enumerate(dets):
print("Detection {}, score: {}, face_type:{}".format(
d, scores[i], idx[i]))5767778798081
我把源代碼精簡了一下,加了一下注釋: face_detector0.1.py
# -*- coding: utf-8 -*-import sys
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:]: #輸出目前處理的圖片地址
print("Processing file: {}".format(f)) #使用skimage的io讀取圖片
img = io.imread(f) #使用detector進行人臉檢測 dets為返回的結果
dets = detector(img, 1) #dets的元素個數即為臉的個數
print("Number of faces detected: {}".format(len(dets))) #使用enumerate 函數遍歷序列中的元素以及它們的下標
#下標i即為人臉序號
#left:人臉左邊距離圖片左邊界的距離 ;right:人臉右邊距離圖片左邊界的距離
#top:人臉上邊距離圖片上邊界的距離 ;bottom:人臉下邊距離圖片上邊界的距離
for i, d in enumerate(dets):
print("dets{}".format(d))
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}"
.format( i, d.left(), d.top(), d.right(), d.bottom())) #也可以獲取比較全面的信息,如獲取人臉與detector的匹配程度
dets, scores, idx = detector.run(img, 1)
for i, d in enumerate(dets):
print("Detection {}, dets{},score: {}, face_type:{}".format( i, d, scores[i], idx[i]))
#繪制圖片(dlib的ui庫可以直接繪制dets)
win.set_image(img)
win.add_overlay(dets) #等待點擊
dlib.hit_enter_to_continue()041424344454647484950
分別測試了一個人臉的和多個人臉的,以下是運行結果:
運行的時候把圖片文件路徑加到後面就好了
python face_detector0.1.py ./data/3.jpg12
一張臉的:
兩張臉的:
這里可以看出側臉與detector的匹配度要比正臉小的很多
2.人臉關鍵點提取
人臉檢測我們使用了dlib自帶的人臉檢測器(detector),關鍵點提取需要一個特徵提取器(predictor),為了構建特徵提取器,預訓練模型必不可少。
除了自行進行訓練外,還可以使用官方提供的一個模型。該模型可從dlib sourceforge庫下載:
arks.dat.bz2
也可以從我的連接下載:
這個庫支持68個關鍵點的提取,一般來說也夠用了,如果需要更多的特徵點就要自己去訓練了。
dlib-18.17/python_examples/face_landmark_detection.py 源程序:
#!/usr/bin/python# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt## This example program shows how to find frontal human faces in an image and# estimate their pose. The pose takes the form of 68 landmarks. These are# points on the face such as the corners of the mouth, along the eyebrows, on# the eyes, and so forth.## This face detector is made using the classic Histogram of Oriented# Gradients (HOG) feature combined with a linear
㈦ 關於python人臉識別的問題
應該是沒有找到分類器編碼文件,把 haarcascade_frontalface_default.xml, haarcascade_eye.xml文件放到項目根目錄下,再用cv.CascadeClassifier(path1), cv.CascadeClassifier(path2)兩個API導入,另python下windows的文件路徑要用 \\ 或者 /
㈧ 人臉識別軟體
可以做到人臉識別的系統可以給你推薦臉探app。功能多,而且通過掃描人臉照片就能夠識別,還有一定的商業價值,能追蹤在逃人員,走失老人或孩童等。
臉搜,這個還是比較贊的,功能多,而且通過掃描人臉照片就能夠識別。
介紹。
Ageitgey
Ageitgey是最流行的免費人臉識別軟體,它在GitHub上也有37.6k的星星。該軟體可以通過Python API或其二進制命令行工具使用。這個平台有關於安裝的所有說明,這使得它更加有趣和流行。
2.CompreFace
CompreFace於2020年在GitHub上發布,擁有約900顆星星。它是少數幾個只需一個docker compose命令即可使用的自託管REST API自由人臉識別軟體之一。該軟體可以識別多個視頻流中的人臉。CompreFace還有一個用於管理用戶角色和面部集合的UI。
3.DeepFace
DeepFace於2020年在Github上發布,擁有約1100顆星星。這個免費的人臉識別軟體支持不同的人臉識別方法,如FaceNet和Insightface。
4.FaceNet
FaceNet是一個由谷歌研究人員創建的免費人臉識別程序,它是一個開源Python庫,實現了該程序。FaceNet具有很高的准確性,但唯一的缺點是它沒有RESTAPI。5.InsightFace
InsightFace是另一款免費人臉識別軟體,擁有約800顆星星。該軟體使用最新和准確的人臉識別方法。InsightFace與以下軟體一樣准確。
㈨ 人臉識別為什麼用python開發
可以使用OpenCV,OpenCV的人臉檢測功能在一般場合還是不錯的。而ubuntu正好提供了python-opencv這個包,用它可以方便地實現人臉檢測的代碼。
寫代碼之前應該先安裝python-opencv:
#!/usr/bin/python
#-*-coding:UTF-8-*-
#face_detect.py
#FaceDetectionusingOpenCV.Basedonsamplecodefrom:
#http://python.pastebin.com/m76db1d6b
#Usage:pythonface_detect.py<image_file>
importsys,os
fromopencv.cvimport*
fromopencv.highguiimport*
fromPILimportImage,ImageDraw
frommathimportsqrt
defdetectObjects(image):
""""""
grayscale=cvCreateImage(cvSize(image.width,image.height),8,1)
cvCvtColor(image,grayscale,CV_BGR2GRAY)
storage=cvCreateMemStorage(0)
cvClearMemStorage(storage)
cvEqualizeHist(grayscale,grayscale)
cascade=cvLoadHaarClassifierCascade(
'/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml',
cvSize(1,1))
faces=cvHaarDetectObjects(grayscale,cascade,storage,1.1,2,
CV_HAAR_DO_CANNY_PRUNING,cvSize(20,20))
result=[]
forfinfaces:
result.append((f.x,f.y,f.x+f.width,f.y+f.height))
returnresult
defgrayscale(r,g,b):
returnint(r*.3+g*.59+b*.11)
defprocess(infile,outfile):
image=cvLoadImage(infile);
ifimage:
faces=detectObjects(image)
im=Image.open(infile)
iffaces:
draw=ImageDraw.Draw(im)
forfinfaces:
draw.rectangle(f,outline=(255,0,255))
im.save(outfile,"JPEG",quality=100)
else:
print"Error:cannotdetectfaceson%s"%infile
if__name__=="__main__":
process('input.jpg','output.jpg')