Setting up the Pi is easy

This is the first in a series of posts on how to run AI on the Raspberry Pi (AI on Pi). The first step – setting up the Raspberry Pi. The final goal is to use the Pi to run a deep learning application. This could be vision related – example, recognizing an event from images/video feed, using Convolutional Neural Nets (CNNs). It could also be audio related, so NLP using RNNs, but that is for a later time.

The main goals:

  • Capture images / video using a camera (sensor) connected to the Pi
  • AI algo executes on the Pi
  • Result is communicated to “Hub” using BT, Wifi etc. Hub could be another computer, IoT Hub, or the Cloud.

Since I have never worked with the Raspberry Pi previously, let’s start at the very beginning.

Hardware:

  • OV5647 5.0MP Camera Module (bought at dlscorp.com site)
    The OV5647 module is the older version. There is a new official camera module, but I decided to go with the older version for two reasons – cost and 5MP (vs 8MP in V2) is plenty for AI applications. Important details – needs to be a CSI module, and comes with a replaceable lens mount (M12)
  • Camera lens (bought different lenses from dlscorp)
  • Monitor – used an old monitor I had from years ago. The Pi connects to a monitor using a micro-HDMI port. The kit includes a micro-HDMI to HDMI cable, but I needed to buy a micro-HDMI to VGA adapter for my Monitor.
  • Keyboard and mouse – used an old keyboard I had laying around

Software:

  • Used the standard NOOBS (preloaded on the micro SD card), and the full Raspbian install. Nothing fancy, yet.

Step 1: Connect the System

Raspberry Pi setup with a camera facing out a window

There are many excellent walk throughs – see here or here. The basics are simple enough – connect the display, keyboard and mouse, and the power, and follow the onscreen prompts. There are a couple of things I would like to point out though. One, setup SSH and VNC access to the Pi, so you can connect to it from a remote computer and don’t need the dedicated mouse, keyboard and monitor. This will be especially useful during deployment of the application. The second thing – update the software. Use “sudo apt-get update” and “sudo apt-get upgrade”.

Once the system is operational, do take the time to explore, browse the web etc. Marvel at a simple yet very complete computer.

Step 2: Python Setup

There are other languages, of course, but Python is the language of choice. Python2 and Python3 come pre-installed, with a bunch of packages. The first thing is the virtual environment setup – extremely important given the stand-alone nature of the intended application. The application should not break because of an update a couple of years out. I used virtualenvhere is a good intro.

I spent some time (a little) trying to research the “best” editor but realize that the Pi is not necessarily where I will develop the code. That can be done on a laptop or in the cloud. So, for now I am using Thonny, which came pre-installed. I have not yet written a lot of python on the Pi, will see how it goes over the next few days/weeks – might yet change my mind.

Try out a simple program, ensure that python is up and running. In the next post, the camera setup.

Show CommentsClose Comments

Leave a comment