Cov txheej txheem:

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: 3 Cov Kauj Ruam

Video: Ntsej Muag thiab Pom Qhov Muag Nrog Raspberry Pi Zero thiab Opencv: 3 Cov Kauj Ruam

Video: Ntsej Muag thiab Pom Qhov Muag Nrog Raspberry Pi Zero thiab Opencv: 3 Cov Kauj Ruam
Video: Часы G-Shock до 250 долларов-15 лучших часов Casio G до 250 доллар... 2024, Hlis ntuj nqeg
Anonim
Ntsej Muag thiab Pom Qhov Muag Nrog Raspberry Pi Zero thiab Opencv
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 daws cov teeb meem no thiab xav sau ntawv qhia kom txhua tus neeg tuaj yeem nruab nws yam tsis muaj teeb meem

Yam yuav tsum tau:

1. Raspberry pi xoom

2. SD-daim npav

3. Lub Koob Yees Duab Module

Cov txheej txheem teeb tsa no yuav siv sijhawm ntau dua 13 teev yog li npaj kev teeb tsa kom haum

Kauj ruam 1: Downlaod thiab Nruab Raspbian Duab

Rub tawm raspbian ncab nrog duab duab los ntawm raspberry pi lub vev xaib

www.raspberrypi.org/downloads/raspbian

Tom qab ntawd ntxig daim npav nco rau hauv koj lub laptop thiab hlawv cov duab raspbian siv lwm yam cuab yeej

Rub tawm ethcher los ntawm no

Tom qab hlawv cov duab ntsaws daim npav nco rau hauv koj lub raspberry pi thiab lub zog ntawm raspberry

Kauj ruam 2: Teeb Up Opencv

Tom qab khau raj txheej txheem qhib davhlau ya nyob twg thiab ua raws cov kauj ruam rau nruab opencv thiab teeb tsa virtual ib puag ncig rau opencv

Cov kauj ruam:

1. Txhua lub sijhawm koj pib ib qho kev teeb tsa tshiab nws zoo dua los txhim kho pob khoom uas twb muaj lawm

$ sudo apt-tau hloov tshiab

$ sudo apt-tau hloov tshiab

Sijhawm: 2m 30 sec

2. Tom qab ntawd teeb tsa cov cuab yeej tsim tawm

$ sudo apt-tau nruab tsim-qhov tseem ceeb cmake pkg-teeb tsa

Sijhawm: 50 sec

3. Tam sim no lob cov duab tsim nyog I/O pob khoom

$ sudo apt-tau nruab libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

Sijhawm: 37 sec

4. Video I/O tej pob khoom

$ sudo apt-tau nruab libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

$ sudo apt-tau nruab libxvidcore-dev libx264-dev

Sijhawm: 36 sec

5. Nruab GTK kev txhim kho

$ sudo apt-tau nruab libgtk2.0-dev

Sijhawm: 2m 57s

6. Kev txhim kho pob khoom

$ sudo apt-tau nruab libatlas-base-dev gfortran

Sijhawm: 1 feeb

7. Tam sim no nruab sej 2.7 yog tias nws tsis nyob ntawd. Hauv kuv qhov xwm txheej nws twb tau teeb tsa tab sis tseem tshawb xyuas

$ sudo apt-tau nruab python2.7-dev

Sijhawm: 55 sec

8. Tam sim no rub tawm lub opencv qhov chaw thiab unzip nws

$ cd ~ ib

$ wget -O opencv.zip

$ unzip qhib cv.zip

Sijhawm: 1m 58 sec

9. Rub tawm lub opencv_contrib repository

$ wget -O opencv_contrib.zip

$ unzip qhib cv_contrib.zip

Sijhawm: 1m 5sec

10. Tam sim no opencv thiab opencv_contrib tau nthuav dav tshem tawm lawv cov zip cov ntaub ntawv kom txuag qee qhov chaw

$ rm opencv.zip opencv_contrib.zip

Sijhawm: 2 sec

11. Tam sim no nruab pip

$ wget

$ sudo nab hab sej get-pip.py

Sijhawm: 50 sec

12. Txhim kho virtualenv thiab virtualenvwrapper, qhov no yuav tso cai rau peb los tsim kev cais, cais nab nab ib puag ncig rau peb cov phiaj xwm yav tom ntej

$ sudo pip nruab virtualenv virtualenvwrapper

$ sudo rm -rf ~/.cache/pip

Sijhawm: 30 sec

13. Tom qab kev teeb tsa ntawd, qhib ~/.profile

$ nano ~/.profile

thiab ntxiv cov kab no rau hauv qab ntawm cov ntawv

# virtualenv thiab virtualenvwrapper

export WORKON_HOME = $ HOME/.virtualenvs qhov chaw /usr/local/bin/virtualenvwrapper.sh

Tam sim no los ntawm koj ~/.profile kom rov ua qhov hloov pauv

$ qhov chaw ~/.profile

Sijhawm: 20 sec

14. Tam sim no tsim cov nab hab sej virtual env npe cv

