Installing the alwaysAI Computer Vision 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. 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 computer vision 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 Raspberrypi 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. You can download it from its website.
Note: Some of the images in this blog may be slightly different than the ones you see when setting up your Pi, however the instructions should be up to date and the differences should be minor. Contact us on Discord if you have any trouble!
Unzip the image and flash it to the SD card or SSD drive. This should take about 5 minutes to flash. Verify depending on the size and throughput of your card or drive. The next step is to connect up the raspberry pi 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 raspberry pi.
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.
If you plan on using a usb webcam as your default camera with your Raspberry Pi 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 rASPBERY Pi.
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:
- curl -sL get.docker.com | sed 's/9)/10)/' | sh
- sudo usermod -aG docker pi
- sudo reboot
Now that the docker container software is installed on Raspberry Pi, 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.
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 Nodejs 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.
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 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 computer vision 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
Even if you elect to install the alwaysAI computer vision 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 computer vision platform image loaded on Raspberry Pi you can verify that the system is working by running one of the starter applications. Open the terminal, navigate to the directory where you would like the starter applications to downloaded to, and run the command:
Before proceeding make sure the camera is attached to Raspberry Pi. In the terminal make sure you are still in the directory where you unzipped the starter applications and change into the realtime_object_detector directory. Now you can configure and run the application as usual! Once the application is running, open your browser and connect to the following link 0.0.0.0:5000
Doing Object Detection using the Intel Myriad Accelerator
The alwaysAI computer vision 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 Raspberry Pi will run around 3 FPS without an accelerator and with the Intel accelerator between 10 - 15 FPS.
Adding Myriad Accelerator Support Via the API
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).
Computer vision is easier with alwaysAI!
Now the Raspberry Pi that is ready for your computer vision projects. The next step is using alwaysAI’s starter applications and API’s to create your own exciting computer vision applications... We look forward to seeing what you create!