Cov txheej txheem:
- Kauj Ruam 1: Yam Koj Yuav Tsum Tau:
- Kauj Ruam 2: Teeb tsa Python Environment:
- Kauj ruam 3: Python Script:
- Kauj Ruam 4: Arduino Code:
- Kauj Ruam 5: Yias-Tilt Mechanism:-
- Kauj Ruam 6: Ua Kev Sib Txuas:
- Kauj Ruam 7: Xeem:
Video: FACE TRACKING SIV ARDUINO !!!: 7 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Hauv cov lus qhia yav dhau los Kuv tau qhia koj li cas koj tuaj yeem sib tham ntawm Arduino thiab Python siv 'pyserial' module thiab tswj LED. Yog tias koj tsis tau pom nws txheeb xyuas nws ntawm no: Kev Sib Tham BETWEEN ARDUINO & PYTHON!
Thiab yuav ua li cas koj tuaj yeem kuaj pom xim ntawm ib yam khoom thiab taug qab nws ntawm lub vijtsam, Txheeb tawm ntawm no: COLOR DETECTION USEN OPENCV THIAB PYTHON.
Hauv Cov Lus Qhia Kuv yuav qhia koj yuav ua li cas taug qab lub ntsej muag siv Arduino & Python thiab ua Lub Koob Yees Duab ua raws lub ntsej muag. Qhov no yuav zoo li nyuaj tab sis ntseeg kuv nws tsis yog, Txhua yam koj xav tau yog kev paub yooj yim ntawm Arduino thiab Python.
Yog li cia pib …
Kauj Ruam 1: Yam Koj Yuav Tsum Tau:
Cov tseev kom muaj yog yam tsawg kawg nkaus. Ntawm no kuv tau muab cov npe ib feem ntawm txhua yam koj xav tau:
Yuav Tsum Tau Kho Vajtse:
- Arduino UNO (Amazon Asmeskas / Amazon EU)
- Web Cam (Amazon US / Amazon EU)
- Servos x 2 (Amazon US / Amazon EU)
- Breadboard (Amazon US / Amazon EU)
- Servo Pan Tilt Kit (Amazon US / Amazon EU)
Software Yuav Tsum Tau:
- Python 2.7 (Yuav tsum tau teeb tsa, Linux OS feem ntau muaj nws tau teeb tsa ua ntej)
- OpenCV (Koj tuaj yeem rub nws cais lossis teeb tsa siv 'pip install' Piav qhia ntxiv)
- pyserial (Tau muab ntsia nrog pip)
- xov.
- Haarcascade.
Tom qab txhua yam tau sib sau ua ke peb tuaj yeem txav mus rau Txoj Kev Txhim Kho…
Kauj Ruam 2: Teeb tsa Python Environment:
Txhim kho Python:
Yog li ua ntej peb xav tau Python 2.7 nce thiab khiav. Txhawm rau ua qhov no thawj zaug rub tawm thiab Nruab Python 2.7.14. Txhawm rau txheeb xyuas yog tias nws tau teeb tsa kom raug Goto: Windows Search >> Type "IDLE" >> Hit Enter. Python Plhaub yuav tsum tshwm sim.
LOS YOG
Hauv kev tshawb nrhiav hom 'CMD' thiab ntaus nkag mus qhib Command Prompt. Hauv CMD hom >> nab nab thiab ntaus nkag, Python interface yuav tsum tso tawm.
Yog tias koj pom qhov yuam kev hauv CMD, Tsis txhob ntshai koj yuav xav tau teeb tsa ib puag ncig sib txawv. Koj tuaj yeem ua raws cov ntawv qhia no Ntawm no kom teeb tsa Ib puag ncig hloov pauv.
Txhim kho 'pyserial', 'OpenCV "thiab" numpy "hauv nab hab sej:
Txhawm rau teeb tsa cov qauv no peb yuav siv siv pip nruab, Ua ntej qhib CMD thiab ntaus cov lej hauv qab no:-
pip nruab serial
pip nruab opencv-python> pip nruab numpy
cov lus txib no yuav teeb tsa cov qauv tsim nyog. Tam sim no peb tuaj yeem txav mus rau qhov coding…
Kauj ruam 3: Python Script:
Ua ntej pib sau cov cai thawj qhov uas yuav tsum tau ua yog tsim daim nplaub tshev tshiab raws li txhua tus lej yuav tsum tau muab khaws cia rau hauv tib daim nplaub tshev. Yog li tsim cov ntawv tshiab, npe nws txhua yam koj xav tau. thiab rub tawm 'Haarcascade' los ntawm hauv qab no thiab muab tso rau hauv daim nplaub tshev.
Tam sim no qhib notepad thiab sau cov ntawv hauv qab no, Txuag nws li 'face.py' hauv tib daim nplaub tshev zoo li haarcascade. (Koj tuaj yeem rub tus lej Kuv tau muab cov ntawv hauv qab no):
#ntshuam txhua qhov qauv xav tau
ntshuam numpy li np ntshuam lub sijhawm ntshuam ntshuam sys ntshuam cv2 #Setup Kev sib txuas lus rau arduino (Qhov chaw ntawm 'COM5' muab qhov chaw nres nkoj uas koj txuas nrog arduino txuas nrog) arduino = serial. Serial ('COM5', 9600) sijhawm.sleep (2) luam tawm ("Txuas rau arduino …") #importing Haarcascade rau lub ntsej muag nrhiav ntsej muag_cascade = cv2. CascadeClassifier ('haarcascade_frontalface_default.xml') #Txhawm rau ntes cov vis dis aus los ntawm webcam. cap = cv2. VideoCapture (0) #Nyeem cov duab uas pom, hloov nws mus rau Grey duab thiab pom ntsej muag thaum 1: ret, img = cap.read () cv2.resizeWindow ('img', 500, 500) cv2.line (img, (500, 250), (0, 250), (0, 255, 0), 1) cv2.line (img, (250, 0), (250, 500), (0, 255, 0), 1) cv2.circle (img, (250, 250), 5, (255, 255, 255), -1) grey = cv2.cvtColor (img, cv2. COLOR_BGR2GRAY) face = face_cascade.detectMultiScale (grey, 1.3) # ntes lub ntsej muag thiab ua lub duab plaub nyob ib puag ncig nws. rau (x, y, w, h) hauv ntsej muag: cv2.rectangle (img, (x, y), (x+w, y+h), (0, 255, 0), 5) roi_gray = grey [y: y+h, x: x+w] roi_color = img [y: y+h, x: x+w] arr = {y: y+h, x: x+w} print (arr) print ('X: '+str (x)) print (' Y: '+str (y)) print (' x+w: '+str (x+w)) print (' y+h: '+str (y+h))) # Center of roi (Rectangle) xx = int (x+(x+h))/2 yy = int (y+(y+w))/2 print (xx) print (yy) center = (xx, yy) # xa cov ntaub ntawv mus rau arduino print ("Center of Rectangle is:", center) data = "X {0: d} Y {1: d} Z".format (xx, yy) print ("output = '" +data + "'") arduino.write (cov ntaub ntawv) #Qhia cov kwj. cv2.imshow ('img', img) #Hit 'Esc' kom txiav qhov kev ua tiav k = cv2.waitKey (30) & 0xff yog k == 27: so
Thaum qhov no ua tiav, txav mus rau sau cov cai rau arduino …
Kauj Ruam 4: Arduino Code:
Tom qab ntawv nab hab sej npaj txhij peb xav tau arduino kos duab los tswj cov servo. Xa cov cai hauv qab no, muab tshuaj txhuam nws tso rau hauv Arduino IDE thiab txuag nws li 'servo.ino' hauv tib daim nplaub tshev zoo li face.py thiab haarcascade. upload cov cai thiab txav mus rau cov kauj ruam tom ntej los ua kev sib txuas.
(Cov ntaub ntawv rub tawm tau muab rau hauv qab no)
#suav nrog
Servo tsav; // Ntsug Servo Servo servoHor; // Kab rov tav Servo int x; tus y; koj prevX; koj prevY; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); servoVer.attach (5); // Txuas Vertical Servo rau Pin 5 servoHor.attach (6); // Txuas Kab Rov Tav Servo rau Pin 6 servoVer.write (90); servoHor.write (90); } void Pos () {if (prevX! = x || prevY! = y) {int servoX = daim ntawv qhia (x, 600, 0, 70, 179); int servoY = daim ntawv qhia (y, 450, 0, 179, 95); servoX = min (servoX, 179); servoX = max (servoX, 70); servoY = min (servoY, 179); servoY = max (servoY, 95); servoHor.write (servoX); servoVer.write (servoY); }} void loop () {if (Serial.available ()> 0) {if (Serial.read () == 'X') {x = Serial.parseInt (); yog (Serial.read () == 'Y') {y = Serial.parseInt (); Pos (); }} thaum (Serial.available ()> 0) {Serial.read (); }}}
Kauj Ruam 5: Yias-Tilt Mechanism:-
Kuv tau siv cov khoom siv npaj tau rau Pan-Tilt. Yog tias koj xav tau koj tuaj yeem ua ib tus kheej siv ntoo/Yas lossis txawm tias 3D luam tawm ib qho.
Qhov kuv siv yog pheej yig zoo nkauj, thiab yooj yim heev rau sib sau ua ke. Txawm li cas los xij yog tias koj xav tau cov lus qhia yuav ua li cas, koj tuaj yeem pom nws ntawm no.
Kauj Ruam 6: Ua Kev Sib Txuas:
Circuit Court yog yooj yim zoo nkauj. Tsuas yog txuas ob lub servos rau arduino.
- Ntsug rau tus Pin 5
- Kab rov tav rau Pin 6
- Lub zog rau +5V
- Hauv av rau GND
Txheeb xyuas daim duab hluav taws xob rau kev siv.
Kauj Ruam 7: Xeem:
- Tom qab txhua yam ua tiav qhov kawg uas yuav tsum tau ua yog kuaj yog tias nws ua haujlwm. Txhawm rau sim ua ntej kom paub tseeb tias servos tau txuas nrog rau arduino thiab kos duab tau muab tso rau.
- Tom qab kos duab tau rub tawm kom paub tseeb tias kaw IDE yog li qhov chaw nres nkoj tau pub dawb txuas rau nab hab sej.
- Tam sim no qhib 'face.py' nrog Python IDLE thiab nias 'F5' kom ua raws txoj cai. Nws yuav siv ob peb feeb los txuas rau arduino thiab tom qab ntawd koj yuav tsum muaj peev xwm pom lub qhov rai ntws ntawm lub vev xaib. Tam sim no tus lej yuav txheeb xyuas koj lub ntsej muag thiab cov servos yuav taug qab nws taug qab nws.
- Lub Servo yuav tsum txav thaum koj txav cov khoom. Tam sim no tsuas yog txuas lub koob yees duab rau servos yog li nws yuav txav mus nrog servos.
Ua tsaug.
Pom zoo:
Cov Khoom Siv Teeb Meem Siv Chaw Taws Teeb Siv Arduino: 7 Kauj Ruam
Cov Khoom Siv Teeb Meem Siv Khoom Siv Hluav Taws Xob Siv Arduino: Tam sim no, Cov Tsim, Cov tsim tawm tau nyiam Arduino rau kev txhim kho sai ntawm cov qauv ntawm cov phiaj xwm. Arduino yog lub platform siv hluav taws xob qhib raws qhov yooj yim-rau-siv-kho vajtse thiab software. Arduino muaj zej zog cov neeg siv zoo heev. Hauv qhov no
Saib Xyuas Kev Siv Sijhawm Siv Raspberry Pi thiab AIS328DQTR Siv Python: 6 Cov Kauj Ruam
Saib Xyuas Kev Siv Sijhawm Siv Raspberry Pi thiab AIS328DQTR Siv Python: Kev nrawm yog qhov kawg, Kuv xav raws li qee txoj cai ntawm Physics.- Terry Riley Tus cheetah siv qhov nrawm nrawm thiab hloov pauv sai thaum caum. Tus tsiaj nrawm tshaj plaws nyob ntawm ntug hiav txwv ib zaug hauv ib lub sijhawm siv nws qhov nrawm tshaj plaws kom ntes tau cov tsiaj txhu. Qhov
Tsis Siv Neeg Kev Hla Hla Kev Siv Hluav Taws Xob Siv Arduino Raws Kev Nkag Nkag Platform: 9 Cov Kauj Ruam
Tsis Siv Neeg Kev Hla Hla Kev Siv Hluav Taws Xob Siv Arduino Raws Kev Nkag Siab Platform: Christmas tsuas yog ib lub lim tiam xwb! Txhua leej txhua tus tibneeg hu tauj coob nrog kev ua koob tsheej thiab tau txais khoom plig, uas, los ntawm txoj kev, tau txais txhua qhov nyuaj dua kom tau nrog qhov tsis muaj peev xwm nyob ib puag ncig peb. Yuav ua li cas mus los ntawm khoom plig qub thiab ntxiv qhov kov ntawm DIY rau
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej
Tsiv Tawm Sijhawm Siv Arduino + DS1307 + Neopixel: Rov Siv Qee Cov Khoom Siv: 5 Kauj Ruam
Tawm Tawm Sijhawm Siv Arduino + DS1307 + Neopixel: Rov Siv Qee Cov Khoom Siv: Los ntawm cov phiaj xwm yav dhau los Kuv muaj Arduino UNO thiab Neopixel LED sawb sab laug, thiab xav ua qee yam txawv. Vim tias Neopixel sawb muaj 60 LED teeb, xav siv nws los ua lub moos loj. Txhawm rau qhia Lub Sijhawm, liab 5-LED ntu tau siv (60 LED