Cov txheej txheem:
- Kauj Ruam 1: Tshawb Pom Lub Ntsej Muag Hauv Lub Sijhawm Yees Duab
- Kauj Ruam 2: Qhia Koj Cov Qauv Piv Txwv
- Kauj Ruam 3: Paub Lub ntsej muag
Video: Kev Nrhiav Kom Ntsej Muag Opencv, Kev Qhia thiab Kev Paub: 3 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
OpenCV yog lub tsev qhib lub khoos phis tawj lub zeem muag pom uas nrov heev rau kev ua cov duab yooj yim ua haujlwm xws li qhov muag plooj, cov duab sib xyaw, txhim kho cov duab nrog rau cov vis dis aus zoo, thresholding thiab lwm yam Ntxiv nrog rau kev ua cov duab, nws muab ntau yam kev kawm ua ntej cov qauv uas tuaj yeem siv ncaj qha los daws cov haujlwm yooj yim ntawm tes.
rau kev teeb tsa opencv siv qhov txuas no
www.instructables.com/id/Opencv-and-Python…
Kauj Ruam 1: Tshawb Pom Lub Ntsej Muag Hauv Lub Sijhawm Yees Duab
koj tuaj yeem tshawb nrhiav google rau ntau lub program nrhiav lub ntsej muag thiab lub ntsej muag uas pom yuav tsum tau khaws tseg hauv daim nplaub tshev rau ntxiv cov duab ua tej yam xws li kev qhia thiab cim npe. peb yuav mus sau 30 qhov qauv
ua cv2
import numpy as np
import os import sys
lub koob yees duab = cv2. VideoCapture (0)
faceCascade = cv2. CascadeClassifier ("haarcascade_frontalface_default.xml") #ntxiv koj cov ntaub ntawv harcascade
name = raw_input ("Nws lub npe hu li cas?")
#tag nrho cov ntaub ntawv yuav raug khaws tseg hauv Cov Neeg Siv/prasad/Cov Ntaub Ntawv/duab nplaub tshev
dirName = "/Cov neeg siv/prasad/Cov ntaub ntawv/duab/" + lub npe
print (dirName) yog tias tsis os.path.exists (dirName): os.makedirs (dirName) print ("Tsim Cov Ntawv Teev Npe") lwm qhov: print ("Lub npe twb muaj lawm") sys.exit ()
suav = 1
#peb yuav sau 30 qhov qauv
thaum suav 30: so # thav duab = frame.array grey = cv2.cvtColor (thav duab, cv2. COLOR_BGR2GRAY) ntsej muag = faceCascade.detectMultiScale (grey, 1.5, 5) rau (x, y, w, h) hauv ntsej muag: roiGray = grey [y: y + h, x: x + w] fileName = dirName + "/" + name + str (count) + ".jpg" cv2.imwrite (fileName, roiGray) cv2.imshow ("ntsej muag", roiGray) cv2.rectangle (thav duab, (x, y), (x+w, y+h), (0, 255, 0), 2) suav+= 1 cv2.imshow ('thav duab', thav duab) qhov tseem ceeb = cv2.txogKey (1)
yog qhov tseem ceeb == 27:
so
#lub koob yees duab.release ()
cv2.destroyAllWindows ()
Kauj Ruam 2: Qhia Koj Cov Qauv Piv Txwv
Tom qab Kev Pom Lub ntsej muag tau ua tiav ces peb tuaj yeem mus rau kev qhia cov duab
import osimport numpy as np from PIL import Image import cv2 import pickle #import serial
#ser = serial. Serial ('/dev/ttyACM0', 9600, sijhawm = 1)
faceCascade = cv2. CascadeClassifier ("haarcascade_frontalface_default.xml")
lees paub = cv2.face. LBPHFaceRecognizer_create ()
baseDir = os.path.dirname (os.path.abspath (_ file_))
#qhia cov duab hauv qab cov ntawv tais ceev tseg
imageDir = os.path.join (baseDir, "duab")
currentId = 1
labelIds = {} yLabels = xTrain = #ser.write ("Kev cob qhia …" "encode ())
rau hauv paus, dirs, cov ntaub ntawv hauv os.walk (imageDir):
print (hauv paus, dirs, cov ntaub ntawv) rau cov ntaub ntawv hauv cov ntaub ntawv: luam tawm (cov ntaub ntawv) yog file.endswith ("png") lossis file.endswith ("jpg"): path = os.path.join (root, file) label = os.path.basename (hauv paus) luam tawm (daim ntawv lo)
yog tias tsis sau rau hauv labelIds:
labelIds [daim ntawv lo] = currentId luam tawm (labelIds) currentId += 1
id_ = labelIds [daim ntawv lo]
pilImage = Image.open (path).convert ("L") imageArray = np.array (pilImage, "uint8") face = faceCascade.detectMultiScale (imageArray, scaleFactor = 1.1, min Neighbors = 5)
rau (x, y, w, h) hauv ntsej muag:
roi = imageArray [y: y+h, x: x+w] xTrain.append (roi) yLabels.append (id_)
with open ("labels", "wb") as f:
pickle.dump (labelIds, f) f.close ()
recognizer.train (xTrain, np.array (yLabels))
recognizer.save ("trainer.yml") luam tawm (labelIds)
Kauj Ruam 3: Paub Lub ntsej muag
tom qab kev kawm tiav tam sim no koj tuaj yeem ua raws cov cai hauv qab no kom nws yuav pib lees paub koj lub ntsej muag uas tau kawm tiav
ntshuam osos.environ ['PYTHONINSPECT'] = 'on' import cv2 import numpy as np import pickle #import RPi. GPIO as GPIO from time import sleep
nrog qhib ('ntawv cim', 'rb') raws li f:
dicti = pickle.load (f) f.close ()
lub koob yees duab = cv2. VideoCapture (0)
faceCascade = cv2. CascadeClassifier ("haarcascade_frontalface_default.xml")
lees paub = cv2.face. LBPHFaceRecognizer_create () lees paub.read ("tus kws qhia.yml")
font = cv2. FONT_HERSHEY_SIMPLEX
kawg = ''
#rau thav duab hauv camera.capture_continuous (rawCapture, format = "bgr", use_video_port = True):
thaum muaj tseeb: ret, thav duab = camera.read () grey = cv2.cvtColor (thav duab, cv2. COLOR_BGR2GRAY) ntsej muag = faceCascade.detectMultiScale (grey, scaleFactor = 1.5, min Neighbors = 5) rau (x, y, w, h) hauv ntsej muag: roiGray = grey [y: y+h, x: x+w]
id_, conf = recognizer.predict (roiGray)
rau lub npe, tus nqi hauv dicti.items ():
yog tus nqi == id_: print (name) cv2.putText (thav duab, lub npe, (x, y), font, 2, (0, 0, 255), 2, cv2. LINE_AA) yog lub npe! = xeem: xeem = npe if conf <= 70: cv2.rectangle (thav duab, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.imshow ('thav duab', thav duab)
qhov tseem ceeb = cv2.waitKey (1)
yog qhov tseem ceeb == 27:
tawg cv2.destroyAllWindows ()
Pom zoo:
Ntsej Muag Ntsej Muag Nrog E-Ntawv Zaub: 9 Kauj Ruam (nrog Duab)
Lub ntsej muag lub ntsej muag nrog E-Ntawv Zaub: Tus kab mob corona tshwm sim tau coj ib qho tshiab ntawm kev zam rau ntiaj teb sab hnub poob: lub ntsej muag lub ntsej muag. Thaum lub sijhawm sau ntawv, lawv tau dhau los ua yuam kev hauv Tebchaws Yelemees thiab lwm qhov hauv Tebchaws Europe rau niaj hnub siv hauv kev thauj mus los rau pej xeem, mus yuav khoom thiab ntau yam ntxiv
Lub ntsej muag lees paub thiab cim npe - Arduino Face ID Siv OpenCV Python thiab Arduino.: 6 Kauj Ruam
Lub ntsej muag lees paub thiab cim npe | Arduino Face ID Siv OpenCV Python thiab Arduino: Lub ntsej muag paub AKA ntsej muag ID yog ib qho tseem ceeb tshaj plaws ntawm cov xov tooj ntawm tes niaj hnub no. Yog li, kuv muaj lus nug " Kuv puas tuaj yeem muaj lub ntsej muag id rau kuv qhov Arduino project " thiab cov lus teb yog yog … Kuv cov lus pib raws li hauv qab no: Kauj Ruam 1: Nkag mus rau peb
Lub Ntsej Muag Ntsej Muag Ntsej Muag => Covid Tiv Thaiv!: 5 Kauj Ruam
Lub Ntsej Muag Ntsej Muag Ntsej Muag => Covid Tiv Thaiv!: Tus naj npawb 1 yam uas cov neeg saib xyuas kev noj qab haus huv xav kom tib neeg ua thaum lub sijhawm muaj tus kabmob kis no yog hnav lub ntsej muag thaum tawm mus rau qhov chaw pej xeem, tab sis qee tus neeg tseem ua qhov muag tsis pom qhov lus ceeb toom. Nkag mus ….. COVID PrevEnter! Tus neeg hlau no siv lub koob yees duab Pixy2
Nrhiav Lub ntsej muag thiab luag ntxhi Nrhiav Xus Neeg Hlau: 8 Kauj Ruam (nrog Duab)
Nrhiav ntsej muag thiab luag ntxhi Nrhiav Xus Neeg Hlau: Xus los txog! Peb txiav txim siab tsim ib yam txias. Ntsib Ghosty thiab Skully robots. Lawv tuaj yeem ua raws koj lub ntsej muag thiab lawv paub thaum koj luag ntxhi kom luag nrog koj! Txoj haujlwm no yog lwm qhov piv txwv ntawm kev siv iRobbie App uas hloov iPhone int
Ntsej Muag thiab Pom Qhov Muag Nrog Raspberry Pi Zero thiab Opencv: 3 Cov Kauj Ruam
Ntsej Muag thiab Pom Qhov Muag Nrog Raspberry Pi Zero thiab Opencv: Hauv cov lus qhia no kuv yuav qhia koj li cas tuaj yeem pom lub ntsej muag thiab qhov muag siv raspberry pi thiab opencv. Nov yog kuv thawj qhov kev qhia ntawm opencv. Kuv ua raws ntau qhov kev qhia kom teeb tsa qhib cv hauv raspberry tab sis txhua lub sijhawm tsoo nrog qee qhov yuam kev. Txawm li cas los kuv