Python影像辨識筆記(一):使用Open CV辨識圖片及影片中的人臉

文章推薦指數: 80 %
投票人數:10人

圖片人. “Python影像辨識筆記(一):使用Open CV辨識圖片及影片中的人臉” is published by Yanwei Liu. GetstartedOpeninappYanweiLiuSigninGetstarted1.3KFollowersAboutGetstartedOpeninappPython影像辨識筆記(一):使用OpenCV辨識圖片及影片中的人臉YanweiLiuApr25,2019·5minread以電影海報為例圖片人臉安裝模組pipinstallopencv-python偵測人臉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)#顯示成果cv2.namedWindow('img',cv2.WINDOW_NORMAL)#正常視窗大小cv2.imshow('img',img)#秀出圖片cv2.imwrite("result.jpg",img)#保存圖片cv2.waitKey(0)#等待按下任一按鍵cv2.destroyAllWindows()#關閉視窗scaleFactor:Parameterspecifyinghowmuchtheimagesizeisreducedateachimagescale.Increasingitleadstofasterdetectionwiththeriskofmissingsomeobjects,whereasasmallvaluemightsometimesbetoothorough.minNeighbors:Parameterspecifyinghowmanyneighborseachcandidaterectangleshouldhavetoretainit.Highervalueresultsinlessdetectionbutwithhigherquality.minSize:Minimumpossibleobjectsize.Objectssmallerthanthatareignored.maxSize:Maximumpossibleobjectsize.Objectslargerthanthatareignored.原始圖片影片人臉importcv2#載入分類器face_cascade=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')#從視訊盡頭擷取影片cap=cv2.VideoCapture(0)或者....#使用現有影片cap=cv2.VideoCapture('filename.mp4')whileTrue:#Readtheframe_,img=cap.read()#轉成灰階gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)#偵測臉部faces=face_cascade.detectMultiScale(gray,1.1,4)#繪製人臉部份的方框for(x,y,w,h)infaces:cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)#顯示成果cv2.namedWindow('img',cv2.WINDOW_NORMAL)#正常視窗大小cv2.imshow('img',img)#秀出圖片#Stopifescapekeyispressedk=cv2.waitKey(30)&0xffifk==27:break#ReleasetheVideoCaptureobjectcap.release()cv2.destroyAllWindows()adarsh1021/facedetectionEasyfacedetectionusingopenCV.Contributetoadarsh1021/facedetectiondevelopmentbycreatinganaccountonGitHub.github.comPython與OpenCV基本讀取、顯示與儲存圖片教學-G.T.Wang這裡介紹如何使用Python與OpenCV讀取影像圖檔,以及將處理好的圖形寫入檔案。

首先引入NumPy與OpenCV的Python模組:OpenCV本身就有提供讀取圖片檔的函數可用,讀取一般的圖片檔,只要呼叫…blog.gtwang.org如何破解並繞過網頁上常見的Captcha驗證?以2CaptchaAPI為例2Captcha是一個非常強大的CAPTCHA辨識服務。

在我們日常生活當中,如果要登入網站(如:AWS的帳戶登入頁面),可能就會遇到需要手動輸入驗證碼的視窗,有些可能單純只是英文及數字的組合。

但是有些卻極度複雜,扭曲的字體及顏色,常常讓使用…yanwei-liu.medium.comYanweiLiuMachineLearning|DeepLearning|https://linktr.ee/yanweiFollow8686 86PythonArtificialIntelligenceMachineLearningImageRecognitionFacedetectionMorefromYanweiLiuFollowMachineLearning|DeepLearning|https://linktr.ee/yanwei



請為這篇文章評分?