Installing OpenCV 4.0 on Google Coral Dev board

Recently Google released TPU chip enabled devices under brand name ‘Coral’. The goal of these devices is to deploy AI/ML based applications onto the Edge to provide edge analytics capabilities, such as inferencing, instead of sending complete data stream to the Cloud. We are testing this device at our company to help our customer deploy edge devices to meet their business needs (low latency, lower bandwidth cost, and lower cloud compute and storage costs). Edge TPU chip based devices aka Coral devices are great fit for edge processing scenarios that we are currently testing (e.g. Vision Analytics). Coral devices are Linux based (Mendel OS), supports Python, C++, TensorFlow Lite and AutoML Vision Edge. For more details please refer to Google Coral website.

In this article, I will explain how to install OpenCV 4.0 on Coral Dev Board. This is based on OpenCV 4.0 installation steps as mentioned in PyImageSearch blog . I have made few minor changes to make it work on Coral Dev board.

Coral Dev Board— Image Copyright Google LLC

Coral dev board is very similar to the size of RaspberryPi. It has 8 GB eMMC and 1 GB LPDDR4. To compile OpenCV from source it doesn’t have enough memory and space on the device.

Minimum required space to install OpenCV is 3 GB and so I recommend using an external SD card. Attach a 16GB SD card and format it to use ext file system.

I am assuming that you have already installed the latest firmware on the dev board and you are able to connect to device using ssh or via serial interface.

Connect to device using ssh (or serial interface) and let us create 1GB temporary swap for the build

Update the system

Install the pre-reqs as mentioned in the PyImageSearch blog

Now mount the SD card

Download OpenCV and contrib modules

As suggested, create Python3 virtual environment

Edit ~/ .bashrc file and add following lines at the end

source the ~/ .bashrc file

Create virtual environment and install NumPy

Now time to compile OpenCV

I used following CMake for my requirements, you can add or remove packages as necessary

We can compile now, it took about 4 hours for me.

Time to install OpenCV

Link it to the virtual environment

Finally run a quick test

Now you can remove the SD card. If everything goes as expected, it should look as follows.

OpenCV 4 on Coral Dev board

Blog and code used with permission from Adrian @PyImageSearch.

CEO of, providing Real-time Vision Analytics using AI / ML