Install Libmraa on Rock Pi 4

This a guide to Install OpenCV on ROCK Pi 4 that running Ubuntu. All the instructions are done in terminal. Nowadays Rock Pi Boards are popular. Rock Pi is the best alternative of Raspberry Pi. Rock Pi 4 is a most popular SBC. Rock Pi Developed and Manufactured by Radxa. Radxa is a startup founded 2013, focusing on design, manufacture and sell Open Source Hardware products. Radxa also provides custom designing, prototyping and software/hardware integration services. Radxa® is pronounced as [reksə]. The name is from the Latin word radix which means root. Radxa® is a registered trade mark by Radxa Limited in Shenzhen, China(深圳市瑞莎科技).

Here a info post about Rock Pi Boards – Rock Pi Boards | Rock Pi 4 | Rock Pi X | Rock Pi N10

Install OpenCV on ROCK Pi 4

We need at least 4GB ram for compile OpenCV on ROCK Pi and we recommend to compile on ubuntu arm64 images.

1: Get Ubuntu running on ROCK Pi 4

To use OpenCV, an OS desktop is necessary. If your ROCK Pi 4 is running Ubuntu but without desktop, you can install Ubuntu mate desktop.

   $ sudo apt install ubuntu-mate-core && sudo apt install ubuntu-mate-desktop

2: Install all the recommended packages

  • Compilers:
   $ sudo apt-get install build-essential
  • Required:
   $ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  • Recommended optional packages
   $ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
   $ sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libavresample-dev
   $ sudo apt install tesseract-ocr cmake-data liblept5

3: Download OpenCV source

We suggest that you are at the home folder, so that you don’t have to change the code in the next steps.

We need to download OpenCV source. OpenCV latest release: [here]. As of writing this, the latest release is 4.0.1. For the newer version, just replace the link for the source code zip file.

   $ cd ~
   $ wget -O
   $ unzip

And we also need to install the contribution packages of OpenCV. Here we get the latest release version:

   $ cd ~
   $ wget -O
   $ unzip

4: Configuring and compiling

Confifure thte build using cmake:

   $ cd ~/opencv-4.0.1/
   $ mkdir build
   $ cd build
   $ export PY_NAME=$(python -c 'from sys import version_info as v; print("python%d.%d" % v[:2])')
   $ export PY_NUMPY_DIR=$(python -c 'import os.path, numpy.core; print(os.path.dirname(numpy.core.__file__))')
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DPYTHON2_EXECUTABLE=$(which python) \
        -DPYTHON_INCLUDE_DIR=/usr/include/$PY_NAME \
        -DPYTHON_INCLUDE_DIR2=/usr/include/aarch64-linux-gnu/$PY_NAME \
        -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/lib$ \
        -DPYTHON2_NUMPY_INCLUDE_DIRS=/usr/lib/$PY_NAME/dist-packages/numpy/core/include/ \
        -DBUILD_DOCS=OFF \
        -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules \

Compile OpenCV in the build folder:

   $ make -j$(nproc --all)

Install OpenCV in the build folder:

   $ sudo make install
   $ sudo ldconfig

5: Test your building and installation

To confirm that you have install ed OpenCV correctly , try this:

   rock@linux:~$ python
   Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
   [GCC 7.3.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import cv2
   >>> cv2.__version__

6: Do the sample supported by OpenCV official

   $ cd ~/opencv-4.0.1/samples/python
   $ python

Finally, if you don’t need the files in opencv-4.0.1 or opencv_contrib-4.0.1. You can remove them:

   $ cd ~
   $ rm -rf opencv-4.0.1 opencv_contrib-4.0.1

If you follow the code exactly, you will find it working just fine.

If you faced any problem you can post your issue at the forum:

I hope you like this post. Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.

You May also like :

By Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. I am a tech blogger and an IoT Enthusiast. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning! Follow and send tweets me on @harshvardhanrvm. If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee!

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.