36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
41 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
45 for (
int i=2; i<nrhs; i+=2) {
46 string key(rhs[i].toString());
48 sigma = rhs[i+1].toDouble();
50 k = rhs[i+1].toFloat();
51 else if (key ==
"MinSize")
52 min_size = rhs[i+1].toInt();
55 "Unrecognized option %s", key.
c_str());
67 if (method ==
"delete") {
72 else if (method ==
"clear") {
76 else if (method ==
"load") {
77 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
79 bool loadFromString =
false;
80 for (
int i=3; i<nrhs; i+=2) {
81 string key(rhs[i].toString());
83 objname = rhs[i+1].toString();
84 else if (key ==
"FromString")
85 loadFromString = rhs[i+1].toBool();
88 "Unrecognized option %s", key.
c_str());
97 FileStorage fs(rhs[2].toString(), FileStorage::READ +
98 (loadFromString ? FileStorage::MEMORY : 0));
107 else if (method ==
"save") {
109 obj->
save(rhs[2].toString());
111 else if (method ==
"empty") {
115 else if (method ==
"getDefaultName") {
119 else if (method ==
"processImage") {
125 else if (method ==
"get") {
127 string prop(rhs[2].toString());
130 else if (prop ==
"K")
132 else if (prop ==
"MinSize")
136 "Unrecognized property %s", prop.
c_str());
138 else if (method ==
"set") {
140 string prop(rhs[2].toString());
143 else if (prop ==
"K")
144 obj->
setK(rhs[3].toFloat());
145 else if (prop ==
"MinSize")
149 "Unrecognized property %s", prop.
c_str());
153 "Unrecognized operation %s", method.
c_str());
virtual void setK(float k)=0
virtual void setSigma(double sigma)=0
virtual void processImage(InputArray src, OutputArray dst)=0
map< int, Ptr< GraphSegmentation > > obj_
Object container.
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.
virtual bool isOpened() const
virtual double getSigma()=0
struct mxArray_tag mxArray
Forward declaration for mxArray.
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 void setMinSize(int min_size)=0
int last_id
Last object id to allocate.
virtual String getDefaultName() const
Global constant definitions.
Ptr< GraphSegmentation > createGraphSegmentation(double sigma=0.5, float k=300, int min_size=100)
virtual int getMinSize()=0
virtual void save(const String &filename) const
virtual bool empty() const