mexopencv  3.4.1
MEX interface for OpenCV library
Classes | Macros | Functions
mex.h File Reference
#include "matrix.h"
#include <stdio.h>

Go to the source code of this file.

Classes

struct  mexGlobalTableEntry_Tag
 
struct  mexFunctionTableEntry_tag
 
struct  _mexLocalFunctionTable
 
struct  _mexInitTermTableEntry
 
struct  _mex_information
 

Macros

#define mex_h
 
#define printf   mexPrintf
 
#define __MEX_PUBLISHED_API_HPP__
 
#define EXTERN_C   extern
 
#define LIBMWMEX_API
 
#define LIBMWMEX_API_EXTERN_C   EXTERN_C LIBMWMEX_API
 
#define MEXFUNCTION_LINKAGE   EXTERN_C
 

Remove usage of deprecated function mexGet and mexSet from MEX code and use mxGetProperty and mxSetProperty instead.

Otherwise, define the macro MEX_DOUBLE_HANDLE by re-compiling the MEX code with -DMEX_DOUBLE_HANDLE switch

#define mexCallMATLAB   mexCallMATLABWithObject
 
#define mexCallMATLABWithTrap   mexCallMATLABWithTrapWithObject
 
#define mexGetVariable   mexGetVariableWithObject
 
#define mexGet(a, b)   NULL;do{mexGetIsDeprecated x;}while(0)
 
#define mexSet(a, b, c)   0;do{mexSetIsDeprecated x;}while(0)
 

Functions

MEXFUNCTION_LINKAGE void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 mexFunction is the user-defined C routine that is called upon invocation of a MEX-function. More...
 
LIBMWMEX_API_EXTERN_C void mexErrMsgTxt (const char *error_msg)
 Issue error message and return to MATLAB prompt. More...
 
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt (const char *identifier, const char *err_msg,...)
 Issue formatted error message with corresponding error identifier and return to MATLAB prompt. More...
 
LIBMWMEX_API_EXTERN_C void mexWarnMsgTxt (const char *warn_msg)
 Invoke an unidentified warning. More...
 
LIBMWMEX_API_EXTERN_C void mexWarnMsgIdAndTxt (const char *identifier, const char *warn_msg,...)
 Invoke a warning with message identifier 'identifier' and message derived from 'fmt' and subsequent arguments. More...
 
LIBMWMEX_API_EXTERN_C int mexPrintf (const char *fmt,...)
 mex equivalent to MATLAB's "disp" function More...
 
LIBMWMEX_API_EXTERN_C void mexMakeArrayPersistent (mxArray *pa)
 Remove all components of an array plus the array header itself from MATLAB's memory allocation list. More...
 
LIBMWMEX_API_EXTERN_C void mexMakeMemoryPersistent (void *ptr)
 Remove memory previously allocated via mxCalloc from MATLAB's memory allocation list. More...
 
