본문 바로가기
1. SW 개발 & IT 트렌드

Raspberry Pi 4 - TensorFlow & Object detection

by soosun 2020. 12. 12.

# Object detection on the Raspberry Pi 4

github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi
위 안내에 따라 설치 및 테스트 한 내용입니다.

 


1. Raspberry OS install
rasperrypi.org/software/operating-system/


2. Update the Raspberry Pi
sudo apt-get update
sudo apt-get dist-upgrade

 

 

3. Camera on - Raspberry Pi Config

 

4. Install TensorFlow
#속도 때문에 오류 가능, 가능하면 유선으로.
pip3 install tensorflow

#텐서플로우 설치 후,
#텐서플로우에 필요한 패키지를 추가로 설치.
sudo apt-get install libatlas-base-dev
sudo pip3 install pillow lxml jupyter matplotlib cython
sudo apt-get install python-tk


4. Install OpenCV
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install qt4-dev-tools libatlas-base-dev

sudo pip3 install opencv-python


5. Compile and Install Protobuf
sudo apt-get install protobuf-compiler
protoc --version
#libprotoc 3.6.1


6. make TensorFlow dir

#작업 폴더 생성.
mkdir tensorflow1
cd tensorflow1

git clone --depth 1 https://github.com/tensorflow/models.git

# PYTHONPATH 편집
sudo nano ~/.bashrc
#export PYTHONPATH=$PYTHONPATH:/home/pi/tensorflow1/models/research:/home/pi/tensorflow1/models/research/slim



# The .proto files are located in /research/object_detection/protos,
# but we need to execute the command from the /research directory.

cd /home/pi/tensorflow1/models/research
protoc object_detection/protos/*.proto --python_out=.


# This command converts all the "name".proto files to "name_pb2".py files.
# Next, move into the object_detection directory:

cd /home/pi/tensorflow1/models/research/object_detection


# Download the SSDLite-MobileNet model and unpack it by issuing:
wget http://download.tensorflow.org/models/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz
tar -xzvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz


7.Detect Objects!

# Download the Object_detection_picamera.py file into the object_detection directory by issuing:
wget https://raw.githubusercontent.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi/master/Object_detection_picamera.py

python3 Object_detection_picamera.py

 

 


# usb cam 일 때
#python3 Object_detection_picamera.py --usbcam

댓글