Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OpenCV library in Octave

Tags:

c++

opencv

octave

Can anyone please provide some insight into finding/generating OpenCV wrappers to be used in Octave?

I have found some older webpages that talk about this, but haven't been able to figure it out!

EDIT:

In this page: http://octave-swig.sourceforge.net/octave-opencv.html It says for the latest release that : "3/27/08: These bindings have been integrated into OpenCV. Latest sources are now available only from OpenCV CVS."

But OpenCV 2.4.6 doesn't have support for Octave. It appears that at some point (OpenCV 2.0) there was a "build with octave support" in the cmake file of OpenCV. But that option doesn't exist in cmakelists.txt that comes with OpenCV anymore!

like image 325
Mehrnoush Avatar asked Nov 25 '13 22:11

Mehrnoush


1 Answers

The first method is Matlab interface generator available in opencv contrib. This repository provides code for generating MEX wrappers for OpenCV functions - these MEXs are suitable for octave too, but for proper setup you need CMake file for OpenCV itself (i. e. you should build it from sources).

As @McMa mentioned, there is a good link to collection of already created interfaces for Matlab/Octave: MEXOpenCV - you can simply use existing sources for creating MEXs suitable for octave.

For both methods when you already have C/C++ sources with Matlab interfaces (i. e. C/C++ files with mexFunction's), you can compile them to MEX with the following command (in linux environment, but I suppose there is no large difference in windows):

mkoctfile --mex -l<opencv lib name> <source name>

where -l<opencv lib name> is required module (something like -lopencv_core -lopencv_imgproc), and <source name> is your source file (with mexFunction) name.

Some more info about mkoctfile can be found in the octave documentation page.

like image 131
avtomaton Avatar answered Nov 04 '22 01:11

avtomaton