LIBMWMEX_API_EXTERN_C int mexCallMATLAB (int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
 call MATLAB function More...
 
LIBMWMEX_API_EXTERN_C int mexCallMATLABWithObject (int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
 Call MATLAB function. More...
 
LIBMWMEX_API_EXTERN_C mxArraymexCallMATLABWithTrap (int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
 call MATLAB function with Trap More...
 
LIBMWMEX_API_EXTERN_C mxArraymexCallMATLABWithTrapWithObject (int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
 call MATLAB function with trap More...
 
LIBMWMEX_API_EXTERN_C void mexSetTrapFlag (int flag)
 set or clear mexCallMATLAB trap flag (if set then an error in mexCallMATLAB is caught and mexCallMATLAB will return a status value, if not set an error will cause control to revert to MATLAB) More...
 
LIBMWMEX_API_EXTERN_C void mexPrintAssertion (const char *test, const char *fname, int linenum, const char *message)
 Print an assertion-style error message and return control to the MATLAB command line. More...
 
LIBMWMEX_API_EXTERN_C bool mexIsGlobal (const mxArray *pa)
 This function is deprecated and always return false. More...
 
LIBMWMEX_API_EXTERN_C int mexPutVariable (const char *workspace, const char *name, const mxArray *parray)
 Place a copy of the array value into the specified workspace with the specified name. More...
 
LIBMWMEX_API_EXTERN_C const mxArraymexGetVariablePtr (const char *workspace, const char *name)
 return a pointer to the array value with the specified variable name in the specified workspace More...
 
LIBMWMEX_API_EXTERN_C mxArraymexGetVariable (const char *workspace, const char *name)
 return a copy of the array value with the specified variable name in the specified workspace More...
 
LIBMWMEX_API_EXTERN_C void mexLock (void)
 Lock a MEX-function so that it cannot be cleared from memory. More...
 
LIBMWMEX_API_EXTERN_C void mexUnlock (void)
 Unlock a locked MEX-function so that it can be cleared from memory. More...
 
LIBMWMEX_API_EXTERN_C bool mexIsLocked (void)
 Return true if the MEX-function is currently locked, false otherwise. More...
 
LIBMWMEX_API_EXTERN_C const char * mexFunctionName (void)
 Return the name of a the MEXfunction currently executing. More...
 
LIBMWMEX_API_EXTERN_C int mexEvalString (const char *str)
 Parse and execute MATLAB syntax in string. More...
 
LIBMWMEX_API_EXTERN_C mxArraymexEvalStringWithTrap (const char *str)
 Parse and execute MATLAB syntax in string. More...
 
LIBMWMEX_API_EXTERN_C int mexAtExit (mex_exit_fn exit_fcn)
 Register Mex-file's At-Exit function (accessed via MEX callback) More...
 
#define mex_typedefs_h
 
#define cicompare(s1, s2)   strcmp((s1),(s2))
 
#define cscompare(s1, s2)   strcmp((s1),(s2))
 
#define MEX_INFORMATION_VERSION   1
 
typedef struct impl_info_tag * MEX_impl_info
 
typedef void(* mex_exit_fn) (void)
 
typedef struct mexGlobalTableEntry_Tag mexGlobalTableEntry
 
typedef struct mexGlobalTableEntry_TagmexGlobalTable
 
typedef struct mexFunctionTableEntry_tag mexFunctionTableEntry
 
typedef struct mexFunctionTableEntry_tagmexFunctionTable
 
typedef struct _mexLocalFunctionTable _mexLocalFunctionTable
 
typedef struct _mexLocalFunctionTablemexLocalFunctionTable
 
typedef struct _mexInitTermTableEntrymexInitTermTableEntry
 
typedef struct _mex_informationmex_information
 
typedef mex_information(* fn_mex_file) (void)
 
typedef void(* fn_clean_up_after_error) (void)
 
typedef const char *(* fn_simple_function_to_string) (mxFunctionPtr f)
 
typedef void(* fn_mex_enter_mex_library) (mex_information x)
 
typedef fn_mex_enter_mex_library fn_mex_exit_mex_library
 
typedef mexLocalFunctionTable(* fn_mex_get_local_function_table) (void)
 
typedef mexLocalFunctionTable(* fn_mex_set_local_function_table) (mexLocalFunctionTable)
 

Detailed Description

PUBLISHed header for libmex, the mex library.

This header file "mex.h" declares all the types, macros and functions necessary to interface mex files with the current version of MATLAB. See the release notes for information on supporting syntax from earlier versions.

Definition in file mex.h.

Macro Definition Documentation

◆ __MEX_PUBLISHED_API_HPP__

#define __MEX_PUBLISHED_API_HPP__

Definition at line 28 of file mex.h.

◆ cicompare

#define cicompare (   s1,
  s2 
)    strcmp((s1),(s2))

Definition at line 79 of file mex.h.

◆ cscompare

#define cscompare (   s1,
  s2 
)    strcmp((s1),(s2))

Definition at line 81 of file mex.h.

◆ EXTERN_C

#define EXTERN_C   extern

Definition at line 35 of file mex.h.

◆ LIBMWMEX_API

#define LIBMWMEX_API

Definition at line 43 of file mex.h.

◆ LIBMWMEX_API_EXTERN_C

#define LIBMWMEX_API_EXTERN_C   EXTERN_C LIBMWMEX_API

Definition at line 47 of file mex.h.

◆ mex_h

#define mex_h

Definition at line 23 of file mex.h.

◆ MEX_INFORMATION_VERSION

#define MEX_INFORMATION_VERSION   1

Definition at line 101 of file mex.h.

◆ mex_typedefs_h

#define mex_typedefs_h

Definition at line 55 of file mex.h.

◆ mexCallMATLAB

#define mexCallMATLAB   mexCallMATLABWithObject

Definition at line 281 of file mex.h.

◆ mexCallMATLABWithTrap

#define mexCallMATLABWithTrap   mexCallMATLABWithTrapWithObject

Definition at line 282 of file mex.h.

◆ MEXFUNCTION_LINKAGE

#define MEXFUNCTION_LINKAGE   EXTERN_C

Definition at line 138 of file mex.h.

◆ mexGet

#define mexGet (   a,
 
)    NULL;do{mexGetIsDeprecated x;}while(0)

Definition at line 284 of file mex.h.

◆ mexGetVariable

#define mexGetVariable   mexGetVariableWithObject

Definition at line 283 of file mex.h.

◆ mexSet

#define mexSet (   a,
  b,
 
)    0;do{mexSetIsDeprecated x;}while(0)

Definition at line 286 of file mex.h.

◆ printf

#define printf   mexPrintf

