9 #include "opencv2/xobjdetect.hpp" 19 map<int,Ptr<WBDetector> > obj_;
29 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
35 vector<MxArray> rhs(prhs, prhs+nrhs);
36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
42 obj_[++last_id] = WBDetector::create();
48 Ptr<WBDetector> obj = obj_[id];
49 if (method ==
"delete") {
53 else if (method ==
"read") {
55 FileStorage fs(rhs[2].toString(), FileStorage::READ);
56 obj->read(fs.getFirstTopLevelNode());
58 mexErrMsgIdAndTxt(
"mexopencv:error",
"Failed to read detector");
60 else if (method ==
"write") {
62 FileStorage fs(rhs[2].toString(), FileStorage::WRITE);
66 else if (method ==
"train") {
68 string pos_samples(rhs[2].toString()), neg_imgs(rhs[3].toString());
69 obj->train(pos_samples, neg_imgs);
71 else if (method ==
"detect") {
73 Mat img(rhs[2].toMat());
75 vector<double> confidences;
76 obj->detect(img, bboxes, confidences);
82 mexErrMsgIdAndTxt(
"mexopencv:error",
83 "Unrecognized operation %s", method.c_str());
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.