Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Installation (Linux, Octave, OpenCV 3)

Amro edited this page Oct 4, 2018 · 14 revisions

This page provides a guide on how to install mexopencv with Octave on Ubuntu. It covers Octave 4, OpenCV 3 and latest mexopencv.

We compile OpenCV with "contrib" modules, which provide non-free features such as SIFT and SURF, as well as other experimental algorithms not included in main distribution.

The instructions below are meant for Ubuntu. Other Debian-like distros will probably also have these packages or similarly named ones available. Adjust accordingly for other Linux distributions.

1) Octave

First we install Octave 4. For older Ubuntu releases, you should use this PPA ppa:octave/stable.

Ubuntu >= 16

For Xenial (16.04), Bionic (18.04) or newer install the official Octave package simply as:

$ sudo apt-get install octave liboctave-dev

Ubuntu < 16

For Precise (12.04) or Trusty (14.04), install Octave from the above PPA (maintained by GNU Octave team):

$ sudo add-apt-repository ppa:octave/stable
$ sudo apt-get update
$ sudo apt-get install octave liboctave-dev

2) OpenCV

Refer to the same instructions from here for compiling OpenCV (step 1). You can also consult OpenCV's installation tutorial for building from source (as long as you use the 3.4.1 version, and not master).

3) mexopencv

Download the latest version of mexopencv:

$ cd ~/cv
$ wget -O mexopencv-master.zip https://github.com/kyamagu/mexopencv/archive/master.zip
$ unzip mexopencv-master.zip && mv mexopencv-master mexopencv

Compile the MEX-files for Octave:

$ cd ~/cv/mexopencv
$ make WITH_OCTAVE=true WITH_CONTRIB=true all contrib

Once it's done, you can start using OpenCV functions in Octave:

>> cd('~/cv/mexopencv')
>> addpath('~/cv/mexopencv')
>> addpath('~/cv/mexopencv/opencv_contrib')
>> addpath('~/cv/mexopencv/+cv/private')                 % HACK
>> addpath('~/cv/mexopencv/opencv_contrib/+cv/private')  % HACK
>> cv.getBuildInformation()

You might wanna put those addpath() calls in your ~/.octaverc config file if you don't want to have to repeat them every time Octave is started.

To verify the installation, you can optionally run the full test suite:

$ make WITH_OCTAVE=true WITH_CONTRIB=true test