Definition at line 207 of file mex.h.

Typedef Documentation

◆ _mexLocalFunctionTable

◆ fn_clean_up_after_error

typedef void(* fn_clean_up_after_error) (void)

Definition at line 117 of file mex.h.

◆ fn_mex_enter_mex_library

typedef void(* fn_mex_enter_mex_library) (mex_information x)

Definition at line 120 of file mex.h.

◆ fn_mex_exit_mex_library

Definition at line 121 of file mex.h.

◆ fn_mex_file

typedef mex_information(* fn_mex_file) (void)

Definition at line 115 of file mex.h.

◆ fn_mex_get_local_function_table

typedef mexLocalFunctionTable(* fn_mex_get_local_function_table) (void)

Definition at line 123 of file mex.h.

◆ fn_mex_set_local_function_table

typedef mexLocalFunctionTable(* fn_mex_set_local_function_table) (mexLocalFunctionTable)

Definition at line 124 of file mex.h.

◆ fn_simple_function_to_string

typedef const char*(* fn_simple_function_to_string) (mxFunctionPtr f)

Definition at line 118 of file mex.h.

◆ mex_exit_fn

typedef void(* mex_exit_fn) (void)

Definition at line 65 of file mex.h.

◆ MEX_impl_info

typedef struct impl_info_tag* MEX_impl_info

Definition at line 57 of file mex.h.

◆ mex_information

◆ mexFunctionTable

◆ mexFunctionTableEntry

◆ mexGlobalTable

◆ mexGlobalTableEntry

◆ mexInitTermTableEntry

◆ mexLocalFunctionTable

Function Documentation

◆ mexAtExit()

LIBMWMEX_API_EXTERN_C int mexAtExit ( mex_exit_fn  exit_fcn)

Register Mex-file's At-Exit function (accessed via MEX callback)

Parameters
exit_fcn

◆ mexCallMATLAB()

LIBMWMEX_API_EXTERN_C int mexCallMATLAB ( int  nlhs,
mxArray plhs[],
int  nrhs,
mxArray prhs[],
const char *  fcn_name 
)

call MATLAB function

Parameters
nlhsnumber of expected outputs
plhspointer array to outputs
nrhsnumber of inputs
prhspointer array to inputs
fcn_namename of function to execute

◆ mexCallMATLABWithObject()

LIBMWMEX_API_EXTERN_C int mexCallMATLABWithObject ( int  nlhs,
mxArray plhs[],
int  nrhs,
mxArray prhs[],
const char *  fcn_name 
)

Call MATLAB function.

Parameters
nlhsnumber of expected outputs
plhspointer array to outputs
nrhsnumber of inputs
prhspointer array to inputs
fcn_namename of function to execute

◆ mexCallMATLABWithTrap()

LIBMWMEX_API_EXTERN_C mxArray* mexCallMATLABWithTrap ( int  nlhs,
mxArray plhs[],
int  nrhs,
mxArray prhs[],
const char *  fcn_name 
)

call MATLAB function with Trap

Parameters
nlhsnumber of expected outputs
plhspointer array to outputs
nrhsnumber of inputs
prhspointer array to inputs
fcn_namename of function to execute

◆ mexCallMATLABWithTrapWithObject()

LIBMWMEX_API_EXTERN_C mxArray* mexCallMATLABWithTrapWithObject ( int  nlhs,
mxArray plhs[],
int  nrhs,
mxArray prhs[],
const char *  fcn_name 
)

call MATLAB function with trap

Parameters
nlhsnumber of expected outputs
plhspointer array to outputs
nrhsnumber of inputs
prhspointer array to inputs
fcn_namename of function to execute

◆ mexErrMsgIdAndTxt()

LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt ( const char *  identifier,
const char *  err_msg,
  ... 
)

Issue formatted error message with corresponding error identifier and return to MATLAB prompt.

Parameters
identifierstring with error message identifier
err_msgstring with error message printf-style format
...any additional arguments

◆ mexErrMsgTxt()

LIBMWMEX_API_EXTERN_C void mexErrMsgTxt ( const char *  error_msg)

Issue error message and return to MATLAB prompt.

Parameters
error_msgstring with error message

◆ mexEvalString()

LIBMWMEX_API_EXTERN_C int mexEvalString ( const char *  str)

Parse and execute MATLAB syntax in string.

Returns zero if successful, and a non zero value if an error occurs.

Parameters
strmatlab command string

◆ mexEvalStringWithTrap()

LIBMWMEX_API_EXTERN_C mxArray* mexEvalStringWithTrap ( const char *  str)

Parse and execute MATLAB syntax in string.

Returns NULL if successful, and an MException if an error occurs.

Parameters
strmatlab command string

◆ mexFunction()

