Setup OpenCV on Ubuntu Server

This post assumes you have Ubuntu server setup as walked through in previous post.

Install OpenCV

Login to your Ubuntu server and run

sudo apt-get update

sudo apt-get upgrade

This will update your server to the latest state.

Next, create a directory called MyWorkspace.  I created mine in my /home/rauastin directory.  Change directory into the MyWorkspace directory and run the following commands. If you do not have git installed, you can install by typing in “sudo apt-get install git” and pressing return.

git clone https://github.com/Itseez/opencv.git

Next, install the necessary libraries and compilers.  Run the following commands:

sudo apt-get install build-essential

sudo apt-get install cmake libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

If you are using Ubuntu 17x you will need to add an older library reference.  Use

echo "deb http://us.archive.ubuntu.com/ubuntu/ yakkety universe" | sudo tee -a /etc/apt/sources.list

and the run sudo apt-get update, then rerun the failed statement from above.  Next:

sudo apt-get install libopencv-dev

That’s it… you have successfully install OpenCV on your Ubuntu Server!  If you want to verify the installation, type in opencv_createsamples at the command prompt.  You should see a list of options when using opencv_createsamples as shown below: