Cov txheej txheem:

Kev Ntsuas Tus Qauv Ntsuas Siv Kev Tshawb Nrhiav Lub Neej Nyob: 11 Kauj Ruam (nrog Duab)
Kev Ntsuas Tus Qauv Ntsuas Siv Kev Tshawb Nrhiav Lub Neej Nyob: 11 Kauj Ruam (nrog Duab)

Video: Kev Ntsuas Tus Qauv Ntsuas Siv Kev Tshawb Nrhiav Lub Neej Nyob: 11 Kauj Ruam (nrog Duab)

Video: Kev Ntsuas Tus Qauv Ntsuas Siv Kev Tshawb Nrhiav Lub Neej Nyob: 11 Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Image
Image
Kev Ntsuas Tus Qauv Ntsuas Siv Kev Tshawb Nrhiav Lub Neej Nyob
Kev Ntsuas Tus Qauv Ntsuas Siv Kev Tshawb Nrhiav Lub Neej Nyob

Hauv lub ntiaj teb niaj hnub no, cov teeb pom kev yog qhov tseem ceeb rau txoj kev nyab xeeb. Txawm li cas los xij, ntau zaus, cov teeb tsheb tuaj yeem cuam tshuam rau cov xwm txheej uas ib tus neeg tab tom nce lub teeb ib yam li nws tab tom tig liab. Qhov no nkim sijhawm, tshwj xeeb tshaj yog tias lub teeb tiv thaiv ib lub tsheb los ntawm kev hla kev thaum tsis muaj leej twg nyob ntawm txoj kev. Kuv qhov kev hloov pauv tshiab yog lub teeb pom kev ntse uas siv cov khoom pom nyob ntawm lub koob yees duab kom suav cov tsheb ntawm txhua txoj kev. Kho vajtse kuv yuav siv rau qhov haujlwm no yog Raspberry Pi 3, lub koob yees duab, thiab ntau yam khoom siv hluav taws xob rau lub teeb nws tus kheej. Siv OpenCV ntawm Raspberry Pi, cov ntaub ntawv sib sau ua ke yuav khiav los ntawm cov cai uas tswj cov LEDs ntawm GPIO. Nyob ntawm cov lej no, lub teeb pom kev yuav hloov pauv, cia lub tsheb hla dhau qhov kev pom zoo tshaj plaws. Hauv qhov no, txoj kab nrog cov tsheb feem ntau yuav raug tso cai kom txoj kab nrog cov tsheb tsawg dua yuav tsis ua haujlwm, txo cov pa phem. Qhov no yuav tshem tawm cov xwm txheej thaum ntau lub tsheb nres thaum tsis muaj tsheb ntawm txoj kev sib tshuam. Tsis tsuas yog qhov no txuag sijhawm rau txhua tus, tab sis nws tseem txuag ib puag ncig. Lub sijhawm cov tib neeg raug nres ntawm lub cim nres nrog lawv lub cav tsis ua haujlwm ua rau cov pa phem ntau ntxiv, yog li los ntawm kev tsim lub teeb pom kev ntse, Kuv tuaj yeem ua kom zoo dua cov qauv teeb pom kev kom cov tsheb siv sijhawm tsawg kawg nrog lawv lub tsheb nres. Thaum kawg, txoj kev teeb pom kev zoo no tuaj yeem siv tau hauv nroog, thaj tsam ib puag ncig, lossis tseem nyob deb nroog kom ua tau zoo dua rau tib neeg yuav txo qis pa phem.

Kauj Ruam 1: Daim Ntawv Teev Npe

Cov ntaub ntawv:

Raspberry Pi 3 Qauv B v1.2

Raspberry Pi Lub Koob Yees Duab 2.1

5V/1A micro USB fais fab mov

HDMI saib, keyboard, nas SD daim npav nrog Raspbian Jessie

Raspberry Pi GPIO breakout cable

Liab, daj, ntsuab LEDs (2 ntawm txhua xim)

Poj niam txuas rau Raspberry Pi (7 xim tshwj xeeb)

Assorted 24 gauge hlau (xim sib txawv) + cua sov ntsws tubing

2'x2 'ntoo vaj huam sib luag lossis platform

Ntoo ntsia hlau

Dub nto (duab los qhia ntawv, ua npuas ncauj board, daim ntawv loj loj ntawv, thiab lwm yam)

Dawb (lossis lwm yam xim uas tsis yog dub) kab xev rau txoj kev cim

Cov tshuaj tsuag xim dub (rau PVC)

Pipe”PVC yeeb nkab nrog 90 degree lub luj tshib txuas (2), T socket (1), poj niam adapter (2)

Cov cuab yeej

Soldering Hlau

3D Tshuab Luam Ntawv

Laum nrog ntau yam laum ntsis

Cov qhob cij

Kub phom

