Introduction: Augmented Reality (AR) for Dragonboard410c or Dragonboard820c Using OpenCV and Python 3.5

About: Luiz Eduardo Teixeira. Graduado em engenharia de computação pelo Inatel, pretende fazer a diferença na área da tecnologia. Apaixonado por sistemas embarcados, microcontroladores, IoT e aprender novas tecnologi…

This instructables describes how to install OpenCV, Python 3.5, and dependencies for Python 3.5 to run the augmented reality application.

Step 1: Requirements

You will need the following itens:

  • A Dragonboard 410c or 820c;
  • A clean installation of Linaro-alip/developer;
  • DB410c: Tested in version

  • DB820c: Tested in version

  • At least 16GB capacity MicroSD Card (If using Dragonboard 410c);
  • Download the file (in the end of this step), unzip and copy to the MicroSD card;
  • Obs: If using an Dragonboard 820c, download the file, unzip and move to /home/*USER*/ to ease the use of the commands;
  • An USB Hub;

  • An USB mouse and keyboard;

  • An internet connection.

Step 2: Mounting the MicroSD Card (Only W/ Dragonboard410c)

  • Open the terminal in the Dragonboard;
  • In the terminal run fdisk:

$ sudo fdisk -l
  • Insert the MicroSD card into the DragonBoard MicroSD card slot;

  • Run fdisk again, looking for the name (and partition) of the new device in the list:

$ sudo fdisk -l
  • Go to the root directory:

$ cd ~
  • Create a folder:

$ mkdir sdfolder
  • Mount the MicroSD card:

mount /dev/sd_card_partition_name sdfolder

Step 3: Installing Required Frameworks

  • Open the terminal in the Dragonboard;
  • In the terminal, go to a chosen directory (using "~" for the 820c and the mounted SDCard for the 410c):
(820c) $ cd 
(410c) $ cd ~/sdfolder
  • Run script:
$ sudo bash augmented_reality/scripts/
  • Update system:
sudo apt update && sudo apt upgrade
  • Install these packages:
sudo apt install -y debootstrap schroot git curl pkg-config zip unzip python python-pip g++ zlib1g-dev openjdk-8-jdk libhdf5-dev libatlas-base-dev gfortran v4l-utils hdf5* libhdf5* libpng-dev build-essential cmake libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk2.0-dev libgtk-3-dev
  • Go to this directory:
$ cd /usr/src
  • Download Python 3.5:
sudo wget
  • Extract the package:
$ sudo tar xzf Python-3.5.6.tgz
  • Delete the compressed package:
$ sudo rm Python-3.5.6.tgz
  • Go to the Python 3.5 directory:
$ cd Python-3.5.6
  • Enable optimizations for the Python 3.5 compilation:
$ sudo ./configure --enable-optimizations
  • Compile Python 3.5:
$ sudo make altinstall
  • Upgrade pip and setup tools:
$ sudo python3.5 -m pip install --upgrade pip && python3.5 -m pip install --upgrade setuptools
  • Install numpy:
$ python3.5 -m pip install numpy
  • Go to the chosen directory:
(820c) $ cd ~
(410c) $ cd ~/sdfolder
  • Clone OpenCV and OpenCV Contrib repositories:

$ sudo git clone -b 3.4 && sudo git clone -b 3.4

  • Go to directory:
$ cd opencv
  • Create build directory and go to it:
$ sudo mkdir build && cd build
  • Run CMake:
  • Compile OpenCV with 4 cores:

$ sudo make -j 4
  • Install OpenCV:

$ sudo make install
  • Go to the chosen directory:

(820c) $ cd ~
(410c) $ cd ~/sdfolder
  • Install Python3.5 requirements:

$ sudo python3.5 -m pip install -r requirements.txt --no-cache-dir
  • Test imports:
>> import cv2
>> import flask

Step 4: Running AR Application

  • Go to the chosen directory:
(820c) $ cd
(410c) $ cd ~/sdfolder
  • Go to augmented reality directory:
$ cd augmented_reality/
  • Run the application:

$ python3.5
  • Obs: Now connect the USB camera and open using a browser with the board IP address and the port (e.g., print the model saved in reference folder and place in front of webcam such as the image in the top. It's possible to change the animal by oppening the source code, going to line 92 and change the name before video capture command, the avaliable animals are: cow, fox, pirate-ship-fat, rat and wolf. It's also possible to change the reference image by changing the image inside the reference folder.