Skip to content

Instantly share code, notes, and snippets.

@tchamberlin
Last active February 6, 2020 05:10
Show Gist options
  • Save tchamberlin/fe55da8afa266c544f1cd0f5f94f2f52 to your computer and use it in GitHub Desktop.
Save tchamberlin/fe55da8afa266c544f1cd0f5f94f2f52 to your computer and use it in GitHub Desktop.
Install OpenCV on ODROID N2

Install Python3.8 and OpenCV on ODROID N2 Ubuntu 18.04

Ubuntu 18.04

This guide uses the "minimal" (headless) Ubuntu installation.

ODROID provides images for Ubuntu 18.04 here

This guide is using build 20190806

Download this and flash it to a MicroSD card. I couldn't find an md5 for it, but it worked for me, and the sum for mine is 25d47739748c23109c218cfdca4e3ffd.

First boot

Ensure the white switch is set to MMC (right-position). Then simply plug in the MicroSD card, turn on the ODROID, and Ubuntu should start up.

Default username/password is root/odroid.

SSH

I would recommend doing the rest of this via SSH, but it's up to you. From another linux host, use ssh-copy-id to get your credentials over, and then SSH in

Software Installs

apt update -y && apt full-upgrade -y
apt install python3.8 python3.8-dev python3.8-venv python3-pip

Set up a virtual environment for OpenCV:

mkdir ~/venvs
python3.8 -m venv ~/venvs/3.8_env
source ~/venvs/3.8_env/bin/activate

Now we need to install the dependencies for OpenCV:

apt install libatlas-base-dev gfortran
pip install numpy

There's not pre-built binaries for ARM (as far as I can tell), so we'll need to build them ourselvs. Note that we are turning off the GUI features -- it's a headless installation, after all.

mkdir ~/opencv
cd ~/opencv
# Get latest OpenCV source
wget https://github.com/opencv/opencv/archive/4.2.0.tar.gz
tar -xf ./4.2.0.tar.gz 
cd opencv-4.2.0
mkdir build
cd build
# Turn examples and GUI off to save time (probably wouldn't work anyway)
cmake \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF \
    -DWITH_QT=OFF \
    -DWITH_GTK=OFF \
    ../
# ~45 minutes
make -j6 # We have 6 cores, so why not
make install
ldconfig
ln -s /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.cpython-38-aarch64-linux-gnu.so /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.so
ln -s /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.so $VIRTUAL_ENV/lib/python3.8/site-packages/cv2.so
# This should print out 4.2.0
python -c "import cv2; print(cv2.__version__)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment