user2792145
user2792145

Reputation: 21

Converting cpp file that uses opencv to mex file with matlab in ubuntu

I need some help converting a cpp file to a mex file. I get the error below:

fatal error: opencv2/core/core.hpp: No such file or directory 
Compilation terminated

The cpp file is using opencv header files. I'm not sure how to link Matlab with opencv in Ubuntu. I saw this link

http://xanthippi.ceid.upatras.gr/people/evangelidis/matlab_opencv/

but its for Windows and I'm not sure where Ubuntu stores opencv. There are a couple places I found opencv folders

usr/local/include/opencv and usr/local/include/opencv2 and usr/local/share/OpenCv

Tried these with OCVROOT but got 'Error: Unexpected Matlab Operator'. Not sure what I'm doing wrong here. Any help would be much appreciated.

Thank you!

Upvotes: 0

Views: 907

Answers (1)

Bull
Bull

Reputation: 11941

  1. Mex needs to be told where the OpenCV header files are. You can either fix it in ~/.matlab/R2013a/mexopts.sh or just put a -I argument on the mex command line. You will find the answer to How to link during Matlab's MEX compilation helpful.
  2. You will have to sort out which of those OpenCV versions you want to use. Might be best to install you own so you know what you are dealing with.
  3. 'Error: Unexpected Matlab Operator' would be cause by an error in your matlab code.
  4. matlab_opencv should work fine on Linux, the only windows specific thing about it the instructions, as far as I know.
  5. unless you have a custom mexopts.sh, I don't think setting OCVROOT will hve any affect on Matlab.

Upvotes: 1

Related Questions