Install OpenCV Ubuntu server in Digital Ocean, Vultr or Amazon EC2

In the last few months I have been working in a Image Recognition system using OpenCV. The idea is to provide a REST API for clients to request images to be matched against an online database.

To run an application like this in the cloud I needed OpenCV installed in a VPS server using services such as Digital Ocean, VULTR or Amazon EC2.

In this post I will show how to install OpenCV in Ubuntu server.

For the configuration I will be using ubuntu server 14.04 (64bits), Digital Ocean and OpenCV v2.4.9

1. The first step is to create our server instance (droplet in Digital Ocean) select a name for the droplet, then select the region and the ubuntu version and finally create the droplet.

Digital Ocean

Digital Ocean

2. Login to your server as root using SSH

3. Update and upgrade your ubuntu server with the following commands

4. Now our server is ready to install OpenCV. What we need to do now is to install all the decencies of OpenCV in our server. To do so we will use a script to make our life easier. The script is below, or you can look the source code here.

To run the script create a file named dependencies.sh, then open the file and copy the script into the file, save it and run it. (I am using emacs, you can use other text editor, to save in emacs ctrl x ctrl s, to exit ctrl x ctrl c)

5. After the installation of the dependencies has finished, we need to install OpenCV in the ubuntu server with the following script (you can also found the source here) and wait for around 20 minutes for the process to finish. This step will download OpenCV, compile and install everything.

This step is similar to number 4, create a file, copy the script, save and run.

Install OpenCV ubuntu server

6. Finally OpenCV should be installed in our server. To check if the installation was correct run the following in the command line.

Install Opencv ubuntu server

After all of this now, you should be able to run OpenCV in your server and write awesome computer vision apps :)

Leave a Reply

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