Objective:
Machine learning is the topic on everyone’s lips. It’s easy to see why. It is the future of data manipulation and is already used in almost every modern business setting. But can it be combined with a Raspberry Pi? Is the Pi up to the task of sustaining a working neural network? With Google TensorFlow, it can!

In this lesson, we will tell you how to Install Google TensorFlow Lite package in Raspberry Pi and use OSOYOO USB Web Camera to detect Object. When Web Camera find an object, Google Tensor A.I software can tell the object’s property, i.e. the object is a person, a bird, a traffic light or an orange or an apple etc. It is really interesting and fun!

Hardware List:

Main board: Raspberry Pi 3 or Pi 4 (highly recommend Pi 4 if you need better performance)

Web Camera : We highly recommend OSOYOO USB camera in our Lesson 4  and Lesson 5 You can also use original PiCamera, but price will be much higher.

Display Device:  We highly recommend OSOYOO 7″ DSI touch Screen or OSOYOO 5″ DSI Screen  which give you a lot of mobility for outdoor projects. You can also use any TV or Monitor which support micro HDMI cable.

Hardware Installation:
You must connect your Keyboard to Raspberry,DSI Screen to DSI port (If you don’t use DSI screen, connect your TV or Monitor to the micro HDMI port in the Pi). We suggest you use Power Adapter instead of Battery during installation.

Software Installation:
Edje Electronics has created a nice TensorFlow Lite installation tutorial in Their Youtube Channel. However, their installation procedure is quite lengthy with many  complicated command typing.

To help people make installation simpler, we have compressed their installation commands into some shell script files. So you just simply type following commands to make the same thing as the video.

1)Download our shell script:

wget http://osoyoo.com/driver/picar/tfinstall.sh

2)run above script: (if system ask you Yes/No during installation ,just reply Yes)

bash tfinstall.sh

Step 3) 4) command must run in Pi Terminal, Do NOT run from ssh or putty window
3)Activate Virtual Environment and install OpenCV and TensorFlow Lite:

cd tflite1
source tflite1-env/bin/activate
bash gpr.sh

4)Run TensorFlow Object Distinguishing Python code:

bash begintf.sh

if you restarted Raspberry Pi ,you should run following command before running bash begintf.sh command:

cd tflite1 
source tflite1-env/bin/activate

Now your Camera Video Window will pop up in your Raspberry Display Screen like following video: