36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
52 if (method ==
"delete") {
57 else if (method ==
"read") {
58 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
60 bool loadFromString =
false;
61 for (
int i=3; i<nrhs; i+=2) {
62 string key(rhs[i].toString());
64 objname = rhs[i+1].toString();
65 else if (key ==
"FromString")
66 loadFromString = rhs[i+1].toBool();
69 "Unrecognized option %s", key.
c_str());
71 FileStorage fs(rhs[2].toString(), FileStorage::READ +
72 (loadFromString ? FileStorage::MEMORY : 0));
80 else if (method ==
"write") {
82 FileStorage fs(rhs[2].toString(), FileStorage::WRITE +
83 ((nlhs > 0) ? FileStorage::MEMORY : 0));
91 else if (method ==
"train") {
93 string pos_samples(rhs[2].toString()), neg_imgs(rhs[3].toString());
94 obj->
train(pos_samples, neg_imgs);
96 else if (method ==
"detect") {
101 obj->
detect(img, bboxes, confidences);
104 plhs[1] =
MxArray(confidences);
108 "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.
virtual void read(const FileNode &node)=0
virtual bool isOpened() const
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void write(FileStorage &fs) const=0
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...
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 detect(const Mat &img, std::vector< Rect > &bboxes, std::vector< double > &confidences)=0
FileNode getFirstTopLevelNode() const
virtual void train(const std::string &pos_samples, const std::string &neg_imgs)=0
Global constant definitions.
map< int, Ptr< WBDetector > > obj_
Object container.
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
int last_id
Last object id to allocate.