BrickPi Candy Sorter

Sort your Halloween candy with Google Cloud Vision and Raspberry Pi.

6. Prepare the Raspberry Pi

Since we’re using Raspbian for Robots, there are only a few changes that need to be made to the software. All of them are specific to using Google Cloud Vision on the Raspberry Pi. We have a very thorough tutorial on how to get set up here. In short you’ll need to run the following in the command line:



1
sudo pip install --upgrade pip
2
sudo apt-get install libjpeg8-dev
3
sudo pip install --upgrade google-api-python-client
4
sudo pip install --upgrade Pillow
5
sudo apt-get install python-picamera, espeak

Finally, you’ll need to upload your Google Application Credentials in JSON to the Raspberry Pi. Use an FTP program (such as FileZilla) or for Windows users Samba (

) to move the JSON file over to your Raspberry Pi. Place the JSON file in the home directory (“/home/pi”).

Next, we’ll turn on Super User and make our credentials available. In the command line, type the command “su”:

1
sudo 

You may need to run:

1
sudo su

and you may need to enter in your password.

Next, we’ll make the JSON credentials available to Python. In the command line, run the following:

1
export GOOGLE_APPLICATION_CREDENTIALS=filename.json

Be sure to substitute your JSON filename in this command with the name of the file you have on your Raspberry Pi.

Finally, we’ll download the code. Again, this should go into the home directory:

1