mex

Calling methods of C++ class in MEX from MATLAB

家住魔仙堡 提交于 2020-01-10 20:11:41
问题 I have a DLP kit which I need to control via MATLAB using a C++ API. Say, I have functions/methods using C/C++ for {load_data, load_settings,display_data} in a mex file named dlp_controller.cpp/.c. I know I can call dlp_controller(); with MATLAB. Is there a way I can call the method of this mex from MATLAB directly? Say my dlp_controller.cpp mex looks as: class dlp{ ... } dlp::dlp{ ... } dlp::load_data{ ... } dlp::load_settings{ ... } dlp::display_data{ ... } void mexFunction(int nlhs,

Calling methods of C++ class in MEX from MATLAB

梦想与她 提交于 2020-01-10 20:10:52
问题 I have a DLP kit which I need to control via MATLAB using a C++ API. Say, I have functions/methods using C/C++ for {load_data, load_settings,display_data} in a mex file named dlp_controller.cpp/.c. I know I can call dlp_controller(); with MATLAB. Is there a way I can call the method of this mex from MATLAB directly? Say my dlp_controller.cpp mex looks as: class dlp{ ... } dlp::dlp{ ... } dlp::load_data{ ... } dlp::load_settings{ ... } dlp::display_data{ ... } void mexFunction(int nlhs,

MATLAB + Mex + OpenCV: Links and compiles correctly but can't find library at run time

孤者浪人 提交于 2020-01-05 13:06:16
问题 I have a mex function which uses OpenCV that I'm trying to use. The compilation seems to work, but when I try and call the function within MATLAB I get this error: Invalid MEX-file '/path/to/project/mexfunction.mexa64': libopencv_legacy.so.2.4: cannot open shared object file: No such file or directory My OpenCV 2.4.5 install is located at /nwdata/username/ (I compiled myself from scratch using the OpenCV recommended settings from their documentation). I compile with mex using this function:

Matlab Mex32 link error while compiling Felzenszwalb VOC on Windows

拥有回忆 提交于 2020-01-05 08:52:12
问题 I'm compiling a C file (part of voc-release library) with Matlab and I'm getting the error below. I can't seem to solve it. Could anyone tell me what causes this error and what I can do about it? mex -O features.cc Writing library for features.mexw32 c:\users\safaa\appdata\local\temp\mex_ty~1\features.obj .text: undefined reference to '_round' C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Link of 'features.mexw32' failed. 回答1: If you had included more of the error message, I believe that this

Matlab Mex32 link error while compiling Felzenszwalb VOC on Windows

百般思念 提交于 2020-01-05 08:52:12
问题 I'm compiling a C file (part of voc-release library) with Matlab and I'm getting the error below. I can't seem to solve it. Could anyone tell me what causes this error and what I can do about it? mex -O features.cc Writing library for features.mexw32 c:\users\safaa\appdata\local\temp\mex_ty~1\features.obj .text: undefined reference to '_round' C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Link of 'features.mexw32' failed. 回答1: If you had included more of the error message, I believe that this

Generating standalone MEX file with GNU compilers, including libraries

纵饮孤独 提交于 2020-01-05 07:08:33
问题 I have written and compiled a MEX function to be called from a MATLAB routine, it runs great on my computer. However, when I try to have a different computer run my routine, it breaks with an error saying the module does not exist. My MEX function is referencing the GSL libraries, and some others. I want to know if it is possible to compile my MEX function so that is a standalone. When I say standalone I mean that if I just copy the MEX file to another computer, and there are no libraries or

MEX options when compiling with Visual Studio

天大地大妈咪最大 提交于 2020-01-05 06:50:21
问题 For some reasons I have to compile my MEX files under the Visual studio environment. There are many tutorials and my MEX files are working fine. However, there are a few MEX options, say -largeArrayDims in mex options, which I do not know where to turn on under the VS environment. Can anyone offer help? 回答1: The -largeArrayDims option is a switch to the mex command in MATLAB that simply indicates not to define MX_COMPAT_32 . So, in Visual Studio, you don't have to do anything since this is

Strange values at debug for fortran mex code

假如想象 提交于 2020-01-05 03:59:30
问题 I am toying with matlab, mex, intel fortran in visual studio etc. I copied a routine from here doing the multiplication of a matrix by a scalar : C Computational subroutine subroutine xtimesy(x, y, z, m, n) real*8 x, y(3,3), z(3,3) integer m, n do 20 i=1,m do 10 j=1,n z(i,j) = x*y(i,j) 10 continue 20 continue return end The initial wrapping code supposed to produce the mexw64 file was crashing on the elseif (mxIsNumeric(prhs(2)) .ne. 1) then so that I have adapted it as follows : #include

Read 4D Array in MEX File

断了今生、忘了曾经 提交于 2020-01-04 14:31:26
问题 I have a 4 dimensional array in MATLAB; I am trying to access the array in a MEX function. The following creates 'testmatrix', a matrix of 4 dimensions with known data of uint8 type. %Create a 4D array 2x,2y, rgb(3), framenumber(from 1 to 5) %Framenumber from 1 to 5 testmatrix(1,1,1,1) = 0; testmatrix(1,1,1,2) = 1; testmatrix(1,1,1,3) = 2; testmatrix(1,1,1,4) = 3; testmatrix(1,1,1,5) = 4; testmatrix(1,1,2,1) = 5; testmatrix(1,1,2,2) = 6; testmatrix(1,1,2,3) = 7; testmatrix(1,1,2,4) = 8;

How to print C-preprocessor variables like __LINE__ with mexErrMsgTxt() In Matlab MEX

ぃ、小莉子 提交于 2020-01-03 00:55:31
问题 For debugging Matlab-MEX, which can be quite a hassle, it would be nice to have better assertion capabilities. Following this question about mex-assertions, it is possible to define a preprocessor makro, that throws an error to Matlab and prints a string (can mostly replace mxAssert , which unfortunately crashes Matlab2011b). #define myassert( isOK,astr ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(astr) ) It would be much nicer to print the file, line number and caller function, from where