This folder contains example code using GStreamer to obtain camera images and perform image classification and object detection on the Edge TPU.
This code works on Linux using a webcam, Raspberry Pi with the Pi Camera, and on the Coral Dev Board using the Coral Camera or a webcam. For the first two, you also need a Coral USB/PCIe/M.2 Accelerator.
-
First, be sure you have completed the setup instructions for your Coral device. If it's been a while, repeat to be sure you have the latest software.
Importantly, you should have the latest TensorFlow Lite runtime installed (as per the Python quickstart). You can check which version is installed using the
pip3 show tflite_runtime
command. -
Clone this Git repo onto your computer or Dev Board:
mkdir google-coral && cd google-coral git clone https://github.com/google-coral/examples-camera --depth 1
-
Download the models:
cd examples-camera sh download_models.sh
-
Install the GStreamer libraries (if you're using the Coral Dev Board, you can skip this):
cd gstreamer bash install_requirements.sh
python3 classify.py
By default, this uses the mobilenet_v2_1.0_224_quant_edgetpu.tflite
model.
You can change the model and the labels file using flags --model
and --labels
.
python3 detect.py
Likewise, you can change the model and the labels file using --model
and --labels
.
By default, both examples use the attached Coral Camera. If you want to use a USB camera,
edit the gstreamer.py
file and change device=/dev/video0
to device=/dev/video1
.