Neural Network DEMO with [email protected] aarch64 OS and USB3.0

Code can be found on GitHub:

Installation of Packages for Demo

OpenCV with Python3.5

Needs installation from source code reason why pip3 not providing comaptible opencv-phton.

  • First of all,
    Install bellow in SDCard(>16GB) by Ethcer,

  • apt install bellow,
    python3-pip python-pip
    pip3 install setuptools

  • Check Python --version

  • To avoid pip SSL certificate error, edit ~/.pip/pip.conf like bellow,

    trusted-host =  
  • apt install for requirements of opencv 3.4.3
    build-essential cmake unzip pkg-config
    libjpeg-dev libpng-dev libtiff-dev
    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
    libxvidcore-dev libx264-dev
    libatlas-base-dev gfortran

  • Build from source

    $ wget -O --no-check-certificate  
    $ wget -O --no-check-certificate  
    $ unzip  
    $ unzip  
    $ pip3 install numpy  
    $ cd opencv-3.4.3  
    $ mkdir build;cd build  
    -D CMAKE_INSTALL_PREFIX=/usr/local \  
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \  
    -D PYTHON_EXECUTABLE=/usr/bin/python3 \  
    $ make -j4  
    # make install
    # ldconfig

    Over 4 hours has elapsed to compile source, Hwuuh,

  • Check build process like bellow,

    $ pkg-config --modversion opencv
    $ find . -iname cv2\*.so
    $ python3 
      Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
      [GCC 6.3.0 20170516] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import cv2
      >>> cv2.__version__

    Completed opencv installation for Python3

  • Check UVC Camera
    Create script like bellow,

    import numpy as np
    import cv2
    import sys,os
    cam = cv2.VideoCapture(0)
    assert cam is not None
    while True:
    r,f =
    assert r is True
    if cv2.waitKey(33)!=-1:break
    $ python3

    Very Fast and Short latency inspite of USB Camera.

Install edgetpu_api and simple Demos

  • Install edgetpu_api.

    $ cd ~/
    $ wget \
      -O edgetpu_api.tar.gz --trust-server-names --no-check-certificate
    $ tar xzf edgetpu_api.tar.gz
    $ cd edgetpu_api
    $ bash ./
  • Run ClassificationEngine demo

    $ cd ~/Downloads/
    $ wget \ \  --no-check-certificate
    $ cd /usr/local/lib/python3.5/dist-packages/edgetpu/demo
    $ python3 --model ~/Downloads/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
    --label ~/Downloads/inat_bird_labels.txt --image ~/Downloads/parrot.jpg
    W0721 22:20:01.232883    3945] Minimum runtime version required by package (5)
    is lower than expected (10).
    Ara macao (Scarlet Macaw)
    Score :  0.761719

    Work fine.

Object Detection a image-file Demo with ssd_mobilenet

  • Demo script
    Use in this repo.
    Looking at sample script EdgeTPU is in not only prediction but also a part of postprocess. Therefore only overlaying bounding boxes on image is user task.

  • Test image

    $ wget --no-check-certificate
  • MobileNet SSD v1 (COCO) model and label
    Detects the location of 90 types objects
    Dataset: COCO
    Input size: 300x300

$ mkdir ~/ssd_mobilenet_v1; cd ~/ssd_mobilenet_v1

$ wget --no-check-certificate
$ wget --no-check-certificate

$ python3 \
  --model mobilenet_ssd_v1_coco_quant_postprocess_edgetpu.tflite \
  --label coco_labels.txt \
  --input face.jpg \
  --output person_result.jpg
  • MobileNet SSD v2 (COCO) model and label
$ mkdir ~/ssd_mobilenet_v2; cd ~/ssd_mobilenet_v2

$ wget --no-check-certificate
$ wget --no-check-certificate

$ python3 \
  --model mobilenet_ssd_v1_coco_quant_postprocess_edgetpu.tflite \
  --label coco_labels.txt \
  --input face.jpg \
  --output person_result.jpg

person_result.jpg via MobileNet SSD v2.

Object Detection via UVC Camera with ssd_mobilenet

Connect UVC Camera via USB 2.0 port and Edge TPU Accelerator via USB 3.0.

  $ cd rock64
  $ python3  
Last modified: January 7, 2020



Leave a Reply