35 for (; first != last; first += 2) {
36 string key(first->toString());
37 const MxArray& val = *(first + 1);
42 else if (key ==
"MinSize")
43 min_size = val.toInt();
46 "Unrecognized option %s", key.c_str());
64 for (; first != last; ++first) {
65 string type(first->toString());
69 else if (
type ==
"Size")
71 else if (
type ==
"Texture")
73 else if (
type ==
"Fill")
77 "Unrecognized segmentation strategy %s",
type.c_str());
102 else if (
type ==
"Size")
104 else if (
type ==
"Texture")
106 else if (
type ==
"Fill")
108 else if (
type ==
"Multiple")
112 "Unrecognized segmentation strategy %s",
type.c_str());
115 "Failed to create SelectiveSearchSegmentationStrategy");
134 int id = rhs[0].toInt();
135 string method(rhs[1].toString());
138 if (method ==
"new") {
150 if (method ==
"delete") {
155 else if (method ==
"clear") {
159 else if (method ==
"load") {
160 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
162 bool loadFromString =
false;
163 for (
int i=3; i<nrhs; i+=2) {
164 string key(rhs[i].toString());
165 if (key ==
"ObjName")
166 objname = rhs[i+1].toString();
167 else if (key ==
"FromString")
168 loadFromString = rhs[i+1].toBool();
171 "Unrecognized option %s", key.
c_str());
180 FileStorage fs(rhs[2].toString(), FileStorage::READ +
181 (loadFromString ? FileStorage::MEMORY : 0));
190 else if (method ==
"save") {
192 obj->
save(rhs[2].toString());
194 else if (method ==
"empty") {
198 else if (method ==
"getDefaultName") {
202 else if (method ==
"setBaseImage") {
207 else if (method ==
"switchToSingleStrategy") {
208 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
211 for (
int i=2; i<nrhs; i+=2) {
212 string key(rhs[i].toString());
214 k = rhs[i+1].toInt();
215 else if (key ==
"Sigma")
216 sigma = rhs[i+1].toFloat();
219 "Unrecognized option %s", key.
c_str());
223 else if (method ==
"switchToSelectiveSearchFast") {
224 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
228 for (
int i=2; i<nrhs; i+=2) {
229 string key(rhs[i].toString());
231 base_k = rhs[i+1].toInt();
232 else if (key ==
"IncK")
233 inc_k = rhs[i+1].toInt();
234 else if (key ==
"Sigma")
235 sigma = rhs[i+1].toFloat();
238 "Unrecognized option %s", key.
c_str());
242 else if (method ==
"switchToSelectiveSearchQuality") {
243 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
247 for (
int i=2; i<nrhs; i+=2) {
248 string key(rhs[i].toString());
250 base_k = rhs[i+1].toInt();
251 else if (key ==
"IncK")
252 inc_k = rhs[i+1].toInt();
253 else if (key ==
"Sigma")
254 sigma = rhs[i+1].toFloat();
257 "Unrecognized option %s", key.
c_str());
261 else if (method ==
"addImage") {
266 else if (method ==
"clearImages") {
270 else if (method ==
"addGraphSegmentation") {
276 else if (method ==
"clearGraphSegmentations") {
280 else if (method ==
"addStrategy") {
284 rhs[2].toString(), rhs.
begin() + 3, rhs.
end());
287 else if (method ==
"clearStrategies") {
291 else if (method ==
"process") {
295 plhs[0] =
MxArray(
Mat(rects,
false).reshape(1,0));
299 "Unrecognized operation %s", method.
c_str());
map< int, Ptr< SelectiveSearchSegmentation > > obj_
Object container.
virtual void clearStrategies()=0
Ptr< SelectiveSearchSegmentationStrategyMultiple > createSelectiveSearchSegmentationStrategyMultiple()
Ptr< SelectiveSearchSegmentationStrategyColor > createSelectiveSearchSegmentationStrategyColor()
virtual void addImage(InputArray img)=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void switchToSelectiveSearchQuality(int base_k=150, int inc_k=150, float sigma=0.8f)=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual void addGraphSegmentation(Ptr< GraphSegmentation > g)=0
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
int last_id
Last object id to allocate.
virtual void setBaseImage(InputArray img)=0
virtual void process(std::vector< Rect > &rects)=0
virtual void addStrategy(Ptr< SelectiveSearchSegmentationStrategy > s)=0
virtual void clearImages()=0
virtual void read(const FileNode &fn)
Ptr< SelectiveSearchSegmentation > createSelectiveSearchSegmentation()
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...
Ptr< SelectiveSearchSegmentationStrategy > create_SelectiveSearchSegmentationStrategy(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of SelectiveSearchSegmentationStrategy using options in arguments.
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 addStrategy(Ptr< SelectiveSearchSegmentationStrategy > g, float weight)=0
virtual void switchToSelectiveSearchFast(int base_k=150, int inc_k=150, float sigma=0.8f)=0
FileNode getFirstTopLevelNode() const
Ptr< GraphSegmentation > create_GraphSegmentation(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of GraphSegmentation using options in arguments.
virtual String getDefaultName() const
Global constant definitions.
Ptr< GraphSegmentation > createGraphSegmentation(double sigma=0.5, float k=300, int min_size=100)
Ptr< SelectiveSearchSegmentationStrategySize > createSelectiveSearchSegmentationStrategySize()
double toDouble() const
Convert MxArray to double.
virtual void clearGraphSegmentations()=0
virtual void save(const String &filename) const
virtual bool empty() const
Ptr< SelectiveSearchSegmentationStrategyMultiple > create_SelectiveSearchSegmentationStrategyMultiple(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of SelectiveSearchSegmentationStrategyMultiple using options in arguments...
Ptr< SelectiveSearchSegmentationStrategyTexture > createSelectiveSearchSegmentationStrategyTexture()
Ptr< SelectiveSearchSegmentationStrategyFill > createSelectiveSearchSegmentationStrategyFill()
virtual void switchToSingleStrategy(int k=200, float sigma=0.8f)=0