kyamagu / mexopencv

Collection and a development kit of matlab mex functions for OpenCV library
http://kyamagu.github.io/mexopencv
Other
664 stars 319 forks source link

make: *** [+cv/private/SuperResolution_.mexa64] error 255 #269

Closed yiran-THU closed 6 years ago

yiran-THU commented 8 years ago

@kyamagu hello,when I make mexopencv in MATLAB,I come across following problem:

/home/yiran/download/mexopencv/src/+cv/private/SuperResolution_.cpp:76:25: error: template argument 1 is invalid
     Ptr<FarnebackOpticalFlow> createFarnebackOpticalFlow(
                   ^
/home/yiran/download/mexopencv/src/+cv/private/SuperResolution_.cpp: In function ‘int {anonymous}::createFarnebackOpticalFlow(bool, std::vector<MxArray>::const_iterator, std::vector<MxArray>::const_iterator)’:
/home/yiran/download/mexopencv/src/+cv/private/SuperResolution_.cpp:83:29: error: template argument 1 is invalid
     Ptr<FarnebackOpticalFlow> p = (use_gpu) ?
                  ^
/home/yiran/download/mexopencv/src/+cv/private/SuperResolution_.cpp:83:33: error: invalid type in declaration before ‘=’ token
     Ptr<FarnebackOpticalFlow> p = (use_gpu) ?
                   ^
/home/yiran/download/mexopencv/src/+cv/private/SuperResolution_.cpp:85:33: error: invalid user-defined conversion from ‘cv::Ptr<cv::superres::FarnebackOpticalFlow>’ to ‘int’ [-fpermissive]
           createOptFlow_Farneback();
                    ^
... ...
/home/yiran/download/mexopencv/src/+cv/private/SuperResolution_.cpp:309:45: error: base operand of ‘->’ is not a pointer
                   s.set("Flags",            pp->getFlags());
                                     ^

make: *** [+cv/private/SuperResolution_.mexa64] 错误 255

My OS is ubuntu 14.04. My MATLAB version is R2016a. My OPENCV version is 3.1.0

I hope I can get help here, Thank you!

yiran-THU commented 8 years ago

when I use terminal ,it reports "ar -crs lib/libMxArray.a lib/mexopencv_features2d.o lib/mexopencv_ml.o lib/mexopencv_shape.o lib/mexopencv_stitching.o lib/mexopencv_videostab.o lib/MxArray.o "

amroamroamro commented 8 years ago

First of all, please fix the formatting of your bug report; All those template arguments <T> are not showing correctly instead being mistaken for html tags...

Refer to here if you need help with markdown. Basically you want to indent the whole block of text by 4 spaces so that it renders like this:

Ptr<T> func();

As for the error, apparently the compiler decided for some reason that the function createFarnebackOpticalFlow() returns int instead of Ptr<FarnebackOpticalFlow> (that's cv::Ptr<cv::superres::FarnebackOpticalFlow> to be exact). Not sure why??

My guess is that you are using the wrong version of OpenCV. So start by checking for certain that you are working with version 3.1.0, not the dev version off the opencv master branch. If you've cloned the git repository, you need to do git checkout tags/3.1.0 and compile that.

If that's not the case, then you should provide more information: details of how you compiled/installed opencv, also the commands you used to invoke the mexopencv makefile.

yiran-THU commented 8 years ago

@amroamroamro Thank you for your reply! I have fixed the formatting of my bug report to make it clear and correct. I have downloaded the opencv from here, then I unpacked it and made a "release" folder in the root directory of opencv. After finish that,I type

mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

in the terminal. this is how I compiled/installed opencv

As for compile mexopencv, I type "mexopencv.make" in matlab command window, the bug report is shown above. I also type make MATLABDIR=/usr/local/MATLAB/R2016ain terminal, but still failed.The bug report in terminal is

ar -crs lib/libMxArray.a lib/mexopencv_features2d.o lib/mexopencv_ml.o lib/mexopencv_shape.o lib/mexopencv_stitching.o lib/mexopencv_videostab.o lib/MxArray.o

. Next time,I want to try

sudo apt-get install libopencv 
make MATLABDIR=/opt/local/MATLAB/R2016a

command in terminal,

Thanks again!

amroamroamro commented 8 years ago

As I suspected, you're not using the correct opencv version. The URL you mentioned is for version 2.4.13. You need to grab 3.1.0 instead if you want to work with the latest mexopencv.

Also since you're on Ubuntu 14.04, trying to install opencv from the Ubuntu archive won't be of help either, seeing that it ships with the old opencv 2.4.8.

You want to compile opencv from source like you did, only you must use the version expected 3.1.0.

Once opencv is built and installed, check that pkg-config --cflags --libs opencv gives the correct output, which is how we locate opencv in the mexopencv makefile.

amroamroamro commented 8 years ago

@yiran-THU Was the problem solved? Did you try building against the correct 3.1.0 version?

yiran-THU commented 8 years ago

@amroamroamro NO! I have tried every version of OPENCV,none of them work. I think it is not the version problem.

amroamroamro commented 8 years ago

@yiran-THU You don't want to try every version of OpenCV, you must use the exact 3.1.0 version to work with the latest mexopencv.

OpenCV is a very active project, with daily changes commited. Some of these changes break the public API interface (i.e its version bumped). We cannot keep up with the bleeding-edge dev-version, so we only target final stable release. Currently at this time, v3.1.0 is the latest stable version published, which we test against...

Note that opencv and opencv_contrib are released in sync, so the same goes for the contrib modules if you're using them.


So please double-check that you are indeed using OpenCV 3.1.0. I'm pretty sure that mexopencv compiles fine against this version, because we continuously test it whenever new code is pushed (both Linux and Windows).

You can see our Travis build script and the build history here: we build opencv+opencv_contrib 3.1.0 from source, compile mexopencv against it, then run the complete test suite (obviously we use Octave in the tests since MATLAB can't be freely installed on the cloud).