'Mex Configuration in MATLAB for OpticalFlow.cpp code
Hello, I am using the Optical Flow Matlab/C++ Code (source code). I am using MATLAB under a Linux-Ubuntu 14.04 64-bit OS. In the configuration file it says:
Before compiling, please check project.h file in subfolder "mex". You don't have to do anything if you use Windows. If you use Mac Os or Linux, please uncomment the line #define _LINUX_MAC.
This has been done. Also it follows:
In Matlab, after you configure mex appropriately, change directory to "mex" and run the following command:
mex Coarse2FineTwoFrames.cpp OpticalFlow.cpp GaussianPyramid.cpp
I think becuase of failing to properly configure mex compilerin MATLAB, I recieve the following error after running the above mex-command:
Warning: You are using gcc version '4.8.2'. The version of gcc is not
supported. The version currently supported with MEX is '4.7.x'. For a list
of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
Warning: You are using gcc version '4.8.2-19ubuntu1)'. The version of gcc
is not supported. The version currently supported with MEX is '4.7.x'. For
a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
Error using mex In file included from /home/labrador/Yashar_BTSync /yasharBTSync /Multimedi Recommender Systems/Video Classification/test_opticalFlow2/OpticalFlow /me x/Coarse2FineTwoFrames.cpp:2:0 /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia Recommender Systems/Video Classification/test_opticalFlow2/OpticalFlow/mex/project.h:7:3: error: stray ‘#’ in program
% #define _OPENCV
In file included from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow/mex/Image.h:11:0,
from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow /mex/Coarse2FineTwoFrames.cpp:3:
/home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow/mex/Stochastic.h:11:13:
warning: extra tokens at end of #ifndef directive
[enabled by default]
#ifndef _abs(x)
^
In file included from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow/mex/OpticalFlow.h:4:0,
from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow /mex/Coarse2FineTwoFrames.cpp:4:
/home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow/mex/NoiseModel.h:6:0:
warning: "PI" redefined [enabled by default]
#define PI 3.1415926535897932384626433832
In file included from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia Recommender Systems/Video Classification/test_opticalFlow2/OpticalFlow/mex/Image.h:11:0,
from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow /mex/Coarse2FineTwoFrames.cpp:3:
/home/labrador/Yashar_BTSync/yasharBTSync/Multimedia
Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow /mex/Stochastic.h:16:0:
note: this is the location of the previous definition
#define PI 3.1415927 In file included from /home/labrador/Yashar_BTSync/yasharBTSync/Multimedia Recommender Systems/Video
Classification/test_opticalFlow2/OpticalFlow
/mex/Coarse2FineTwoFrames.cpp:2:0:/home/labrador/Yashar_BTSync/yasharBTSync/Multimedia Recommender
Systems/Video
Classification/test_opticalFlow2/OpticalFlow/mex/project.h:7:1: error:
expected unqualified-id before ‘%’ token
% #define _OPENCV
^
How can I solve this problem please?
Solution 1:[1]
I also face this problem when using OpticalFlow in MATLAB on a Linux server. I solve this by adding an option -compatibleArrayDims,
mex -compatibleArrayDims Coarse2FineTwoFrames.cpp OpticalFlow.cpp GaussianPyramid.cpp
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
