mexopencv  3.4.1
MEX interface for OpenCV library
mex.h
Go to the documentation of this file.
1 
15 #if defined(_MSC_VER)
16 # pragma once
17 #endif
18 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
19 # pragma once
20 #endif
21 
22 #ifndef mex_h
23 #define mex_h
24 #endif
25 
27 #ifndef __MEX_PUBLISHED_API_HPP__
28 #define __MEX_PUBLISHED_API_HPP__
29 
30 
31 #ifndef EXTERN_C
32 # ifdef __cplusplus
33 # define EXTERN_C extern "C"
34 # else
35 # define EXTERN_C extern
36 # endif
37 #endif
38 
39 #if defined(BUILDING_LIBMEX)
40 # include "mex/libmwmex_util.hpp"
41 #else
42 # ifndef LIBMWMEX_API
43 # define LIBMWMEX_API
44 # endif
45 
46 # ifndef LIBMWMEX_API_EXTERN_C
47 # define LIBMWMEX_API_EXTERN_C EXTERN_C LIBMWMEX_API
48 # endif
49 #endif
50 
52 
54 #ifndef mex_typedefs_h
55 #define mex_typedefs_h
56 
57 typedef struct impl_info_tag *MEX_impl_info;
58 
59 #include "matrix.h"
60 
61 #ifdef __cplusplus
62 extern "C"
63 {
64 #endif
65 typedef void (*mex_exit_fn)(void);
66 #ifdef __cplusplus
67 }
68 #endif
69 
71 {
72  const char *name;
75 
76 #ifdef _WIN32
77 #define cicompare(s1,s2) utStrcmpi((s1),(s2))
78 #else
79 #define cicompare(s1,s2) strcmp((s1),(s2))
80 #endif
81 #define cscompare(s1,s2) strcmp((s1),(s2))
82 
83 typedef struct mexFunctionTableEntry_tag {
84  const char * name;
86  int nargin;
87  int nargout;
90 
91 typedef struct _mexLocalFunctionTable {
92  size_t length;
95 
96 typedef struct {
97  void (*initialize)(void);
98  void (*terminate)(void);
100 
101 #define MEX_INFORMATION_VERSION 1
102 
103 typedef struct {
104  int version;
109  int npaths;
110  const char ** paths;
114 
115 typedef mex_information(*fn_mex_file)(void);
116 
117 typedef void (*fn_clean_up_after_error)(void);
118 typedef const char *(*fn_simple_function_to_string)(mxFunctionPtr f);
119 
122 
125 
126 #endif
127 
129 
131 #ifdef DLL_EXPORT_SYM
132 # define MEXFUNCTION_LINKAGE EXTERN_C DLL_EXPORT_SYM
133 #else
134 # ifdef MW_NEEDS_VERSION_H
135 # include "version.h"
136 # define MEXFUNCTION_LINKAGE EXTERN_C DLL_EXPORT_SYM
137 # else
138 # define MEXFUNCTION_LINKAGE EXTERN_C
139 # endif
140 #endif
141 
143 
153 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
154 
155 
156 #include "matrix.h"
157 #include <stdio.h>
158 
159 
165 LIBMWMEX_API_EXTERN_C void mexErrMsgTxt(const char *error_msg);
166 
175 LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char * identifier, const char * err_msg, ...);
176 
185 LIBMWMEX_API_EXTERN_C void mexWarnMsgTxt(const char *warn_msg);
186 
197 LIBMWMEX_API_EXTERN_C void mexWarnMsgIdAndTxt(const char * identifier, const char * warn_msg, ...);
198 
205 LIBMWMEX_API_EXTERN_C int mexPrintf(const char *fmt, ...);
206 
207 #define printf mexPrintf
208 
218 
227 
237 LIBMWMEX_API_EXTERN_C int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name);
238 
248 LIBMWMEX_API_EXTERN_C int mexCallMATLABWithObject(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name);
249 
259 LIBMWMEX_API_EXTERN_C mxArray *mexCallMATLABWithTrap(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name);
260 
270 LIBMWMEX_API_EXTERN_C mxArray *mexCallMATLABWithTrapWithObject(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name);
271 
272 
279 #ifndef MEX_DOUBLE_HANDLE
281 #define mexCallMATLAB mexCallMATLABWithObject
282 #define mexCallMATLABWithTrap mexCallMATLABWithTrapWithObject
283 #define mexGetVariable mexGetVariableWithObject
284 #define mexGet(a,b) \
285 NULL;do{mexGetIsDeprecated x;}while(0)
286 #define mexSet(a,b,c) \
287 0;do{mexSetIsDeprecated x;}while(0)
288 #else
290 
297 LIBMWMEX_API_EXTERN_C const mxArray *mexGet(double handle, const char *property);
298 
306 LIBMWMEX_API_EXTERN_C int mexSet(double handle, const char *property, mxArray *value);
307 
308 #endif
309 
310 
319 
329 LIBMWMEX_API_EXTERN_C void mexPrintAssertion(const char *test, const char *fname, int linenum, const char *message);
330 
337 
346 LIBMWMEX_API_EXTERN_C int mexPutVariable(const char *workspace, const char *name, const mxArray *parray);
347 
355 LIBMWMEX_API_EXTERN_C const mxArray *mexGetVariablePtr(const char *workspace, const char *name);
356 
364 LIBMWMEX_API_EXTERN_C mxArray *mexGetVariable(const char *workspace, const char *name);
365 
369 LIBMWMEX_API_EXTERN_C void mexLock(void);
370 
375 
380 
384 LIBMWMEX_API_EXTERN_C const char *mexFunctionName(void);
385 
392 LIBMWMEX_API_EXTERN_C int mexEvalString(const char *str);
393 
401 
408 
409 #endif /* mex_h */
Definition: mex.h:83
const char ** paths
Definition: mex.h:110
struct _mexLocalFunctionTable * mexLocalFunctionTable
int file_function_table_length
Definition: mex.h:105
Definition: mex.h:96
LIBMWMEX_API_EXTERN_C void mexWarnMsgTxt(const char *warn_msg)
Invoke an unidentified warning.
#define LIBMWMEX_API_EXTERN_C
Definition: mex.h:47
LIBMWMEX_API_EXTERN_C void mexWarnMsgIdAndTxt(const char *identifier, const char *warn_msg,...)
Invoke a warning with message identifier &#39;identifier&#39; and message derived from &#39;fmt&#39; and subsequent a...
int npaths
Definition: mex.h:109
LIBMWMEX_API_EXTERN_C void mexSetTrapFlag(int flag)
set or clear mexCallMATLAB trap flag (if set then an error in mexCallMATLAB is caught and mexCallMATL...
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
mexFunctionTable file_function_table
Definition: mex.h:106
#define mexGet(a, b)
Definition: mex.h:284
struct _mexInitTermTableEntry * mexInitTermTableEntry
LIBMWMEX_API_EXTERN_C mxArray * mexCallMATLABWithTrapWithObject(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
call MATLAB function with trap
LIBMWMEX_API_EXTERN_C void mexErrMsgTxt(const char *error_msg)
Issue error message and return to MATLAB prompt.
void(* mxFunctionPtr)(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[])
Type representing the signature for MEX functions.
Definition: matrix.h:269
LIBMWMEX_API_EXTERN_C const char * mexFunctionName(void)
Return the name of a the MEXfunction currently executing.
void(* fn_clean_up_after_error)(void)
Definition: mex.h:117
LIBMWMEX_API_EXTERN_C void mexMakeMemoryPersistent(void *ptr)
Remove memory previously allocated via mxCalloc from MATLAB&#39;s memory allocation list.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
int version
Definition: mex.h:104
void(* mex_exit_fn)(void)
Definition: mex.h:65
LIBMWMEX_API_EXTERN_C int mexPrintf(const char *fmt,...)
mex equivalent to MATLAB&#39;s "disp" function
const char * name
The name of the global.
Definition: mex.h:72
LIBMWMEX_API_EXTERN_C void mexMakeArrayPersistent(mxArray *pa)
Remove all components of an array plus the array header itself from MATLAB&#39;s memory allocation list...
int init_term_table_length
Definition: mex.h:111
struct _mexLocalFunctionTable * local_function_table
Definition: mex.h:88
struct mexGlobalTableEntry_Tag mexGlobalTableEntry
#define mexCallMATLAB
Definition: mex.h:281
#define mexGetVariable
Definition: mex.h:283
void(* fn_mex_enter_mex_library)(mex_information x)
Definition: mex.h:120
#define MEXFUNCTION_LINKAGE
Definition: mex.h:138
struct _mexLocalFunctionTable _mexLocalFunctionTable
struct mexFunctionTableEntry_tag mexFunctionTableEntry
LIBMWMEX_API_EXTERN_C int mexAtExit(mex_exit_fn exit_fcn)
Register Mex-file&#39;s At-Exit function (accessed via MEX callback)
mexGlobalTable global_variable_table
Definition: mex.h:108
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 ...
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...
LIBMWMEX_API_EXTERN_C int mexCallMATLABWithObject(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
Call MATLAB function.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray ** variable
A pointer to the variable.
Definition: mex.h:73
mexLocalFunctionTable(* fn_mex_get_local_function_table)(void)
Definition: mex.h:123
LIBMWMEX_API_EXTERN_C int mexEvalString(const char *str)
Parse and execute MATLAB syntax in string.
LIBMWMEX_API_EXTERN_C mxArray * mexEvalStringWithTrap(const char *str)
Parse and execute MATLAB syntax in string.
fn_mex_enter_mex_library fn_mex_exit_mex_library
Definition: mex.h:121
mexFunctionTable entries
Definition: mex.h:93
Definition: mex.h:70
struct mexGlobalTableEntry_Tag * mexGlobalTable
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.
LIBMWMEX_API_EXTERN_C bool mexIsGlobal(const mxArray *pa)
This function is deprecated and always return false.
struct _mex_information * mex_information
#define mexCallMATLABWithTrap
Definition: mex.h:282
mexLocalFunctionTable(* fn_mex_set_local_function_table)(mexLocalFunctionTable)
Definition: mex.h:124
struct impl_info_tag * MEX_impl_info
Definition: mex.h:57
mxFunctionPtr f
Definition: mex.h:85
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.
struct mexFunctionTableEntry_tag * mexFunctionTable
int nargin
Definition: mex.h:86
const char * name
Definition: mex.h:84
LIBMWMEX_API_EXTERN_C bool mexIsLocked(void)
Return true if the MEX-function is currently locked, false otherwise.
int nargout
Definition: mex.h:87
mex_information(* fn_mex_file)(void)
Definition: mex.h:115
#define mexSet(a, b, c)
Definition: mex.h:286
mexInitTermTableEntry init_term_table
Definition: mex.h:112
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.
int global_variable_table_length
Definition: mex.h:107