OpenCV

Did you know that you can use computer vision in your Skill by including the OpenCV library?

In this tutorial we are going to show how to cross compile and bind a C++ library to be used in your Skills. We will be using OpenCV since it is a very useful library for robots who want to visually understand the world.

Cross compiling OpenCV

To make OpenCV work in a Skill on the HEXA we need to compile OpenCV for HEXA’s processor architecture (arm7).

Compiling for another architecture than what your development machine is using is called cross-compilation and MIND SDK ships with this functionality built in.

We will be using mind x [COMMAND]to launch a container in the current folder which in turn will invoke [COMMAND]. In our case, we are going to write a small shell scriptbuild.shwhich we will execute inside the cross-compiling container withmind x ./build.sh

Inside the opencv-2.4.13.2 folder that we just extracted, use your favorite editor and add the following content to build.sh, and run chmod +x build.sh to add executing permission to it.

This shell script contains all the commands that are required to build OpenCV directly grabbed from their official documentation.

To generate Golang bindings for C libraries, one would typically use CGO, and when binding for C++ libraries, one would use SWIG. Writing the Golang bindings can be a pretty mundane process, and in our case we are lucky. Some cool people have already gone through the effort of writing Golang bindings for OpenCV using SWIG.