Create simple recognition object detection in the live time on the Raspberry Pi — version 2. Using TensorFlow Lite

Alex G.
2 min readDec 7, 2020
Create simple recognition object detection in the live time on the Raspberry Pi — version 2 (Photo,GIF by Author) https://github.com/oleksandr-g-rock/simple_object_detection/blob/main/demo_od.gif

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:

Clone models list from Tensorflow repository:

sudo mkdir object_detectioncd object_detectionsudo git clone --depth 1 https://github.com/tensorflow/models.gitcd models/research/sudo protoc object_detection/protos/*.proto --python_out=.cd object_detection

Upload Object detection pre-trained model and unzip

wget http://download.tensorflow.org/models/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09.tar.gzsudo tar -xzvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz

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

Clone my Python script for object detection to this directory where you located and run this script.

wget https://raw.githubusercontent.com/oleksandr-g-rock/object-detection/main/OD.py && python3 OD.py

Result:

Create simple recognition object detection in the live time on the Raspberry Pi — version 2 (Photo,GIF by Author) https://github.com/oleksandr-g-rock/simple_object_detection/blob/main/demo_od.gif

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

--

--

Alex G.

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