Cov txheej txheem:

Raspberry Pi Kev Tshawb Nrhiav Lub Hom Phiaj: 7 Kauj Ruam
Raspberry Pi Kev Tshawb Nrhiav Lub Hom Phiaj: 7 Kauj Ruam

Video: Raspberry Pi Kev Tshawb Nrhiav Lub Hom Phiaj: 7 Kauj Ruam

Video: Raspberry Pi Kev Tshawb Nrhiav Lub Hom Phiaj: 7 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Raspberry Pi Lub Hom Phiaj Tshawb Nrhiav
Raspberry Pi Lub Hom Phiaj Tshawb Nrhiav

Phau ntawv qhia no qhia ib qib zuj zus cov lus qhia yuav teeb tsa TensorFlow's Object Detection API ntawm Raspberry Pi. Los ntawm ua raws cov theem hauv phau ntawv qhia no, koj yuav tuaj yeem siv koj li Raspberry Pi los ua qhov ntsuas pom ntawm cov vis dis aus nyob ntawm Picamera lossis USB webcam. Kev siv lub tshuab kev kawm tsis tas yuav siv raws li siv hauv online database rau kev txheeb xyuas qhov khoom. Koj tuaj yeem tshawb pom feem ntau ntawm cov khoom uas feem ntau siv thoob ntiaj teb.

Thov xa mus rau kuv daim duab saum toj no, peb siv tus nas, Kua thiab Txiab thiab pom cov khoom zoo kawg nkaus.

Phau ntawv qhia taug kev hla cov theem hauv qab no:

Hloov kho Raspberry Pi

Nruab TensorFlowInstall OpenCV

Sau thiab teeb tsa Protobuf

Teeb tsa TensorFlow phau ntawv teev npe qauv

Tshawb xyuas cov khoom

Kauj ruam 1: Hloov kho Raspberry Pi

Hloov kho Raspberry Pi
Hloov kho Raspberry Pi

Koj li Raspberry Pi yuav tsum tau hloov kho tshiab

Kauj ruam 1:

Ntaus hauv Command qhov davhlau ya nyob twg, sudo apt-tau hloov tshiab

Thiab tom qab ntawd Hom

sudo apt-tau nruab dist-upgrade

Qhov no Yuav Siv Sijhawm Ntev nyob ntawm koj li Internet thiab Raspberry pi

Qhov ntawd yog txhua yam koj xav tau, koj tau ua tiav Hloov Kho koj li Raspberry pi

Kauj ruam 2: Nruab TensorFlow

Nruab TensorFlow
Nruab TensorFlow

Tam sim no, peb tab tom yuav nruab Tensorflow.

Ntaus cov lus txib hauv qab no, pip3 nruab TensorFlow

TensorFlow tseem xav tau pob LibAtlas, Ntaus cov lus txib hauv qab no

sudo apt-tau nruab libatlas-base-dev

Thiab ntaus cov lus txib hauv qab no ib yam nkaus, sudo pip3 nruab hauv ncoo lxml jupyter matplotlib cythonsudo apt-tau nruab python-tk

Tam sim no, Peb tau ua tiav Txhim Kho Tensorflow.

Kauj ruam 3: Nruab OpenCV

Nruab OpenCV
Nruab OpenCV

Tam sim no peb tab tom ua haujlwm Txhim Kho OpenCV lub tsev qiv ntawv vim tias TensorFlow cov khoom ntsuas pom piv txwv siv matplotlib los qhia cov duab, tab sis kuv xaiv los xyaum OpenCV txij li nws yooj yim ua haujlwm nrog thiab tsawg dua qhov ua yuam kev. Yog li, peb yuav tsum teeb tsa OpenCV. Tam sim no OpenCV tsis txhawb nqa RPI, yog li peb yuav teeb tsa Kev Txheeb Xyuas qub.

Tam sim no peb tab tom ua haujlwm los teeb tsa ob peb qhov kev vam khom uas yuav tsum tau teeb tsa ntawm apt-get

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

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

sudo apt-tau nruab libxvidcore-dev libx264-dev

sudo apt-tau nruab qt4-dev-cuab yeej libatlas-base-dev

Thaum kawg, Tam sim no peb tuaj yeem nruab OpenCV los ntawm kev ntaus ntawv, pip3 nruab opencv-python == 3.4.6.27

Qhov ntawd yog txhua yam, tam sim no peb tau teeb tsa OpenCV

Kauj ruam 4: Nruab Protobuf

Nruab Protobuf
Nruab Protobuf

TensorFlow cov khoom ntsuas pom API siv Protobuf, pob uas tso rau Google Cov Txheej Txheem Tsis Cov ntaub ntawv hom. Koj yuav tsum tau suav sau los ntawm qhov chaw, tam sim no koj tuaj yeem teeb tsa tau yooj yim.