Kauj Ruam 2: Teeb Kho Raspberry Pi

Rub daim npav SD rau hauv Raspberry Pi thiab khau raj.

Ua raws li phau ntawv qhia no txhawm rau txhim kho OpenCV cov tsev qiv ntawv uas xav tau. Nco ntsoov tias koj muaj sijhawm los ua cov kauj ruam no, vim kev txhim kho OpenCV lub tsev qiv ntawv tuaj yeem siv sijhawm ob peb teev. Nco ntsoov tseem yuav teeb tsa thiab teeb tsa koj lub koob yees duab ntawm no.

Koj kuj tseem yuav tsum nruab pip:

picamera

gpiozero

RPi. GPIO

Nov yog tus lej kawg:

los ntawm picamera.array ntshuam PiRGBArray

los ntawm picamera ntshuam PiCamera

ntshuam picamera.array

import numpy as np

lub sij hawm ntshuam

ua cv2

ntshuam RPi. GPIO ua GPIO

lub sij hawm ntshuam

GPIO.setmode (GPIO. BCM)

rau kuv hauv (23, 25, 16, 21):

GPIO.setup (kuv, GPIO. OUT)

cam = PiCamera ()

cam.resolution = (480, 480)

cam.framerate = 30

raw = PiRGBArray (cam, qhov loj = (480, 480))

sijhawm.s pw (0.1)

colorLower = np.array ([0, 100, 100])

colorUpper = np.array ([179, 255, 255])

pib = 0

inithoriz = 0

cov = 0

rau thav duab hauv cam.capture_continuous (raw, format = "bgr", use_video_port = True):

thav duab = frame.array

hsv = cv2.cvtColor (thav duab, cv2. COLOR_BGR2HSV)

daim npog = cv2.inRange (hsv, xim qis, xim xim)

daim npog = cv2.blur (daim npog, (3, 3))

mask = cv2.dilate (daim npog, Tsis muaj, rov ua dua = 5)

mask = cv2.erode (daim npog, Tsis muaj, rov ua dua = 1)

mask = cv2.dilate (daim npog, Tsis muaj, rov ua dua = 3)

kuv, pib = cv2.threshold (daim npog, 127, 255, cv2. THRESH_BINARY)

cnts = cv2.findContours (pib, cv2. RETR_TREE, cv2. CHAIN_APPROX_SIMPLE) [-2]

center = Tsis muaj

vert = 0 os

luas = 0

yog len (cnts)> 0:

rau c hauv cnts:

(x, y), radius = cv2.minEnclosingCircle (c)

center = (int (x), int (y))

radius = int (vojvoog)

cv2.circle (thav duab, nruab nrab, vojvoog, (0, 255, 0), 2)

x = int (x)

y = int (y)

yog 180 <x <300:

yog tias y> 300:

vert = vert +1

koj y <180:

vert = vert +1

lwm tus:

vert = vert

yog 180 <y <300:

yog tias x> 300:

qab = qab +1

elif x <180: cov

qab = qab +1

lwm tus:

horiz = qab zib

yog vert! = initvert:

luam "Cov tsheb hauv txoj kab ntsug:" + str (vert)

initvert = vert

luam "Cov tsheb hauv kab rov tav:" + str (kab rov tav)

inithoriz = horiz

sau '----------------------------'

yog horiz! = inithoriz:

luam "Cov tsheb hauv txoj kab ntsug:" + str (vert)

initvert = vert

luam "Cov tsheb hauv kab rov tav:" + str (kab rov tav)

inithoriz = horiz

sau '----------------------------'

yog tias vert <horiz:

GPIO.output (23, GPIO. HIGH)

GPIO.output (21, GPIO. HIGH)

GPIO.output (16, GPIO. LOW)

GPIO.output (25, GPIO. LOW)

yog horiz <vert:

GPIO.output (16, GPIO. HIGH)

GPIO.output (25, GPIO. HIGH)

GPIO.output (23, GPIO. LOW)

GPIO.output (21, GPIO. LOW)

cv2.imshow ("Ncej", thav duab)

cv2.imshow ("HSV", hsv)

cv2.imshow ("Pib", pib)

raw.truncate (0)

yog cv2.waitKey (1) & 0xFF == ord ('q'):

so

cv2.destroyAllWindows ()

GPIO.cleanup ()

Kauj Ruam 3: Raspberry Pi thiab Lub Koob Yees Duab Mount

Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount
Raspberry Pi thiab Lub Koob Yees Duab Mount

3D luam tawm rooj plaub thiab lub koob yees duab mount thiab sib dhos.

Kauj Ruam 4: Teeb Lub Teeb Pom Kev

Tsheb Teeb Sib Ntsib
Tsheb Teeb Sib Ntsib
Tsheb Teeb Sib Ntsib
Tsheb Teeb Sib Ntsib
Tsheb Teeb Sib Ntsib
Tsheb Teeb Sib Ntsib

