Create simple recognition object detection in the live time on the Raspberry Pi using TensorFlow Lite

Alex G.
2 min readOct 26, 2020
object detection in the live time Raspberry Pi (Photo,GIF by Author) https://github.com/oleksandr-g-rock/simple_object_detection/blob/main/1_HBuxU8qAdWWhX6PliCRjyA.png

Short summary:

In this article, I will explain how to create a solution for object detection on Raspberry Pi 4 (4 GB) from Pi-camera in live time.
I will use pre-trained model.
Code for this article is available here.

Note before you start:

So, Let’s start :)

Hardware preparation:

Software preparation:

For run this application just run the next commands:

1 download this repo to your raspberry pi

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

2 go to this repo

cd examples/lite/examples/object_detection/raspberry_pi

3 prepare Object Detection folder && upload Object detection pretrained model and unzip


# The script takes an argument specifying where you want to save the model files
bash download.sh /tmp

4 preparing VNC (if you have)

If you go to VNC Server Options (right-click on the VNC status icon in the top right) and check to Enable direct capture mode on the Troubleshooting page. This will allow you to see the camera output via VNC. Like on the screenshots:

(Photo,GIF by Author) https://github.com/oleksandr-g-rock/simple_object_detection/blob/main/0_BvOkcWvUyTXTW8gY.png
(Photo,GIF by Author) https://github.com/oleksandr-g-rock/simple_object_detection/blob/main/0_FhS-AYQn0gmWw6hC.png

5 run script which will show images from Pi camera

python3 detect_picamera.py \
--model /tmp/detect.tflite \
--labels /tmp/coco_labels.txt

Result:

object detection in the live time Raspberry Pi (Photo,GIF by Author) https://github.com/oleksandr-g-rock/simple_object_detection/blob/main/0_O3T66qPaM5uEoGQL.gif

So in this article, we created simple recognition object detection in the live time. Code from this article is here.

--

--

Alex G.

ML DevOps engineer. 🙂 I am always open to new opportunities and offers. 🖖 I trying to help the world 🌏 with machine learning.