sudo apt-tau nruab protobuf-compiler

Khiav raws tu qauv -kev hloov pauv ib zaug uas ua tiav. Koj yuav tsum tau txais cov lus teb ntawm libprotoc 3.6.1 lossis zoo sib xws.

Kauj Ruam 5: Teeb TensorFlow Directory Structure

Teeb TensorFlow Cov Txheej Txheem Txheej Txheem
Teeb TensorFlow Cov Txheej Txheem Txheej Txheem

Peb tau teeb tsa tag nrho cov pob khoom, peb xav teeb tsa cov npe rau TensorFlow. Los ntawm cov npe hauv tsev, tsim cov npe npe hu ua "tensorflow1", Ntaus cov hauv qab no, mkdir tensorflow1cd tensorflow1

Tam sim no rub tawm TensorFlow los ntawm kev ntaus ntawv, git clone --depth 1

Peb xav hloov kho PYTHONPATH ib puag ncig sib txawv kom ncaj ntawm qee cov npe hauv TensorFlow chaw cia khoom. Peb xav tau PYTHONPATH los teeb tsa txhua lub sijhawm. Peb yuav tsum kho cov ntaub ntawv.bashrc. Peb yuav tsum qhib nws los ntawm Typing

sudo nano ~/.bashrc

Thaum kawg ntawm cov ntawv, thiab kab kawg ntxiv cov lus txib, zoo li hauv daim duab saum toj kawg nkaus uas tau cim rau ntawm lub thawv xim liab.

export PYTHONPATH = $ PYTHONPATH:/tsev/pi/tensorflow1/qauv/tshawb fawb:/tsev/pi/tensorflow1/qauv/tshawb fawb/slim

Tam sim no txuag thiab tawm. Peb yuav tsum siv Txoj Cai los sau cov Txheej Txheem Tsis (.proto) cov ntaub ntawv siv los ntawm Lub Hom Phiaj Tshawb Nrhiav API. Cov ntaub ntawv.proto nyob hauv /tshawb fawb /object_detection /protos, peb xav ua kom tiav cov lus txib los ntawm /tshawb nrhiav cov npe. Ntaus nram qab no hais kom ua

cd/tsev/pi/tensorflow1/ua qauv/tshawb fawbprotoc object_detection/protos/*. proto --python_out =.

Cov lus txib no hloov tag nrho "npe".proto cov ntaub ntawv rau "name_pb2".py cov ntaub ntawv.

cd/tsev/pi/tensorflow1/qauv/tshawb fawb/object_detection

Peb yuav tsum rub tawm SSD_Lite tus qauv los ntawm TensorFlowdetection qauv zoo. Txog qhov no, peb xav siv SSDLite-MobileNet, uas yog tus qauv nrawm tshaj plaws rau RPI.

Google tsis muaj qhov kawg tso cov qauv nrog txhim kho nrawm thiab ua tau zoo, yog li tshawb xyuas ntau zaus yog tias muaj cov qauv txhim kho.

Ntaus cov lus txib hauv qab no txhawm rau rub tawm SSDLite-MobileNet tus qauv.

wget

tar -xzvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz

Tam sim no peb tuaj yeem muaj peev xwm xyaum ua qauv Object_Detction!

Peb yuav luag tiav!

Kauj Ruam 6: Tshawb Pom Lub Hom Phiaj

Tshawb xyuas lub hom phiaj
Tshawb xyuas lub hom phiaj

Tam sim no txhua yam tau teeb tsa rau kev ua tiav cov khoom pom ntawm Pi!

Object_detection_picamera.py pom cov khoom nyob hauv los ntawm Picamera lossis USB webcam.

Yog tias koj siv Picamera, hloov pauv Raspberry Pi teeb tsa cov ntawv qhia zaub mov zoo li hauv daim duab saum toj no cim hauv lub thawv xim liab.

Ntaus cov lus txib hauv qab no txhawm rau rub tawm Object_detection_picamera.py cov ntaub ntawv mus rau hauv phau ntawv teev npe object_detection.

wget https://raw.githubusercontent.com/EdjeElectronics/ TensorFlow-Object-Detection-on-the-Raspberry-Pi/master/Object_detection_picamera.py

python3 Object_detection_picamera.py

Ntaus cov lus txib hauv qab no rau USB lub koob yees duab

python3 Object_detection_picamera.py --usbcam

Ib tus hais kom ua tiav, tom qab 1 feeb qhib lub qhov rai tshiab uas yuav pib tshawb pom cov khoom !!!

Kauj Ruam 7: Teeb Meem thiab Ua Tsaug

Teeb Meem thiab Ua Tsaug
Teeb Meem thiab Ua Tsaug

Thov qhia rau kuv paub yog tias koj muaj lus nug

Email: [email protected]

Ua tsaug, Rithik

Pom zoo: