34 rhs[1] =
MxArray(image_.getMat());
38 bool success = (
mexCallMATLAB(1, &lhs, 2, rhs,
"feval") == 0);
65 for (; first != last; first += 2) {
66 string key(first->toString());
67 const MxArray& val = *(first + 1);
68 if (key ==
"CascadeDepth")
69 parameters.
cascade_depth =
static_cast<unsigned long>(val.toInt());
70 else if (key ==
"TreeDepth")
71 parameters.
tree_depth =
static_cast<unsigned long>(val.toInt());
72 else if (key ==
"NumTreesPerCascadeLevel")
74 else if (key ==
"LearningRate")
76 else if (key ==
"OversamplingAmount")
78 else if (key ==
"NumTestCoordinates")
80 else if (key ==
"Lambda")
81 parameters.
lambda = val.toFloat();
82 else if (key ==
"NumTestSplits")
84 else if (key ==
"ConfigFile")
88 "Unrecognized option %s", key.c_str());
108 int id = rhs[0].toInt();
109 func = rhs[1].toString();
110 string method(rhs[2].toString());
113 if (method ==
"new") {
125 if (method ==
"delete") {
130 else if (method ==
"clear") {
134 else if (method ==
"empty") {
138 else if (method ==
"getDefaultName") {
142 else if (method ==
"read") {
143 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs==0);
145 bool loadFromString =
false;
146 for (
int i=4; i<nrhs; i+=2) {
147 string key(rhs[i].toString());
148 if (key ==
"ObjName")
149 objname = rhs[i+1].toString();
150 else if (key ==
"FromString")
151 loadFromString = rhs[i+1].toBool();
154 "Unrecognized option %s", key.
c_str());
156 FileStorage fs(rhs[3].toString(), FileStorage::READ +
157 (loadFromString ? FileStorage::MEMORY : 0));
165 else if (method ==
"write") {
167 FileStorage fs(rhs[3].toString(), FileStorage::WRITE +
168 ((nlhs > 0) ? FileStorage::MEMORY : 0));
177 else if (method ==
"training") {
178 nargchk(nrhs>=7 && (nrhs%2)==1 && nlhs<=1);
179 string modelFilename =
"face_landmarks.dat";
180 for (
int i=7; i<nrhs; i+=2) {
181 string key(rhs[i].toString());
182 if (key ==
"ModelFilename")
183 modelFilename = rhs[i+1].toString();
186 "Unrecognized option %s", key.
c_str());
197 string configfile(rhs[5].toString());
198 Size scale(rhs[6].toSize());
199 bool b = obj->
training(images, landmarks, configfile, scale, modelFilename);
202 else if (method ==
"loadModel") {
204 string filename(rhs[3].toString());
207 else if (method ==
"fit") {
212 bool b = obj->
fit(image, faces, landmarks);
217 else if (method ==
"setFaceDetector") {
219 func = rhs[3].toString();
223 else if (method ==
"getFaces") {
227 bool b = obj->
getFaces(image, faces);
234 "Unrecognized operation %s", method.
c_str());
bool matlab_face_detector(InputArray image_, OutputArray faces_, void *userData)
Custom face detector implemented as a MATLAB function.
unsigned long num_test_coordinates
unsigned long num_trees_per_cascade_level
virtual bool getFaces(InputArray image, OutputArray faces)=0
void copyTo(OutputArray m) const
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
int last_id
Last object id to allocate.
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxDestroyArray(mxArray *pa)
mxArray destructor
Ptr< FacemarkKazemi > createFacemarkKazemi(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of FacemarkKazemi using options in arguments.
virtual bool isOpened() const
unsigned long oversampling_amount
struct mxArray_tag mxArray
Forward declaration for mxArray.
unsigned long cascade_depth
virtual String releaseAndGetString()
virtual void training(String imageList, String groundTruth)=0
virtual void read(const FileNode &fn)
virtual void write(FileStorage &fs) const
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.
CV__DEBUG_NS_END typedef const _InputArray & InputArray
FileNode getFirstTopLevelNode() const
map< int, Ptr< FacemarkKazemi > > obj_
Object container.
virtual String getDefaultName() const
Global constant definitions.
virtual bool fit(InputArray image, InputArray faces, InputOutputArray landmarks)=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
unsigned long num_test_splits
virtual bool empty() const
string func
name of MATLAB function to evaluate (custom face detector)
LIBMWMEX_API_EXTERN_C int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *fcn_name)
call MATLAB function
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
virtual bool setFaceDetector(bool(*f)(InputArray, OutputArray, void *), void *userData)=0
virtual void loadModel(String filename)=0