OpenCV is a computer vision library that can be used in the development of applications programmed in C++ and C. It is relatively easy to get started with OpenCV, but you will need some basic C programming skills and the prerequisite packages installed on your system. In this tutorial, we will go through the step by step instructions of installing everything required for OpenCV on an Ubuntu Linux system. Then, we will compile a basic program to get you started with using OpenCV.
In this tutorial you will learn:
How to install OpenCV prerequisite packages on Ubuntu Linux
Privileged access to your Linux system as root or via the sudo command.
Conventions
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user
Getting started with OpenCV and Computer Vision on Ubuntu Linux step by step instructions
Follow the step by step instructions below to get the prerequisite packages for OpenCV Computer Vision installed on Ubuntu Linux, and then begin using the programming library to create and compile a C++ program that utilizes OpenCV.
Let’s start by installing the packages we will need to work with OpenCV on our Ubuntu system:
Next, run cmake and make in the directory to turn your .cpp file into an executable:
$ cmake .
$ make
Once the program is done compiling, we can use it to open up and display an image by running the program and specifying the path to the image that we want to open:
In this tutorial, we saw how to install the OpenCV programming library on an Ubuntu Linux system. We then saw how to get started with using OpenCV in C++ by creating a small but powerful program that can be used as an image viewer. It will display any image file that we specify.