38 int id = rhs[0].toInt();
39 string method(rhs[1].toString());
42 if (method ==
"new") {
54 if (method ==
"delete") {
59 else if (method ==
"typeid") {
61 plhs[0] =
MxArray(
string(
typeid(*obj).name()));
63 else if (method ==
"clear") {
67 else if (method ==
"load") {
68 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
70 bool loadFromString =
false;
71 for (
int i=3; i<nrhs; i+=2) {
72 string key(rhs[i].toString());
74 objname = rhs[i+1].toString();
75 else if (key ==
"FromString")
76 loadFromString = rhs[i+1].toBool();
79 "Unrecognized option %s", key.
c_str());
81 obj_[id] = (loadFromString ?
82 Algorithm::loadFromString<SURF>(rhs[2].toString(), objname) :
83 Algorithm::load<SURF>(rhs[2].toString(), objname));
85 else if (method ==
"save") {
87 obj->
save(rhs[2].toString());
89 else if (method ==
"empty") {
93 else if (method ==
"getDefaultName") {
97 else if (method ==
"defaultNorm") {
101 else if (method ==
"descriptorSize") {
105 else if (method ==
"descriptorType") {
109 else if (method ==
"detect") {
110 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
111 if (rhs[2].isNumeric()) {
113 for (
int i=3; i<nrhs; i+=2) {
114 string key(rhs[i].toString());
116 mask = rhs[i+1].toMat(
CV_8U);
119 "Unrecognized option %s", key.
c_str());
123 obj->
detect(image, keypoints, mask);
126 else if (rhs[2].isCell()) {
128 for (
int i=3; i<nrhs; i+=2) {
129 string key(rhs[i].toString());
140 "Unrecognized option %s", key.
c_str());
151 obj->
detect(images, keypoints, masks);
157 else if (method ==
"compute") {
159 if (rhs[2].isNumeric()) {
162 obj->
compute(image, keypoints, descriptors);
163 plhs[0] =
MxArray(descriptors);
167 else if (rhs[2].isCell()) {
178 &MxArray::toVector<KeyPoint>)));
179 obj->
compute(images, keypoints, descriptors);
180 plhs[0] =
MxArray(descriptors);
187 else if (method ==
"detectAndCompute") {
188 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=2);
191 bool useProvidedKeypoints =
false;
192 for (
int i=3; i<nrhs; i+=2) {
193 string key(rhs[i].toString());
195 mask = rhs[i+1].toMat(
CV_8U);
196 else if (key ==
"Keypoints") {
197 keypoints = rhs[i+1].toVector<
KeyPoint>();
198 useProvidedKeypoints =
true;
202 "Unrecognized option %s", key.
c_str());
206 useProvidedKeypoints);
209 plhs[1] =
MxArray(descriptors);
211 else if (method ==
"get") {
213 string prop(rhs[2].toString());
214 if (prop ==
"Extended")
216 else if (prop ==
"HessianThreshold")
218 else if (prop ==
"NOctaveLayers")
220 else if (prop ==
"NOctaves")
222 else if (prop ==
"Upright")
226 "Unrecognized property %s", prop.
c_str());
228 else if (method ==
"set") {
230 string prop(rhs[2].toString());
231 if (prop ==
"Extended")
233 else if (prop ==
"HessianThreshold")
235 else if (prop ==
"NOctaveLayers")
237 else if (prop ==
"NOctaves")
239 else if (prop ==
"Upright")
243 "Unrecognized property %s", prop.
c_str());
247 "Unrecognized operation %s",method.
c_str());
virtual void setHessianThreshold(double hessianThreshold)=0
virtual int descriptorType() const
virtual void setExtended(bool extended)=0
virtual bool getUpright() const=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
const ConstMap< int, std::string > NormTypeInv
Inverse norm type map for option processing.
virtual void detect(InputArray image, std::vector< KeyPoint > &keypoints, InputArray mask=noArray())
virtual bool getExtended() const=0
cv::Ptr< cv::xfeatures2d::SURF > createSURF(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of SURF using options in arguments.
virtual int getNOctaves() const=0
struct mxArray_tag mxArray
Forward declaration for mxArray.
int last_id
Last object id to allocate.
virtual double getHessianThreshold() const=0
virtual void setNOctaveLayers(int nOctaveLayers)=0
virtual int defaultNorm() 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...
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
map< int, Ptr< SURF > > obj_
Object container.
virtual int descriptorSize() const
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
Common definitions for the features2d and xfeatures2d modules.
virtual String getDefaultName() const
virtual void detectAndCompute(InputArray image, InputArray mask, std::vector< KeyPoint > &keypoints, OutputArray descriptors, bool useProvidedKeypoints=false)
const ConstMap< int, std::string > ClassNameInvMap
Translates data type definition used in OpenCV to that of MATLAB.
virtual void setNOctaves(int nOctaves)=0
Global constant definitions.
virtual void compute(InputArray image, std::vector< KeyPoint > &keypoints, OutputArray descriptors)
virtual bool empty() const
virtual void save(const String &filename) const
virtual int getNOctaveLayers() const=0
virtual void setUpright(bool upright)=0