Installing the alwaysAI Platform on Raspberry Pi

Note: The method described in this article is not your only option for installing the base operating system on your Raspberry Pi. You can also use NOOBS, an operating system installation manager to install the base Raspbian operating system. For information on NOOBS go to this website https://www.raspberrypi.org/documentation/installation/noobs.md . If you do use NOOBS to do the initial operating system installation once finished go to Setting Up A Docker Container section of this document to continue installing the alwaysAI platform.

 

Ready to get started with computer vision on your Raspberry Pi?

Step one is to install the latest version of the Raspbian operating system(OS) on your Raspberry Pi (RPi) by installing the OS image on your SD card or SSD drive. On your PC go to the https://www.raspberrypi.org/downloads/raspbian website and download the latest version of Raspbian desktop OS software to your PC. You will need a tool like Etcher to burn the OS image to either the SD card or SSD drive, it can be downloaded from this website: https://www.balena.io/etcher/

 

Screen Shot 2019-08-08 at 1.52.15 PM      Screen Shot 2019-07-31 at 12.50.47 PM

 

Unzip the image and flash it to the SD card or SSD drive, this should take about 5 minutes to flash and verify depending on the size and throughput of your card or drive. The next step is to connect up the RPi with the standard input / output devices (external monitor, keyboard and mouse), put in the SD card or attach the SSD drive and bring up the RPi. The default user ID is pi and the password is raspberry you should consider changing the password. After you have done the initial configuration and rebooted the RPi, open a terminal and type sudo raspi-config at the command line. This will bring up the configuration tool that will allow you to enable ssh and the camera capabilities. Under the Interface Section of the configuration tool, enable camera and ssh interfaces.

Screen Shot 2019-08-02 at 12.32.52 PM      Screen Shot 2019-08-02 at 12.33.24 PM

If you plan on using a usb webcam as your default camera with your RPi instead the pi camera (ribbon cable attached camera), you will need to change a configuration file manually using nano editor that comes with the system. Open a terminal and type in sudo nano /etc/modules and add bcm2835-v4l2 to the modules file to add the usb webcam.

Next, update the OS image. To update the OS image open a terminal and type sudo apt-get update && sudo apt-get upgrade -y, this will take a few minutes, then reboot your RPi. 

 

Setting Up A Docker Container 

The alwaysAI computer vision platform is docker image that is executed within a docker container. In order to work with the RPi you will need to install docker and the alwaysAI docker image. Begin by installing the docker container software, open a terminal on your PC and ssh into your Pi and at the command prompt type the following commands:

  1. curl -sL get.docker.com | sed 's/9)/10)/' | sh
  2. sudo usermod -aG docker pi
  3. sudo reboot

Now that the docker container software is installed on RPi, it needs to be tested to make sure its functional by running the hello world application. Open a terminal and type docker run hello-world to test the docker installation.  

Screen Shot 2019-08-02 at 3.54.07 PM

 

Adding the alwaysAI Computer Vision Platform

Now that the docker software is loaded and the RPi configured it's time to add the alwaysAI computer vision platform. This can be accomplished in one of two ways, either install the platform using alwaysAI’s Command Line Interface (CLI) or through docker commands.

Command Line Interface (CLI)

The CLI tool is written in Node.js and requires the Node runtime environment to execute on your PC. To check to see if Node is already installed on your PCopen a terminal and type node --version and hit enter. The CLI requires Node version 8 or above to run, anything below that will need to be upgraded. Since the installation instructions for Node varies depending on your PC OS (Mac, Windows or LInux), best practice is to go to the https://nodejs.org website for specific instructions on how to install or upgrade Node on your PC. Once the runtime system is installed on your PC you need to install the CLI tool.  On the terminal, type npm install --global alwaysai and if that command does not succeed enter sudo in front of npm install.

       Screen Shot 2019-08-19 at 1.13.27 PM     Screen Shot 2019-08-19 at 1.49.54 PM

 When you go to deploy your first computer vision application using the CLI tool, it will automatically install alwaysAI’s computer vision platform image into the docker container.

 

Using Docker CLI

To install the alwaysAI computer vision(CV) platform using docker CLI you will need to ssh into your RPi. To list the alwaysAI CV packages available through docker repository at the command line type in docker image ls alwaysai/edgeiq. To install the latest version of the CV platform on the terminal enter docker pull alwaysai/edgeiq. To pull a particular version of the platform issue the same command adding a colon followed by the version number for example docker pull alwaysai/edgeiq:0.6.0

     Screen Shot 2019-08-19 at 2.10.29 PM     Screen Shot 2019-08-05 at 12.24.38 PM

Even if you elect to install the alwaysAI CV platform using docker CLI you will still need to install the alwaysAI CLI tool deploy applications to the container image.

 

Test Installations Through Sample Applications

Now that you have the CV platform image loaded on RPi you can verify that the system is working by running one of the starter applications. Login to the alwaysAI website, download the sample applications to your PC and unzip them.

Screen Shot 2019-08-05 at 12.45.23 PM

Before proceeding make sure the camera is attached to RPi. In the terminal move to the directory where you unzip the starter applications and enter into the realtime_object_detect_app directory. In terminal on your PC type in the following command to deploy the application aai app deploy followed by aai app start. Then open your browser and connect to the following link 0.0.0.0:5000

        Screen Shot 2019-08-05 at 5.30.40 PM     Screen Shot 2019-08-06 at 10.11.14 AM

 

 

Doing Object Detection using the Intel Myriad Accelerator 

The alwaysAI platform comes with support for Intel’s Myriad accelerator built in. Accelerators allow you to decrease the inferencing time of applications while increasing the Frame Per Second (FPS). For example the RPi will run around 3 FPS without an accelerator and with the Intel accelerator between 10 - 15 FPS.

Adding Myriad Accelerator Support Via the API

 

           NCS2      IMG_0704

 

With the alwaysAI computer vision platform it’s easy to use the Myriad accelerator by changing a single set of input parameters in the API. Open the real time object detection application (app.py) in your favorite editor and locate the following line, obj_detect.load(engine=edgeiq.Engine.DNN). Change that line of code to obj_detect.load(engine=edgeiq.Engine.DNN_OPENVINO) by changing the API engine parameter. Save the modified application and redeploy it using the CLI tool (rerun the alwaysai app deploy command).

Screen Shot 2019-08-19 at 4.27.38 PM   Screen Shot 2019-08-19 at 4.28.38 PM

Now the RPi that is ready for your computer vision projects. The next step is use alwaysAI’s starter applications and API’s to create your own exciting computer vision applications.

We look forward to seeing what you create!

We are providing professional developers with a simple and easy-to-use platform to build and deploy computer vision applications on embedded devices. The alwaysAI Private Beta program is now accepting applications. Join us apply for the beta now.

APPLY FOR BETA