52 int id = rhs[0].toInt();
53 string method(rhs[1].toString());
56 if (method ==
"new") {
60 if (nrhs==4 && !rhs[2].isChar()) {
62 if (rhs[3].numel() == 1) {
63 int initSeedCount = rhs[3].toInt();
67 vector<int> initClusterSeedIndexes(rhs[3].toVector<int>());
73 nargchk(nrhs>=2 && (nrhs%2)==0);
74 int initSampleCount = 2000;
75 int initSeedCount = 400;
76 int pointDistribution = 0;
77 for (
int i=2; i<nrhs; i+=2) {
78 string key(rhs[i].toString());
79 if (key ==
"InitSampleCount")
80 initSampleCount = rhs[i+1].toInt();
81 else if (key ==
"InitSeedCount")
82 initSeedCount = rhs[i+1].toInt();
83 else if (key ==
"PointDistributiontion")
84 pointDistribution = (rhs[i+1].isChar()) ?
89 "Unrecognized option %s", key.
c_str());
92 initSampleCount, initSeedCount, pointDistribution);
100 else if (method ==
"generateInitPoints") {
102 int count = rhs[2].toInt();
103 int pointDistribution = (rhs[3].isChar()) ?
106 PCTSignatures::generateInitPoints(initPoints,
count, pointDistribution);
107 plhs[0] =
MxArray(
Mat(initPoints,
false).reshape(1,0));
110 else if (method ==
"drawSignature") {
111 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
112 float radiusToShorterSideRatio = 1.0f / 8;
113 int borderThickness = 1;
114 for (
int i=4; i<nrhs; i+=2) {
115 string key(rhs[i].toString());
116 if (key ==
"RadiusToShorterSideRatio")
117 radiusToShorterSideRatio = rhs[i+1].toFloat();
118 else if (key ==
"BorderThickness")
119 borderThickness = rhs[i+1].toInt();
122 "Unrecognized option %s", key.
c_str());
127 PCTSignatures::drawSignature(source, signature, result,
128 radiusToShorterSideRatio, borderThickness);
137 if (method ==
"delete") {
142 else if (method ==
"clear") {
146 else if (method ==
"save") {
148 obj->
save(rhs[2].toString());
150 else if (method ==
"load") {
151 nargchk(nrhs>=3 && (nrhs%2)!=0 && nlhs==0);
153 bool loadFromString =
false;
154 for (
int i=3; i<nrhs; i+=2) {
155 string key(rhs[i].toString());
156 if (key ==
"ObjName")
157 objname = rhs[i+1].toString();
158 else if (key ==
"FromString")
159 loadFromString = rhs[i+1].toBool();
162 "Unrecognized option %s", key.
c_str());
164 obj_[id] = (loadFromString ?
165 Algorithm::loadFromString<PCTSignatures>(rhs[2].toString(), objname) :
166 Algorithm::load<PCTSignatures>(rhs[2].toString(), objname));
168 else if (method ==
"empty") {
172 else if (method ==
"getDefaultName") {
176 else if (method ==
"computeSignature") {
183 else if (method ==
"computeSignatures") {
197 else if (method ==
"getSampleCount") {
201 else if (method ==
"getSamplingPoints") {
205 else if (method ==
"setSamplingPoints") {
209 else if (method ==
"setWeight") {
211 obj->
setWeight(rhs[2].toInt(), rhs[3].toFloat());
213 else if (method ==
"setWeights") {
217 else if (method ==
"setTranslation") {
221 else if (method ==
"setTranslations") {
225 else if (method ==
"getInitSeedCount") {
229 else if (method ==
"getInitSeedIndexes") {
233 else if (method ==
"setInitSeedIndexes") {
237 else if (method ==
"get") {
239 string prop(rhs[2].toString());
240 if (prop ==
"GrayscaleBits")
242 else if (prop ==
"WindowRadius")
244 else if (prop ==
"WeightX")
246 else if (prop ==
"WeightY")
248 else if (prop ==
"WeightL")
250 else if (prop ==
"WeightA")
252 else if (prop ==
"WeightB")
254 else if (prop ==
"WeightContrast")
256 else if (prop ==
"WeightEntropy")
258 else if (prop ==
"IterationCount")
260 else if (prop ==
"MaxClustersCount")
262 else if (prop ==
"ClusterMinSize")
264 else if (prop ==
"JoiningDistance")
266 else if (prop ==
"DropThreshold")
268 else if (prop ==
"DistanceFunction")
272 "Unrecognized property %s", prop.
c_str());
274 else if (method ==
"set") {
276 string prop(rhs[2].toString());
277 if (prop ==
"GrayscaleBits")
279 else if (prop ==
"WindowRadius")
281 else if (prop ==
"WeightX")
283 else if (prop ==
"WeightY")
285 else if (prop ==
"WeightL")
287 else if (prop ==
"WeightA")
289 else if (prop ==
"WeightB")
291 else if (prop ==
"WeightContrast")
293 else if (prop ==
"WeightEntropy")
295 else if (prop ==
"IterationCount")
297 else if (prop ==
"MaxClustersCount")
299 else if (prop ==
"ClusterMinSize")
301 else if (prop ==
"JoiningDistance")
303 else if (prop ==
"DropThreshold")
305 else if (prop ==
"DistanceFunction")
310 "Unrecognized property %s", prop.
c_str());
314 "Unrecognized operation %s", method.
c_str());
virtual std::vector< Point2f > getSamplingPoints() const=0
virtual void setIterationCount(int iterationCount)=0
virtual void setJoiningDistance(float joiningDistance)=0
virtual void setWeight(int idx, float value)=0
virtual void setWeights(const std::vector< float > &weights)=0
virtual int getDistanceFunction() const=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void setDropThreshold(float dropThreshold)=0
virtual float getWeightEntropy() const=0
virtual int getIterationCount() const=0
virtual void setWeightA(float weight)=0
virtual int getSampleCount() const=0
virtual void setInitSeedIndexes(std::vector< int > initSeedIndexes)=0
virtual float getWeightA() const=0
virtual void setTranslations(const std::vector< float > &translations)=0
virtual std::vector< int > getInitSeedIndexes() const=0
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual float getDropThreshold() const=0
virtual void computeSignatures(const std::vector< Mat > &images, std::vector< Mat > &signatures) const=0
virtual void setWeightY(float weight)=0
virtual void setWindowRadius(int radius)=0
virtual void setWeightL(float weight)=0
virtual void setDistanceFunction(int distanceFunction)=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...
int last_id
Last object id to allocate.
virtual void setClusterMinSize(int clusterMinSize)=0
const ConstMap< string, int > DistanceFuncMap
Lp distance function selector for option processing.
const ConstMap< string, int > PointDistributionMap
Random point distributions for option processing.
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.
map< int, Ptr< PCTSignatures > > obj_
Object container.
virtual float getWeightY() const=0
virtual float getWeightX() const=0
virtual void setSamplingPoints(std::vector< Point2f > samplingPoints)=0
virtual String getDefaultName() const
Global constant definitions.
virtual void setWeightEntropy(float weight)=0
virtual void setGrayscaleBits(int grayscaleBits)=0
virtual void setWeightB(float weight)=0
virtual int getWindowRadius() const=0
virtual int getGrayscaleBits() const=0
virtual void save(const String &filename) const
virtual bool empty() const
virtual void computeSignature(InputArray image, OutputArray signature) const=0
virtual float getWeightL() const=0
std::map wrapper with one-line initialization and lookup method.
virtual void setWeightX(float weight)=0
virtual int getClusterMinSize() const=0
virtual int getInitSeedCount() const=0
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
virtual float getJoiningDistance() const=0
virtual float getWeightContrast() const=0
virtual void setTranslation(int idx, float value)=0
virtual int getMaxClustersCount() const=0
virtual void setWeightContrast(float weight)=0
virtual void setMaxClustersCount(int maxClustersCount)=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual float getWeightB() const=0