使用Python的OpenCV進行圖片人臉辨識
文章推薦指數: 80 %
使用Python的OpenCV進行圖片人臉辨識. GitHub Gist: instantly share code, notes, and snippets. Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. e96031413/opencv-image.py LastactiveOct21,2019 Star 0 Fork 0 Star Code Revisions 2 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP 使用Python的OpenCV進行圖片人臉辨識 Raw opencv-image.py ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters importcv2 #載入分類器 face_cascade=cv2.CascadeClassifier('haarcascade_frontalface_default.xml') #讀取圖片 img=cv2.imread('a.jpg') #轉成灰階圖片 gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #偵測臉部 faces=face_cascade.detectMultiScale( gray, scaleFactor=1.08, minNeighbors=5, minSize=(32,32)) #繪製人臉部份的方框 for(x,y,w,h)infaces: cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) #(0,255,0)欄位可以變更方框顏色(Blue,Green,Red) #計算找到幾張臉 print("找到了{0}張臉.".format(len(faces))) #顯示成果 cv2.namedWindow('img',cv2.WINDOW_NORMAL)#正常視窗大小 cv2.imshow('img',img)#秀出圖片 cv2.imwrite("result.jpg",img)#保存圖片 cv2.waitKey(0)#等待按下任一按鍵 cv2.destroyAllWindows()#關閉視窗 Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1Python影像辨識筆記(一):使用Open CV辨識圖片及影片中的人臉
pip install opencv-python. 偵測人臉. import cv2# 載入分類器 face_cascade = cv2.CascadeClassifier('haarcasc...
- 2Raspberry3使用WebCam+OpenCV進行人臉辨識 - Google Sites
Raspberry3使用WebCam+OpenCV進行人臉辨識 ... Step3)使用指令「mkdir images」新增資料夾images。假設以下程式為1.py,使用「python3 1....
- 3Python 使用OpenCV、Dlib 實作即時人臉偵測程式教學
這裡示範如何在Python 中使用OpenCV 與Dlib 開發人臉偵測程式,即時擷取網路攝影機串流影像,輸出人臉偵測結果。 人臉偵測是一項相當成熟的技術,不管 ...
- 4利用python、tensorflow、opencv實現人臉識別(包會)!
opencv -- 3.3.1. keras -- 3.0.X. sklearn -- 0.19.0. 三、正式開始. 1,識別人臉.
- 5[Day13] 使用OpenCV & Dlib作人臉偵測需要知道的一些事
本文開始回顧一下過去四天提到的,使用OpenCV & Dlib做人臉偵測的方法: OpenCV Haar cascades:哈爾特徵檢測法OpenCV deep neural networ...