I was trying to use the iHOG found in this link : http://web.mit.edu/vondrick/ihog/#code to visualize my HOG features. However, I had a compilation problem when following the steps. I am using MAC Mavericks MATLAB 2014a, does anyone ever met a compilation problem when using same system or maybe knows why? This is a screenshot of the error given by MATLAB after running 'compile' as indicated by this link https://github.com/CSAILVision/ihog/blob/master/README.md#ihog-inverting-histograms-of-oriented-gradients
I tried changing the -o to -output as told bye #rayryeng. However still I have the following error occuring:
Though this is not related to HOG, take a look at this Github page regarding mexopencv by Kota Yamaguchi: https://github.com/kyamagu/mexopencv/issues/117. The error that you are encountering was experienced in compiling his MEX OpenCV wrappers.
Essentially, the mex -o option is for MATLAB versions from R2013b and below. As of R2014a, you need to use the -output flag when using mex. You are probably using a MATLAB version that is R2014a or later. Therefore, go into the compile.m file, and change all instances of the -o flag to -output.
Related
I have a .mex code that properly works on Matlab 2012b (32bit).
However, I would like to make it work also on Matlab 2019b (64bit).
When I run it in Matlab 2019, even though the directory is introduced in the path, the error that I get is:
Missing file directm.mex
Have somebody encountered this kind of problem?
Specifically, the toolbox is "forcefeedback toolbox"
https://de.mathworks.com/matlabcentral/fileexchange/4939-force-feedback-toolbox-for-matlab-simulink
Many thanks!
Your MEX-file is a 32-bit binary. You cannot combine it with a 64-bit binary (the newer MATLAB program). The only way to get this to work is to recompile the MEX-file with the newer MATLAB. Unfortunately it looks like this File Exchange submission doesn't come with the sources to the MEX-file. So you are, unfortunately, out of luck.
I have looked at many resources. I just want a simple way to use the newest OpenCV with Matlab 2017a. MinGW doesn't work and a compiler but I can't seem to get Visual C++ working. I can use OpenCV in Visual Studio but what compiler does Matlab want from me and how do I obtain it?
There is a way to use opencv from matlab without compiling any mex files, and without using the computer vision toolbox.
You can call opencv through matlab via python commands.
1) Download and install the CPython distribution, not Anaconda
2) from the command prompt, install the opencv and other packages you want using the pip command > python -m pip install opencv-python
3) Follow the procedure in the matlab help for ensuring matlab knows where to look for the python installation
4) use the syntax py.cv2.function to call the opencv function
If you keep the data types as python data types in matlab while using the py.cv2 functions there isn't too much of a speed hit.
As #Miki mentions in the their comment, have you checked out this page on the MathWorks site? It has many resources, the main one is the Computer Vision System Toolbox OpenCV Interface. It comes with some examples which would be a good starting point. And if those aren't close to what you want, try another one of the community examples on the File Exchange and trying to make small changes to it.
For each version of MATLAB you can find the supported compilers in the documentation. You can also use -v flag as shown blow to see all the paths where MATLAB looks for a C++ compiler.
mex -setup -v
I am trying to use Matlab mex wrappers provided by the OpenCV contrib repository https://github.com/opencv/opencv_contrib/tree/master/modules/matlab.
During the OpenCV installation everything goes fine and cmake can find Matlab installation. My OS is ubuntu 16.04 64 bit and I am using Matlab R2015b.
After successful installation, in order to solve conflicts due to internal dynamic libraries, I have put libstdc++ or libgcc_s in the LD_PRELOAD variable before launching matlab. Moreover, based on opencv documentation (opencv_contrib/modules/matlab/) I have added the binding to the matlab path using "addpath('/path/to/opencv/matlab/');"
after running the following code (provided in the opencv documentation):
% load an image (Matlab)
I = imread('cameraman.tif');
% compute the DFT (OpenCV)
If = cv.dft(I, cv.DFT_COMPLEX_OUTPUT);
My code works fine, but whenever I use
I=imread('cameraman.tif');
cv.imshow('test',I)
or
cv.imread('cameraman.tif');
(or I think all modules provided in the opencv highgui module), I face with the following error in matlab:
Invalid MEX-file '/usr/local/opencv-3.1.0/matlab/+cv/imread.mexa64': /usr/lib/libgdal.so.1:
undefined symbol: _ZN11xercesc_3_111InputSource11setEncodingEPKt
I searched a lot to solve the problem, but I couldn't achieve any success. I also tried to build opencv with the flag -D WITH_GDAL=OFF during the opencv cmake installation, but not only it solves the problem, but also makes matlab crash after calling the above-mentioned codes.
This question already has an answer here:
mex with MATLAB2013a Unrecognized switch: -o
(1 answer)
Closed 7 years ago.
I'm trying to run the Deformable Parts Model MATLAB code provided here and I keep getting this error when running the demo.m file. The specific lines it hangs up on are:
eval([mexcmd ' gdetect/fconvsse.cc -o fconv']);
and
eval([mexcmd ' gdetect/fconv_var_dim_MT.cc -o fconv_var_dim']);
This is a pretty popular tool for detection (cited thousands of times in subsequent papers), so it's certainly not the code itself. I'm running it on MATLAB R2014a on CentOS 6.5. The documentation does say:
The software was tested on several versions of Linux and Mac OS X using MATLAB version R2011a. Earlier versions of MATLAB should also work, though there may be compatibility issues with releases prior to 2009."
Generally R2014a runs stuff from older versions though. Does anyone know what I can do to fix this? Or at least what the '-o' command even refers to? I checked the source code being compiled but couldn't find a parser or anything.
That's probably because there is no such thing as -o flag. However, there is a CAPITAL O flag, so -O. That stands for optimizing the code so that you get the best running code given what you have coded. However, this is already enabled by default, but there is an -output flag. This is probably more along the lines of what you need, judging from the way mex is getting called. -output allows you to override how the output MEX file would be named instead of assuming the name of the MEX implementation file that is being compiled.... so in your case, that would be fconvsse or fconv_var_dim_MT.
As another recommendation, I would also recommend you enable verbose mode so you can see everything that is happening under the hood while the code is being compiled. That is enabled by the -v flag.
Therefore, do this:
eval([mexcmd ' -v gdetect/fconvsse.cc -output fconv']);
and:
eval([mexcmd ' -v gdetect/fconv_var_dim_MT.cc -output fconv_var_dim']);
For more help on mex compilation flags, see the help page: http://www.mathworks.com/help/matlab/ref/mex.html
I want to use the export_fig package for Matlab. At one point this worked, but now it's broken. The error occurs here:
>> system('pdftops -h')
dyld: Library not loaded: /opt/local/lib/libtiff.5.dylib
Referenced from: /opt/local/bin/pdftops
Reason: Incompatible library version: pdftops requires version 8.0.0 or later, but libtiff.5.dylib provides version 6.0.0
pdftops -h: Trace/breakpoint trap
But when I call pdftops from my own bash terminal everything works fine. I suppose it must be because Matlab has some bad library paths or something, but I don't know where to go from here?
Some relevant environmental vars used by matlab:
>> system('env')
SHELL=/bin/bash
OSG_LD_LIBRARY_PATH=/Applications/MATLAB_R2013b.app/sys/openscenegraph/lib/maci64
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
__CHECKFIX1436934=1
XFILESEARCHPATH=/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/locale/%L/%T/%N%S:
DYLD_FRAMEWORK_PATH=/Applications/MATLAB_R2013b.app/sys/os/maci64:/Applications/MATLAB_R2013b.app/bin/maci64/../../Contents/MacOS:/Applications/MATLAB_R2013b.app/bin/maci64:/Applications/MATLAB_R2013b.app/extern/lib/maci64:/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/./native_threads:/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/./server:/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/./lib/jli
SHLVL=1
__KMP_REGISTERED_LIB_33586=0x124404710-cafeb339-libiomp5.dylib
DYLD_LIBRARY_PATH=/Applications/MATLAB_R2013b.app/sys/os/maci64:/Applications/MATLAB_R2013b.app/bin/maci64/../../Contents/MacOS:/Applications/MATLAB_R2013b.app/bin/maci64:/Applications/MATLAB_R2013b.app/extern/lib/maci64:/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/./native_threads:/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/./server:/Applications/MATLAB_R2013b.app/sys/java/jre/maci64/jre/lib/./lib/jli
If you take a look at the error message, MATLAB uses libtiff to call pdftops, but only has version 6.0.0. It says it needs version 8.0.0 or later. There has been a case where this happened before here on StackOverflow. Someone was trying to install mexopencv and has encountered the same error that you're talking about: Compiling mexopencv in OS X 10.9 with Xcode 5 and Matlab R2013b
Though this is unrelated to what you're doing, they encountered the libtiff error that you speak of. They provide two solutions how to fix this error:
Go into MATLAB's root directory, then go bin/os directory where os is the directory of the operating system you are using (in my case, it's maci64). To get into the root directory, in the command prompt do this: cd/(matlabroot). Once you're here, locate the libtiff.5.dylib file and rename it to something like libtiff.5.dylib.bak so that the libtiff libraries that are used are the ones that are default to your system rather than what MATLAB is using internally in the program.
Force MATLAB to point to the library that is part of the system rather than using the one built into MATLAB. As such, in MATLAB's command prompt, run this command:
setenv('DYLD_INSERT_LIBRARIES','/opt/local/lib/libtiff.5.dylib');
Once you do this, you may get further errors that are similar but are with other libraries. As such, you need to keep appending these libraries in the second parameter of setenv and colon-delimiting them until you resolve the issues. You need to make sure that you're pointing to the ones on your system rather than the ones installed with MATLAB. In your case, you have to do:
setenv('DYLD_INSERT_LIBRARIES', ...
'/opt/local/lib/libtiff.5.dylib:/opt/local/lib/libcurl.4.dylib');
Glad this helped!