$ mkvirtualenv cv

Sijhawm: 10sec

15. Cov kauj ruam tom ntej yog nruab numpy. Qhov no yuav siv sijhawm tsawg kawg ib nrab teev yog li koj tuaj yeem muaj kas fes thiab qhaub cij

$ pip nruab numpy

Sijhawm: 36m

16. Tam sim no suav sau thiab teeb tsa opencv thiab paub tseeb tias koj nyob hauv cv virtual ib puag ncig los ntawm kev siv cov lus txib no

$ ua haujlwm cv

thiab tom qab ntawd teeb tsa kev tsim siv Cmake

$ cd ~/opencv-3.0.0/

$ mkdir tsim $ cd tsim $ cmake -D CMAKE_BUILD_TYPE = RELEASE / -D CMAKE_INSTALL_PREFIX =/usr/local / -D INSTALL_C_EXAMPLES = ON / -D INSTALL_PYTHON_EXAMPLES = ON / -D OPENCV_EXTRPLE_contact D BUILD_EXAMPLES = ON -D ENABLE_PRECOMPILED_HEADERS = OFF..

Sijhawm: 5 feeb

17. Tam sim no tsim yog teeb tsa, khiav ua kom pib txheej txheem muab tso ua ke. Qhov no yuav siv sijhawm me ntsis yog li koj tuaj yeem cia qhov kev ua haujlwm no tsaus ntuj

$ ua

Hauv kuv qhov xwm txheej 'ua' cuam tshuam rau kuv ib qho yuam kev uas cuam tshuam nrog ffpmeg. Tom qab tshawb nrhiav ntau kuv pom qhov kev daws teeb meem. Mus rau opencv 3.0 nplaub tshev ces modules ces hauv videoio mus rau src thiab hloov lub cap_ffpmeg_impl.hpp nrog cov ntawv no

github.com/opencv/opencv/blob/f88e9a748a37e5df00912524e590fb295e7dab70/modules/videoio/src/cap_ffmpeg_impl.hpp thiab khiav dua

Sijhawm: 13 teev

Yog tias nws suav ua yam tsis muaj qhov yuam kev, nruab nws ntawm raspberry pi siv:

$ sudo ua nruab

$ sudo ldconfig

Sijhawm: 2 min 30 sec

18. Tom qab ua tiav kauj ruam 17 koj qhov kev sib txuas opencv yuav tsum nyob hauv /usr/local/lib/python-2.7/site-packages. Txheeb xyuas qhov no los ntawm kev siv qhov no

$ ls -l /usr/local/lib/python2.7/site-packages

tag nrho 1549 -rw-r-r-- 1 cov neeg ua haujlwm 1677024 Dec 3 09:44 cv2.so

19. Tam sim no tsuas yog sab laug yog sym-txuas cov ntaub ntawv cv2.so rau hauv qhov chaw-pob ntawv teev npe ntawm cv ib puag ncig

$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/

$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

20. Txheeb xyuas koj qhov kev teeb tsa opencv los ntawm kev siv:

$ ua haujlwm cv

$ python >>> ntshuam cv2 >>> cv2._ version_ '3.0.0' >>>

Kauj Ruam 3: Ntsej Muag thiab Pom Qhov Muag

Ntsej Muag thiab Pom Qhov Muag
Ntsej Muag thiab Pom Qhov Muag
Ntsej Muag thiab Pom Qhov Muag
Ntsej Muag thiab Pom Qhov Muag

Tam sim no cia peb sim nrhiav lub ntsej muag

Thawj qhov ua yog qhib lub koob yees duab los ntawm kev siv:

$ sudo raspi-teeb tsa

Qhov no yuav coj los teeb tsa lub vijtsam. Siv koj tus yuam sij xub txhawm rau nqes mus rau Qhov Xaiv 5: Pab lub koob yees duab, ntaus koj tus yuam sij nkag mus kom pab tau lub koob yees duab, thiab tom qab ntawv xub mus rau qhov ua tiav khawm thiab ntaus nkag dua. Thaum kawg, koj yuav tsum rov pib dua koj li Raspberry Pi rau kev teeb tsa kom muaj kev cuam tshuam.

Tam sim no teeb tsa picamera [array] hauv cv ib puag ncig. Rau qhov no kom ntseeg tau tias koj nyob hauv ib puag ncig cv. Yog tias koj rov pib dua koj tus pi, kom rov nkag dua hauv cv ib puag ncig tsuas yog ntaus:

$ qhov chaw ~/.profile

$ ua haujlwm cv

Tam sim no nruab pi lub koob yees duab

$ pip nruab "picamera [array]"

Khiav lub ntsej muag -detection-test.py bu siv:

nab hab sej face-detection-test.py

Yog tias nws cuam tshuam qhov yuam kev tsuas yog ntaus cov lus txib no ua ntej ua cov ntawv

sudo modprobe bcm2835-v4l2

Tam sim no koj zoo mus rau lub ntsej muag pom. Sim thiab qhia koj cov txiaj ntsig

Cheers!

Pom zoo: