34 int id = rhs[0].toInt();
35 string method(rhs[1].toString());
38 if (method ==
"new") {
39 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
40 int num_components = 0;
41 for (
int i=2; i<nrhs; i+=2) {
42 string key(rhs[i].toString());
43 if (key ==
"NumComponents")
44 num_components = rhs[i+1].toInt();
47 "Unrecognized option %s", key.
c_str());
55 else if (method ==
"subspaceProject") {
61 dst = LDA::subspaceProject(W,
mean, src);
65 else if (method ==
"subspaceReconstruct") {
71 dst = LDA::subspaceReconstruct(W,
mean, src);
80 if (method ==
"delete") {
85 else if (method ==
"load") {
86 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
87 bool loadFromString =
false;
88 for (
int i=3; i<nrhs; i+=2) {
89 string key(rhs[i].toString());
90 if (key ==
"FromString")
91 loadFromString = rhs[i+1].toBool();
94 "Unrecognized option %s", key.
c_str());
96 string fname(rhs[2].toString());
98 FileStorage fs(fname, FileStorage::READ + FileStorage::MEMORY);
106 else if (method ==
"save") {
108 string fname(rhs[2].toString());
111 FileStorage fs(fname, FileStorage::WRITE + FileStorage::MEMORY);
121 else if (method ==
"compute") {
124 if (rhs[2].isCell()) {
133 else if (method ==
"project") {
138 else if (method ==
"reconstruct") {
143 else if (method ==
"get") {
145 string prop(rhs[2].toString());
146 if (prop ==
"eigenvalues")
148 else if (prop ==
"eigenvectors")
152 "Unrecognized property %s", prop.
c_str());
156 "Unrecognized operation %s", method.
c_str());
Scalar mean(InputArray src, InputArray mask=noArray())
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
void load(const String &filename)
int last_id
Last object id to allocate.
virtual String releaseAndGetString()
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...
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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.
void save(const String &filename) const
void compute(InputArrayOfArrays src, InputArray labels)
Global constant definitions.
Mat project(InputArray src)
Mat reconstruct(InputArray src)
map< int, Ptr< LDA > > obj_
Object container.