52 int id = rhs[0].toInt();
53 string method(rhs[1].toString());
56 if (method ==
"new") {
57 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
58 int distanceFunction = 3;
59 int similarityFunction = 2;
60 float similarityParameter = 1.0f;
61 for (
int i=2; i<nrhs; i+=2) {
62 string key(rhs[i].toString());
63 if (key ==
"DistanceFunction")
64 distanceFunction = (rhs[i+1].isChar()) ?
66 else if (key ==
"SimilarityFunction")
67 similarityFunction = (rhs[i+1].isChar()) ?
69 else if (key ==
"SimilarityParameter")
70 similarityParameter = rhs[i+1].toFloat();
73 "Unrecognized option %s", key.
c_str());
76 distanceFunction, similarityFunction, similarityParameter);
86 if (method ==
"delete") {
91 else if (method ==
"clear") {
95 else if (method ==
"save") {
97 obj->
save(rhs[2].toString());
99 else if (method ==
"load") {
100 nargchk(nrhs>=3 && (nrhs%2)!=0 && nlhs==0);
102 bool loadFromString =
false;
103 for (
int i=3; i<nrhs; i+=2) {
104 string key(rhs[i].toString());
105 if (key ==
"ObjName")
106 objname = rhs[i+1].toString();
107 else if (key ==
"FromString")
108 loadFromString = rhs[i+1].toBool();
111 "Unrecognized option %s", key.
c_str());
113 obj_[id] = (loadFromString ?
114 Algorithm::loadFromString<PCTSignaturesSQFD>(rhs[2].toString(), objname) :
115 Algorithm::load<PCTSignaturesSQFD>(rhs[2].toString(), objname));
117 else if (method ==
"empty") {
121 else if (method ==
"getDefaultName") {
125 else if (method ==
"computeQuadraticFormDistance") {
132 else if (method ==
"computeQuadraticFormDistances") {
150 "Unrecognized operation %s", method.
c_str());
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
const ConstMap< string, int > SimilarityFuncMap
Similarity function selector for option processing.
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void computeQuadraticFormDistances(const Mat &sourceSignature, const std::vector< Mat > &imageSignatures, std::vector< float > &distances) const=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
map< int, Ptr< PCTSignaturesSQFD > > obj_
Object container.
virtual float computeQuadraticFormDistance(InputArray _signature0, InputArray _signature1) const=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...
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 String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const
std::map wrapper with one-line initialization and lookup method.
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
const ConstMap< string, int > DistanceFuncMap
Lp distance function selector for option processing.
int last_id
Last object id to allocate.