82 s.
set(
"fun", fun_name);
92 return makePtr<MatlabMaskGenerator>(
func);
114 int id = rhs[0].toInt();
115 string method(rhs[1].toString());
118 if (method ==
"new") {
125 else if (method ==
"convert") {
127 string oldcascade(rhs[2].toString()),
128 newcascade(rhs[3].toString());
129 bool success = CascadeClassifier::convert(oldcascade, newcascade);
141 if (method ==
"delete") {
146 else if (method ==
"empty") {
150 else if (method ==
"load") {
152 string filename(rhs[2].toString());
153 bool success = obj->
load(filename);
158 "Invalid path or file specified");
160 else if (method ==
"isOldFormatCascade") {
164 else if (method ==
"getFeatureType") {
168 else if (method ==
"getOriginalWindowSize") {
172 else if (method ==
"getMaskGenerator") {
178 plhs[0] = pp->toStruct();
184 else if (method ==
"setMaskGenerator") {
186 string str(rhs[2].toString());
188 if (str ==
"FaceDetectionMaskGenerator")
194 else if (method ==
"detectMultiScale") {
195 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=3);
196 double scaleFactor = 1.1;
197 int minNeighbors = 3;
199 Size minSize, maxSize;
200 bool outputRejectLevels =
false;
201 for (
int i=3; i<rhs.
size(); i+=2) {
202 string key(rhs[i].toString());
203 if (key ==
"ScaleFactor")
204 scaleFactor = rhs[i+1].toDouble();
205 else if (key ==
"MinNeighbors")
206 minNeighbors = rhs[i+1].toInt();
207 else if (key ==
"DoCannyPruning")
209 else if (key ==
"ScaleImage")
211 else if (key ==
"FindBiggestObject")
213 else if (key ==
"DoRoughSearch")
215 else if (key ==
"Flags")
216 flags = rhs[i+1].toInt();
217 else if (key ==
"MinSize")
218 minSize = rhs[i+1].toSize();
219 else if (key ==
"MaxSize")
220 maxSize = rhs[i+1].toSize();
221 else if (key ==
"OutputRejectLevels")
222 outputRejectLevels = rhs[i+1].toBool();
225 "Unrecognized option %s", key.
c_str());
230 if (nlhs > 2 || outputRejectLevels) {
231 outputRejectLevels =
true;
235 scaleFactor, minNeighbors, flags, minSize, maxSize,
238 plhs[1] =
MxArray(rejectLevels);
240 plhs[2] =
MxArray(levelWeights);
245 scaleFactor, minNeighbors, flags, minSize, maxSize);
246 plhs[1] =
MxArray(numDetections);
250 scaleFactor, minNeighbors, flags, minSize, maxSize);
255 "Unrecognized operation %s", method.
c_str());
void detectMultiScale(InputArray image, std::vector< Rect > &objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size())
Size getOriginalWindowSize() const
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
void initializeMask(const Mat &)
Initialization method (unused)
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
Ptr< BaseCascadeClassifier::MaskGenerator > getMaskGenerator()
MatlabMaskGenerator(const string &func)
Constructor.
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxDestroyArray(mxArray *pa)
mxArray destructor
int getFeatureType() const
bool load(const String &filename)
map< int, Ptr< CascadeClassifier > > obj_
Object container.
struct mxArray_tag mxArray
Forward declaration for mxArray.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
int last_id
Last object id to allocate.
string func
name of MATLAB function to evaluate (custom face detector)
Represents a custom mask generator implemented as a MATLAB function.
MxArray toStruct() const
Convert object to MxArray.
bool isNumeric() const
Determine whether array is numeric.
Ptr< Y > dynamicCast() const
#define UPDATE_FLAG(NUM, TF, BIT)
set or clear a bit in flag depending on bool value
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.
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
static Ptr< MatlabMaskGenerator > create(const string &func)
Factory function.
void setMaskGenerator(const Ptr< BaseCascadeClassifier::MaskGenerator > &maskGenerator)
Global constant definitions.
const ConstMap< int, string > FeatureTypeMap
feature types for option processing
Ptr< BaseCascadeClassifier::MaskGenerator > createFaceDetectionMaskGenerator()
cv::Mat toMat(int depth=CV_USRTYPE1, bool transpose=true) const
Convert MxArray to cv::Mat.
Mat generateMask(const Mat &src)
Evaluates MATLAB generator function.
bool isOldFormatCascade() const
CASCADE_FIND_BIGGEST_OBJECT
static Scalar_< double > all(double v0)
std::map wrapper with one-line initialization and lookup method.
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)