44 const int gnrmRad,
const int gsmthRad,
const int shrink,
45 const int outNum,
const int gradNum)
const 49 opts.
set(
"normRad", gnrmRad);
50 opts.
set(
"grdSmooth", gsmthRad);
51 opts.
set(
"shrink", shrink);
52 opts.
set(
"nChns", outNum);
53 opts.
set(
"nOrients", gradNum);
77 gnrmRad, gsmthRad, shrink, outNum, gradNum);
93 return makePtr<MatlabRFFeatureGetter>(
func);
115 int id = rhs[0].toInt();
116 string method(rhs[1].toString());
119 if (method ==
"new") {
120 nargchk((nrhs==3||nrhs==4) && nlhs<=1);
121 string model(rhs[2].toString());
129 model, howToGetFeatures);
135 else if (method ==
"getFeatures") {
139 int gnrmRad = rhs[3].
at(
"normRad").
toInt(),
140 gsmthRad = rhs[3].
at(
"grdSmooth").
toInt(),
141 shrink = rhs[3].
at(
"shrink").
toInt(),
142 outNum = rhs[3].
at(
"nChns").
toInt(),
143 gradNum = rhs[3].
at(
"nOrients").
toInt();
145 gnrmRad, gsmthRad, shrink, outNum, gradNum);
154 if (method ==
"delete") {
159 else if (method ==
"clear") {
163 else if (method ==
"load") {
164 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
166 bool loadFromString =
false;
167 for (
int i=3; i<nrhs; i+=2) {
168 string key(rhs[i].toString());
169 if (key ==
"ObjName")
170 objname = rhs[i+1].toString();
171 else if (key ==
"FromString")
172 loadFromString = rhs[i+1].toBool();
175 "Unrecognized option %s", key.
c_str());
184 FileStorage fs(rhs[2].toString(), FileStorage::READ +
185 (loadFromString ? FileStorage::MEMORY : 0));
194 else if (method ==
"save") {
196 obj->
save(rhs[2].toString());
198 else if (method ==
"empty") {
202 else if (method ==
"getDefaultName") {
206 else if (method ==
"detectEdges") {
212 else if (method ==
"computeOrientation") {
218 else if (method ==
"edgesNms") {
219 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
223 bool isParallel =
true;
224 for (
int i=4; i<nrhs; i+=2) {
225 string key(rhs[i].toString());
227 r = rhs[i+1].toInt();
229 s = rhs[i+1].toInt();
231 m = rhs[i+1].toFloat();
232 else if (key ==
"IsParallel")
233 isParallel = rhs[i+1].toBool();
236 "Unrecognized option %s", key.
c_str());
241 obj->
edgesNms(edge_image, orientation_image, dst, r, s, m, isParallel);
246 "Unrecognized operation %s", method.
c_str());
int last_id
Last object id to allocate.
mwSize ndims() const
Number of dimensions.
map< int, Ptr< StructuredEdgeDetection > > obj_
Object container.
int toInt() const
Convert MxArray to int.
virtual void edgesNms(cv::InputArray edge_image, cv::InputArray orientation_image, cv::OutputArray _dst, int r=2, int s=0, float m=1, bool isParallel=true) const=0
virtual void computeOrientation(cv::InputArray _src, cv::OutputArray _dst) const=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxDestroyArray(mxArray *pa)
mxArray destructor
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
MatlabRFFeatureGetter(const string &func)
Constructor.
Ptr< StructuredEdgeDetection > createStructuredEdgeDetection(const String &model, Ptr< const RFFeatureGetter > howToGetFeatures=Ptr< RFFeatureGetter >())
string func
name of MATLAB function to evaluate (custom face detector)
virtual void read(const FileNode &fn)
bool isNumeric() const
Determine whether array is numeric.
bool isComplex() const
Determine whether data is complex.
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.
FileNode getFirstTopLevelNode() const
static Ptr< MatlabRFFeatureGetter > create(const string &func)
Factory function.
virtual String getDefaultName() const
Global constant definitions.
virtual void detectEdges(cv::InputArray _src, cv::OutputArray _dst) const=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
cv::Mat toMat(int depth=CV_USRTYPE1, bool transpose=true) const
Convert MxArray to cv::Mat.
Custom feature extractor class implemented as a MATLAB function.
Ptr< RFFeatureGetter > createRFFeatureGetter()
virtual void save(const String &filename) const
virtual bool empty() const
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 void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad, const int shrink, const int outNum, const int gradNum) const
Extracts feature channels from source image.