38 for (; first != last; first += 2) {
39 string key(first->toString());
40 const MxArray& val = *(first + 1);
43 else if (key ==
"EPS")
47 "Unrecognized option %s", key.c_str());
67 int id = rhs[0].toInt();
68 string method(rhs[1].toString());
71 if (method ==
"new") {
75 OptionsParser opts(rhs.
begin() + 3, rhs.
end());
82 else if (method ==
"guidedFilter") {
88 OptionsParser opts(rhs.
begin() + 4, rhs.
end());
98 if (method ==
"delete") {
103 else if (method ==
"clear") {
107 else if (method ==
"load") {
108 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
110 bool loadFromString =
false;
111 for (
int i=3; i<nrhs; i+=2) {
112 string key(rhs[i].toString());
113 if (key ==
"ObjName")
114 objname = rhs[i+1].toString();
115 else if (key ==
"FromString")
116 loadFromString = rhs[i+1].toBool();
119 "Unrecognized option %s", key.
c_str());
128 FileStorage fs(rhs[2].toString(), FileStorage::READ +
129 (loadFromString ? FileStorage::MEMORY : 0));
138 else if (method ==
"save") {
140 obj->
save(rhs[2].toString());
142 else if (method ==
"empty") {
146 else if (method ==
"getDefaultName") {
150 else if (method ==
"filter") {
151 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
153 for (
int i=3; i<nrhs; i+=2) {
154 string key(rhs[i].toString());
156 dDepth = (rhs[i+1].isChar()) ?
160 "Unrecognized option %s", key.
c_str());
164 obj->
filter(src, dst, dDepth);
169 "Unrecognized operation %s", method.
c_str());
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< std::string, int > ClassNameMap
Translates class name used in MATLAB to equivalent OpenCV depth.
int toInt() const
Convert MxArray to int.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void filter(InputArray src, OutputArray dst, int dDepth=-1)=0
int last_id
Last object id to allocate.
virtual bool isOpened() const
void guidedFilter(InputArray guide, InputArray src, OutputArray dst, int radius, double eps, int dDepth=-1)
struct mxArray_tag mxArray
Forward declaration for mxArray.
OptionsParser(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Parse input arguments.
Option arguments parser used by create and filter methods.
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.
Ptr< GuidedFilter > createGuidedFilter(InputArray guide, int radius, double eps)
virtual void save(const String &filename) const
virtual bool empty() const
map< int, Ptr< GuidedFilter > > obj_
Object container.