Cov txheej txheem:
- Khoom siv
- Kauj Ruam 1: FaceDetect Function
- Kauj ruam 2: BackgroundRemove Function
- Kauj Ruam 3: VideoEdges Muaj nuj nqi
- Kauj ruam 4: VideoBlur Muaj nuj nqi
- Kauj Ruam 5: Kev txhim kho
Video: OpenCV Basic Projects: 5 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Hauv txoj haujlwm no, peb tshawb xyuas qee qhov yooj yim OpenCV kev ua haujlwm dhau los ntawm 4 txoj haujlwm yooj yim cuam tshuam nrog cov vis dis aus nyob. Cov no yog kev lees paub lub ntsej muag, tshem tawm keeb kwm yav dhau, ua kom pom kev tshwj xeeb ntawm cov npoo, thiab siv qhov ua kom pom tseeb rau cov vis dis aus nyob. Kuv lub hom phiaj tseem ceeb rau kev sim cov phiaj xwm no tsuas yog ua kom kuv txhais taw ntub nrog OpenCV interface, raws li kuv npaj yuav nkag mus tob hauv thaj tsam ntawm lub computer kev pom
Khoom siv
- Khoos phis tawj siv Python
- Qhib CV lub tsev qiv ntawv, Numpy tsev qiv ntawv, tkinter tsev qiv ntawv, sys tsev qiv ntawv
- Lub koob yees duab txuas rau lub khoos phis tawj (yog lub khoos phis tawj tsis suav nrog ib qho lawm)
- Program's sej file file (included in this instructable)
- haarcascade xml cov ntaub ntawv (suav nrog hauv cov lus qhia no)
Kauj Ruam 1: FaceDetect Function
Txoj haujlwm no qhia koj lub koob yees duab cov vis dis aus nrog cov plaub fab ntsuab ntawm txhua lub ntsej muag uas nws khaws. Hauv txoj cai, peb siv cv2. VideoCapture () muaj nuj nqi los khaws cov vis dis aus uas peb tab tom ntes hauv cov khoom hu ua "capture". CAPTURE_INDEX yog tus lej teev tseg los ntawm koj lub khoos phis tawj uas sib haum rau qhov ntsuas ntawm koj lub koob yees duab hauv lub khoos phis tawj cov npe nkag video. Yog tias koj tsis muaj lub koob yees duab sab nrauv txuas nrog koj lub khoos phis tawj, 0 lossis 1 yuav tsum ua haujlwm.
Lub ntsej muag_cascade cov khoom tau pib siv cov haujlwm cascadeClassifier thiab "haarcascade_frontalface_default.xml" cov ntaub ntawv pom hauv OpenCV github. Peb siv cov khoom no los khaws lub ntsej muag pom hauv cov npe "ntsej muag" raws li nkag plaub-txoj kev-tuple tuav lub ntsej muag x sib koom tes, y sib koom, dav thiab siab. Tom qab ntawd peb kos lub duab plaub uas zoo kawg nkaus npog lub ntsej muag siv cv2.rectangle muaj nuj nqi
Los ntawm cov vis dis aus no, OpenCV ntes ntau cov duab hauv peb thaum lub voj siv capture.read () thiab khaws cov duab hauv tus thav duab peb hu ua "img". Txhua daim duab yog tom qab ntawd txhais thiab hloov kho raws li peb xav tau. Txog lub ntsej muag, peb ua cov duab grey siv cvtColor ua haujlwm uas hloov pauv cov duab twg los xij hauv thawj qhov ntsuas rau yam tshwj xeeb ntawm cov duab xim tshwj xeeb hauv qhov ntsuas thib ob. Cov npe ntawm qhov muaj txiaj ntsig zoo rau qhov ntsuas thib ob tuaj yeem pom hauv online. Peb tom qab ntawd tso cov duab hauv lub qhov rai npe "Txheeb xyuas lub ntsej muag" siv qhov imshow () muaj nuj nqi uas siv txoj hlua rau lub npe qhov rai thiab cov duab thav duab kom pom.
Thaum kawg peb tos rau tus neeg siv nkag mus rau tus lej q siv cv2.waitKey () ua haujlwm. Lub npog ntsej muag 0xFF tau siv los ua kev pom zoo rau 64 lub khoos phis tawj me me. Tom qab tus neeg siv tau kaw cov vis dis aus, lub ntsej muag lub ntsej muag ua haujlwm tso cov khoom ntes tom qab ntawd rhuav tshem lwm lub qhov rais qhib hauv qab OpenCV interface. Tag nrho lwm txoj haujlwm ua raws cov qauv tsim zoo sib xws.
Kauj ruam 2: BackgroundRemove Function
Lub luag haujlwm no sim tshem tawm qhov keeb kwm yav dhau ntawm peb cov vis dis aus thiab tsuas yog tso duab ua ntej. Nws yuav tsis ua haujlwm ntawm qee lub koob yees duab, vim lawv siv lub teeb pom kev zoo ua haujlwm uas tau qhib thaum cov khoom sib txawv/ foci nkag mus rau hauv tus ncej. Yog tias koj keeb kwm yav dhau los Tshem tawm txoj haujlwm tsis ua haujlwm, tsis txhob txhawj xeeb- nws tsuas yog koj lub koob yees duab!
Txhawm rau siv txoj haujlwm no, txav deb ntawm lub koob yees duab thiab nias lub pob "d" txhawm rau ntes cov duab tom qab. Nws yog ib qho tseem ceeb uas tsis muaj cov khoom txav hauv keeb kwm yav dhau uas koj xav mus ntes. Tom qab ntawd, peb tuaj yeem rov qab mus rau lub koob yees duab thav duab. Yog tias txoj haujlwm ua haujlwm, tus neeg siv yuav tsum tsuas yog pom lawv tus kheej ntawm txoj haujlwm cov vis dis aus. Txhua lub suab nrov/blobs dub hauv cov duab ua ntej yuav yog los ntawm lub koob yees duab teeb pom kev zoo. Txhawm rau ntes lwm qhov keeb kwm yav dhau, nyem "r" tus yuam sij kom rov pib dua, tom qab ntawd nias "d" dua.
Qee qhov tseem ceeb ua rau lub luag haujlwm no yog kev siv "chij" boolean uas tau tsa tam sim tus neeg siv nias lub pob d. Qhov no ntes cov keeb kwm yav dhau los thiab tso cai rau peb tshem nws los ntawm cov vis dis aus uas tau ntws los ntawm txoj haujlwm. Peb lub hom phiaj khaws cov duab keeb kwm yav dhau los hauv ref_img kom peb tuaj yeem sib txawv nws los ntawm cov duab ua ntej, uas ntes txhua yam khoom txav. Peb siv cv2.subtract () ua haujlwm kom rho tawm cov duab hauv pem hauv ntej los ntawm cov duab tom qab thiab rov ua dua, tom qab ntawd tshem tawm ib qho kev sib txawv me me ntawm ob daim duab tam sim ntawd tom qab. Cov keeb kwm yav dhau yog blacked tawm.
Lub fgmask tau tsim los siv qhov sib txawv ntawm ob daim duab no thiab tom qab ntawv thov rau lub luag haujlwm video kwj siv OpenCV cv2.bitwise_and () muaj nuj nqi.
Kauj Ruam 3: VideoEdges Muaj nuj nqi
Lub luag haujlwm no rov qab los rau peb cov vis dis aus nyob, tab sis cov npoo tuaj yeem pom tau ua dawb thaum txhua yam ntxiv dub. Dab tsi txawv qhov kev ua haujlwm no los ntawm lwm txoj haujlwm yog kev hloov pauv ntawm peb cov yeeb yaj kiab qub los ntawm RBG hom rau HSV, uas sawv rau qhov hue, saturation thiab variation- qhov sib txawv ntawm kev ua lub teeb thiab xim los ntawm cov vis dis aus. Nrog rau txoj hauv kev no, peb tuaj yeem yooj yim dua qhov sib txawv hauv cov vis dis aus los ntawm kev siv lub lim (red_low rau red_high).
Canny Edge Detection yog siv txhawm rau txheeb xyuas cov npoo hauv cov duab. Nws lees txais cov duab nplai grey raws li cov tswv yim thiab nws siv ntau txheej txheej txheej txheem.
Kauj ruam 4: VideoBlur Muaj nuj nqi
Qhov haujlwm no yog siv los ntxiv qhov ua rau pom kev tsis zoo rau peb cov vis dis aus. Txoj haujlwm yooj yim hu rau GaussianBlur cv2 ua haujlwm ntawm peb tus ncej. Cov ntaub ntawv ntxiv ntawm kev ua haujlwm gaussianBlur tuaj yeem pom ntawm no:
opencv-python-tutroals.readthedocs.io/en/l…
Kauj Ruam 5: Kev txhim kho
Txoj haujlwm tseem ceeb tshaj plaws hauv txoj haujlwm no yog kev tshem tawm keeb kwm yav dhau, vim nws xav tau kev siv lub koob yees duab uas tsis muaj teeb pom kev zoo ua haujlwm. Tej zaum yuav muaj txheej txheem ua haujlwm tau zoo dua hauv OpenCV lub tsev qiv ntawv uas tuaj yeem suav txog qhov teeb pom kev zoo no thiab tshem tawm cov keeb kwm yav dhau los (zoo ib yam li lub vijtsam ntsuab).
Peb kuj tseem tuaj yeem siv lwm lub ntsej muag ntsuas lub luag haujlwm uas tuaj yeem tsim cov khoom nrog ua haujlwm tau zoo dua li tsuas yog rov qab (x, y) ua haujlwm. Tej zaum txoj haujlwm lees paub lub ntsej muag nrog lub peev xwm ntawm kev nco lub ntsej muag yuav tsis nyuaj rau siv.
Qhov kev ua haujlwm plooj tuaj yeem ua ntau qhov kev hloov pauv ntawm kev tswj hwm los ntawm tus neeg siv. Piv txwv li, tus neeg siv yuav xav hloov kho qhov siv qhov muag plooj lossis xaiv thaj chaw tshwj xeeb hauv tus ncej kom plooj.
Pom zoo:
Lub laptop txias Touchpad Hack rau Arduino Projects !: 18 Cov Kauj Ruam (nrog Duab)
Lub Txias Laptop Touchpad Hack rau Arduino Cov Haujlwm!: Ib pliag rov qab, thaum kuv tau tinkering ncig nrog PS/2 touchpad nrog Arduino microcontroller, Kuv pom tias ob ntawm nws cov kev sib txuas hauv nkoj tuaj yeem siv ua cov khoom siv digital. Hauv Cov Lus Qhia no, cia peb kawm paub yuav ua li cas peb tuaj yeem siv PS/2 touchpad's ntxiv
Tsib Neat Me Projects: 6 Kauj Ruam
Tsib Txoj Haujlwm Me Me Neat: Tau nyiam cov kab hluav taws xob uas nyem thiab ua suab nrov thaum koj qhia cov khoom siv hluav taws xob rau cov tub ntxhais hluas. Cov tsib qhov hluav taws xob uas siv sijhawm li ob peb feeb los tsim, lawv yooj yim rau kev hloov pauv txhawm rau hloov pauv qhov nrawm lossis lub sijhawm. Thawj Circuit
LED Dimmer Circuit - 555 Timer Projects: 5 Kauj Ruam
LED Dimmer Circuit | 555 Timer Projects: Nrhiav Cov Haujlwm Piav Qhia tag nrho & Txhua Yam Khoom Siv Muaj xws li Daim Duab Kab Duab / Schematic Kho Vajtse / Cov Txheej Txheem Teev Npe Codes / Algorithm Datasheet / Pin Configuration thiab lwm yam Ntawm ►► https://circuits-diy.com/how-to-make-simple-led-d
Ntxiv Idler (2nd Axis Mounting Point) ntawm Micro Servos rau Robotic Projects: 4 Cov Kauj Ruam
Ntxiv Idler (2nd Axis Mounting Point) ntawm Micro Servos rau Robotic Projects: Hauv tib neeg txoj haujlwm neeg hlau, servos tau siv ntawm cov pob qij txha txhawm rau txav cov ntu sib txawv ntawm cov neeg hlau, feem ntau nws yog qhov zoo tshaj plaws rau mount txhua ntu ntawm 2 lossis ntau dua cov ntsiab lus ntawm lub axis tig ntawm servo rau kev ruaj ntseg thiab hloov pauv ntawm lub zog ..Sma
10 Basic Arduino Projects rau Beginners! Ua Yam Tsawg 15 Txoj Haujlwm Nrog Ib Leeg Pawg!: 6 Cov Kauj Ruam
10 Basic Arduino Projects for Beginners! Ua Yam Tsawg 15 Txoj Haujlwm Nrog Ib Leeg Pawg!: Arduino Project & Pawg Thawj Saib Xyuas; Xws li 10 qhov haujlwm yooj yim Arduino. Txhua qhov chaws, cov ntaub ntawv Gerber thiab ntau ntxiv. Tsis muaj SMD! Yooj yim soldering rau txhua tus. Yooj yim tshem tau thiab hloov pauv tau. Koj tuaj yeem ua yam tsawg kawg 15 txoj haujlwm nrog rau ib leeg