48 for (; first != last; first += 2) {
49 string key(first->toString());
50 const MxArray& val = *(first + 1);
51 if (key ==
"SigmaSpatial")
53 else if (key ==
"SigmaColor")
54 sigmaColor = val.toDouble();
55 else if (key ==
"Mode")
57 else if (key ==
"NumIters")
58 numIters = val.toInt();
61 "Unrecognized option %s", key.c_str());
81 int id = rhs[0].toInt();
82 string method(rhs[1].toString());
85 if (method ==
"new") {
88 OptionsParser opts(rhs.
begin() + 3, rhs.
end());
90 opts.sigmaSpatial, opts.sigmaColor, opts.mode, opts.numIters);
96 else if (method ==
"dtFilter") {
101 OptionsParser opts(rhs.
begin() + 4, rhs.
end());
103 opts.sigmaSpatial, opts.sigmaColor, opts.mode, opts.numIters);
112 if (method ==
"delete") {
117 else if (method ==
"clear") {
121 else if (method ==
"load") {
122 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
124 bool loadFromString =
false;
125 for (
int i=3; i<nrhs; i+=2) {
126 string key(rhs[i].toString());
127 if (key ==
"ObjName")
128 objname = rhs[i+1].toString();
129 else if (key ==
"FromString")
130 loadFromString = rhs[i+1].toBool();
133 "Unrecognized option %s", key.
c_str());
142 FileStorage fs(rhs[2].toString(), FileStorage::READ +
143 (loadFromString ? FileStorage::MEMORY : 0));
152 else if (method ==
"save") {
154 obj->
save(rhs[2].toString());
156 else if (method ==
"empty") {
160 else if (method ==
"getDefaultName") {
164 else if (method ==
"filter") {
165 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
167 for (
int i=3; i<nrhs; i+=2) {
168 string key(rhs[i].toString());
170 dDepth = (rhs[i+1].isChar()) ?
174 "Unrecognized option %s", key.
c_str());
178 obj->
filter(src, dst, dDepth);
183 "Unrecognized operation %s", method.
c_str());
const ConstMap< std::string, int > ClassNameMap
Translates class name used in MATLAB to equivalent OpenCV depth.
int last_id
Last object id to allocate.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Ptr< DTFilter > createDTFilter(InputArray guide, double sigmaSpatial, double sigmaColor, int mode=DTF_NC, int numIters=3)
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void filter(InputArray src, OutputArray dst, int dDepth=-1)=0
map< int, Ptr< DTFilter > > obj_
Object container.
const ConstMap< string, int > EdgeAwareFiltersListMap
Domain Transform filter modes.
virtual void read(const FileNode &fn)
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 void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
double toDouble() const
Convert MxArray to double.
OptionsParser(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Parse input arguments.
virtual void save(const String &filename) const
virtual bool empty() const
void dtFilter(InputArray guide, InputArray src, OutputArray dst, double sigmaSpatial, double sigmaColor, int mode=DTF_NC, int numIters=3)
std::map wrapper with one-line initialization and lookup method.
Option arguments parser used by create and filter methods.