Kuaj tawm lub teeb pom kev nrog lub khob cij. Txhua qhov kev tawm tsam ntawm LEDs qhia ib qho anode, thiab txhua tus ntawm lawv sib koom ib qho cathode (hauv av). Yuav tsum muaj tag nrho ntawm 7 lub xov hlau nkag: 1 rau txhua khub ntawm LEDS (6) + 1 hauv av xaim. Cuab yeej thiab teeb tsa cov teeb tsheb.

Kauj Ruam 5: Txuas (Ntu 1)

Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)
Kev thaiv (Ntu 1)

Muab tus poj niam lub taub hau txuas rau kwv yees li 5 feet ntawm xaim. Cov no yog ob sab uas Cov xov hlau no yuav nab hla cov kav dej PVC tom qab ntawd. Nco ntsoov muaj peev xwm paub qhov txawv ntawm cov teeb sib txawv (2 x 3 xim thiab 1 hauv av). Hauv qhov no, Kuv tau cim qhov xaus ntawm lwm txheej ntawm cov xim liab, daj, thiab xiav nrog cov ntse yog li kuv paub qhov twg yog qhov twg.

Kauj Ruam 6: Tsim Ib puag ncig

Tsim Ib puag ncig
Tsim Ib puag ncig
Tsim Ib puag ncig
Tsim Ib puag ncig
Tsim Ib puag ncig
Tsim Ib puag ncig
Tsim Ib puag ncig
Tsim Ib puag ncig

Tsim ib puag ncig Ua kom 2 feet square ntoo pallet zoo li no. Ntoo ntoo zoo li nws yuav raug npog. Laum ib lub qhov uas tsuas haum koj lub adapter. Laum cov ntsia hlau hla ob sab ntawm lub pallet kom ruaj ntseg PVC yeeb nkab rau hauv qhov chaw. Txiav lub rooj ua npuas dej dub kom phim cov ntoo ntoo hauv qab. Laum ib lub qhov uas haum ib ncig ntawm cov yeeb nkab PVC. Rov ua dua ntawm lub ces kaum rov qab. Kos txoj kev nrog qee daim kab xev dawb.

Kauj Ruam 7: Ua kom tiav PVC Ncej

Ua kom tiav cov PVC Ncej
Ua kom tiav cov PVC Ncej
Ua kom tiav cov PVC Ncej
Ua kom tiav cov PVC Ncej
Ua kom tiav cov PVC Ncej
Ua kom tiav cov PVC Ncej

Nyob rau saum cov yeeb nkab, laum ib lub qhov uas tuaj yeem haum cov kab xaim. Lub qhov ntxhib yog qhov zoo yog tias koj tuaj yeem nkag mus rau sab hauv ntawm cov kav dej. Nab cov xov hlau hla cov kav dej PVC thiab lub luj tshib sib txuas rau qhov ntsuas haum. Thaum txhua yam ua tiav, pleev xim PVC nrog qee cov xim tsuag xim dub los txhawm rau saib qhov zoo ntawm lub thav duab loj. Txiav qhov sib txawv me me hauv ib qho ntawm cov kav dej PVC kom haum T-sib koom. Ntxiv cov yeeb nkab PVC rau t-sib koom no rau lub teeb pom kev kom dai ntawm. Txoj kab uas hla tuaj yeem zoo ib yam li lub thav duab loj (1/2 ), txawm hais tias koj siv cov yeeb nkab me me, ua kom ntseeg tau tias 7 lub xov hlau tuaj yeem hla dhau.

Kauj Ruam 8: Txuas (Ntu 2)

Kev thaiv (Ntu 2)
Kev thaiv (Ntu 2)
Kev thaiv (Ntu 2)
Kev thaiv (Ntu 2)
Kev thaiv (Ntu 2)
Kev thaiv (Ntu 2)

Re-xaim txhua yam raws li kev sim yav dhau los. Txheeb ob zaug kom pom cov teeb pom kev zoo thiab txuas nrog lub khob cij kom paub tseeb tias txhua qhov kev sib txuas tau ua tiav. Muab lub teeb pom kev tso rau ntawm cov xov hlau los ntawm T-caj npab. Qhwv cov xov hlau uas nthuav tawm nrog daim kab xev hluav taws xob txhawm rau tiv thaiv ib qho luv thiab kom pom zoo dua.

Kauj ruam 9: Ua tiav

Tiav lawm!
Tiav lawm!
Tiav lawm!
Tiav lawm!
Tiav lawm!
Tiav lawm!
Tiav lawm!
Tiav lawm!

Txhawm rau khiav cov cai, nco ntsoov teeb tsa koj qhov chaw li ~/.profile thiab cd rau koj qhov chaw nyob.

Kauj Ruam 10: Ntxiv (Duab)

Pom zoo: