42     int id = rhs[0].toInt();
    43     string method(rhs[1].toString());
    46     if (method == 
"new") {
    47         nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
    48         float segEgbThresholdI = 0.08f;
    49         int minRegionSizeI = 100;
    50         float segEgbThresholdII = 0.28f;
    51         int minRegionSizeII = 200;
    52         float spatialWeight = 0.6f;
    53         int slicSpixelSize = 8;
    55         for (
int i=4; i<nrhs; i+=2) {
    56             string key(rhs[i].toString());
    57             if (key == 
"SegEgbThresholdI")
    58                 segEgbThresholdI = rhs[i+1].toFloat();
    59             else if (key == 
"MinRegionSizeI")
    60                 minRegionSizeI = rhs[i+1].toInt();
    61             else if (key == 
"SegEgbThresholdII")
    62                 segEgbThresholdII = rhs[i+1].toFloat();
    63             else if (key == 
"MinRegionSizeII")
    64                 minRegionSizeII = rhs[i+1].toInt();
    65             else if (key == 
"SpatialWeight")
    66                 spatialWeight = rhs[i+1].toFloat();
    67             else if (key == 
"SlicSpixelSize")
    68                 slicSpixelSize = rhs[i+1].toInt();
    69             else if (key == 
"NumSlicIter")
    70                 numSlicIter = rhs[i+1].toInt();
    73                     "Unrecognized option %s", key.
c_str());
    75         int height = rhs[2].toInt(),
    76             width = rhs[3].toInt();
    78             segEgbThresholdI, minRegionSizeI, segEgbThresholdII,
    79             minRegionSizeII, spatialWeight, slicSpixelSize, numSlicIter);
    89     if (method == 
"delete") {
    94     else if (method == 
"clear") {
    98     else if (method == 
"load") {
    99         nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
   101         bool loadFromString = 
false;
   102         for (
int i=3; i<nrhs; i+=2) {
   103             string key(rhs[i].toString());
   104             if (key == 
"ObjName")
   105                 objname = rhs[i+1].toString();
   106             else if (key == 
"FromString")
   107                 loadFromString = rhs[i+1].toBool();
   110                     "Unrecognized option %s", key.
c_str());
   119         FileStorage fs(rhs[2].toString(), FileStorage::READ +
   120             (loadFromString ? FileStorage::MEMORY : 0));
   129     else if (method == 
"save") {
   131         obj->
save(rhs[2].toString());
   133     else if (method == 
"empty") {
   137     else if (method == 
"getDefaultName") {
   141     else if (method == 
"performSegment") {
   142         nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
   145         for (
int i=3; i<nrhs; i+=2) {
   146             string key(rhs[i].toString());
   148                 ifDraw = rhs[i+1].toBool();
   149             else if (key == 
"Backend")
   153                     "Unrecognized option %s", key.
c_str());
   161     else if (method == 
"get") {
   163         string prop(rhs[2].toString());
   164         if (prop == 
"SegEgbThresholdI")
   166         else if (prop == 
"MinRegionSizeI")
   168         else if (prop == 
"SegEgbThresholdII")
   170         else if (prop == 
"MinRegionSizeII")
   172         else if (prop == 
"SpatialWeight")
   174         else if (prop == 
"SlicSpixelSize")
   176         else if (prop == 
"NumSlicIter")
   180                 "Unrecognized property %s", prop.
c_str());
   182     else if (method == 
"set") {
   184         string prop(rhs[2].toString());
   185         if (prop == 
"SegEgbThresholdI")
   187         else if (prop == 
"MinRegionSizeI")
   189         else if (prop == 
"SegEgbThresholdII")
   191         else if (prop == 
"MinRegionSizeII")
   193         else if (prop == 
"SpatialWeight")
   195         else if (prop == 
"SlicSpixelSize")
   197         else if (prop == 
"NumSlicIter")
   201                 "Unrecognized property %s", prop.
c_str());
   205             "Unrecognized operation %s", method.
c_str());
 virtual float getSegEgbThresholdII()=0
 
virtual void setSpatialWeight(float w)=0
 
virtual void setMinRegionSizeII(int n)=0
 
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory. 
 
virtual bool isOpened() const
 
virtual void setSlicSpixelSize(int n)=0
 
virtual int getMinRegionSizeII()=0
 
struct mxArray_tag mxArray
Forward declaration for mxArray. 
 
virtual void setSegEgbThresholdII(float c)=0
 
virtual void read(const FileNode &fn)
 
virtual float getSpatialWeight()=0
 
virtual void setSegEgbThresholdI(float c)=0
 
virtual Mat performSegmentCpu(InputArray src, bool ifDraw=true)=0
 
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...
 
virtual Mat performSegmentGpu(InputArray src, bool ifDraw=true)=0
 
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. 
 
virtual void setNumSlicIter(int n)=0
 
FileNode getFirstTopLevelNode() const
 
virtual void setMinRegionSizeI(int n)=0
 
map< int, Ptr< HfsSegment > > obj_
Object container. 
 
virtual String getDefaultName() const
 
virtual int getSlicSpixelSize()=0
 
Global constant definitions. 
 
virtual int getMinRegionSizeI()=0
 
int last_id
Last object id to allocate. 
 
virtual void save(const String &filename) const
 
virtual bool empty() const
 
const ConstMap< string, int > BackendsMap
 
std::map wrapper with one-line initialization and lookup method. 
 
virtual float getSegEgbThresholdI()=0
 
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
virtual int getNumSlicIter()=0
 
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.