MEXFUNCTION_LINKAGE void mexFunction ( int  nlhs,
mxArray plhs[],
int  nrhs,
const mxArray prhs[] 
)

mexFunction is the user-defined C routine that is called upon invocation of a MEX-function.

Parameters
nlhsnumber of expected outputs
plhsarray of pointers to output arguments
nrhsnumber of inputs
prhsarray of pointers to input arguments

mexFunction is the user-defined C routine that is called upon invocation of a MEX-function.

Parameters
nlhsnumber of left-hand-side arguments
plhspointers to mxArrays in the left-hand-side
nrhsnumber of right-hand-side arguments
prhspointers to mxArrays in the right-hand-side

Definition at line 19 of file testMxArray1_.cpp.

◆ mexFunctionName()

LIBMWMEX_API_EXTERN_C const char* mexFunctionName ( void  )

Return the name of a the MEXfunction currently executing.

◆ mexGetVariable()

LIBMWMEX_API_EXTERN_C mxArray* mexGetVariable ( const char *  workspace,
const char *  name 
)

return a copy of the array value with the specified variable name in the specified workspace

Parameters
workspace
namename of variable in question

◆ mexGetVariablePtr()

LIBMWMEX_API_EXTERN_C const mxArray* mexGetVariablePtr ( const char *  workspace,
const char *  name 
)

return a pointer to the array value with the specified variable name in the specified workspace

Parameters
workspace
namename of symbol

◆ mexIsGlobal()

LIBMWMEX_API_EXTERN_C bool mexIsGlobal ( const mxArray pa)

This function is deprecated and always return false.

Parameters
pa

◆ mexIsLocked()

LIBMWMEX_API_EXTERN_C bool mexIsLocked ( void  )

Return true if the MEX-function is currently locked, false otherwise.

◆ mexLock()

LIBMWMEX_API_EXTERN_C void mexLock ( void  )

Lock a MEX-function so that it cannot be cleared from memory.

◆ mexMakeArrayPersistent()

LIBMWMEX_API_EXTERN_C void mexMakeArrayPersistent ( mxArray pa)

Remove all components of an array plus the array header itself from MATLAB's memory allocation list.

The array will now persist between calls to the mex function. To destroy this array, you will need to explicitly call mxDestroyArray.

Parameters
papointer to array

◆ mexMakeMemoryPersistent()

LIBMWMEX_API_EXTERN_C void mexMakeMemoryPersistent ( void *  ptr)

Remove memory previously allocated via mxCalloc from MATLAB's memory allocation list.

To free this memory, you will need to explicitly call mxFree.

Parameters
ptrpointer to memory

◆ mexPrintAssertion()

LIBMWMEX_API_EXTERN_C void mexPrintAssertion ( const char *  test,
const char *  fname,
int  linenum,
const char *  message 
)

Print an assertion-style error message and return control to the MATLAB command line.

Parameters
test
fname
linenum
message

◆ mexPrintf()

LIBMWMEX_API_EXTERN_C int mexPrintf ( const char *  fmt,
  ... 
)

mex equivalent to MATLAB's "disp" function

Parameters
fmtprintf style format
...any additional arguments

◆ mexPutVariable()

LIBMWMEX_API_EXTERN_C int mexPutVariable ( const char *  workspace,
const char *  name,
const mxArray parray 
)

Place a copy of the array value into the specified workspace with the specified name.

Parameters
workspace
name
parraymatrix to copy

◆ mexSetTrapFlag()

LIBMWMEX_API_EXTERN_C void mexSetTrapFlag ( int  flag)

set or clear mexCallMATLAB trap flag (if set then an error in mexCallMATLAB is caught and mexCallMATLAB will return a status value, if not set an error will cause control to revert to MATLAB)

Parameters
flag

◆ mexUnlock()

LIBMWMEX_API_EXTERN_C void mexUnlock ( void  )

Unlock a locked MEX-function so that it can be cleared from memory.

◆ mexWarnMsgIdAndTxt()

LIBMWMEX_API_EXTERN_C void mexWarnMsgIdAndTxt ( const char *  identifier,
const char *  warn_msg,
  ... 
)

Invoke a warning with message identifier 'identifier' and message derived from 'fmt' and subsequent arguments.

The warning may either get printed as is (if it is set to 'on'), or not actually get printed (if set to 'off'). See 'help warning' in MATLAB for more details.

Parameters
identifierstring with warning message identifer
warn_msgstring with warning message printf-style format
...any additional arguments

◆ mexWarnMsgTxt()

LIBMWMEX_API_EXTERN_C void mexWarnMsgTxt ( const char *  warn_msg)

Invoke an unidentified warning.

Such warnings can only be affected by the M-code 'warning * all', since they have no specific identifier.

Parameters
warn_msgstring with warning message
See also
mexWarnMsgIdAndTxt.