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<DAISY>(rhs[2].toString(), objname) :
83 Algorithm::load<DAISY>(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 ==
"compute") {
111 if (rhs[2].isNumeric()) {
115 obj->
compute(image, keypoints, descriptors);
116 plhs[0] =
MxArray(descriptors);
120 else if (rhs[2].isCell()) {
131 &MxArray::toVector<KeyPoint>)));
132 obj->
compute(images, keypoints, descriptors);
133 plhs[0] =
MxArray(descriptors);
140 else if (method ==
"compute_all") {
141 nargchk((nrhs==3 || nrhs==4) && nlhs<=1);
145 Rect roi(rhs[3].toRect());
146 obj->
compute(image, roi, descriptors);
149 obj->
compute(image, descriptors);
150 plhs[0] =
MxArray(descriptors);
152 else if (method ==
"GetDescriptor") {
153 nargchk(nrhs>=5 && (nrhs%2)==1 && nlhs<=2);
154 double y = rhs[2].toDouble(),
155 x = rhs[3].toDouble();
156 int orientation = rhs[4].toInt();
157 bool unnormalized =
false;
158 bool useHomography =
false;
160 for (
int i=5; i<nrhs; i+=2) {
161 string key(rhs[i].toString());
162 if (key ==
"Unnormalized")
163 unnormalized = rhs[i+1].toBool();
164 else if (key ==
"H") {
165 H = rhs[i+1].toMatx<double,3,3>();
166 useHomography =
true;
170 "Unrecognized option %s", key.
c_str());
177 &descriptor[0], H.
val);
185 &descriptor[0], H.
val);
197 "Unrecognized operation %s",method.
c_str());
virtual int descriptorType() const
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void GetDescriptor(double y, double x, int orientation, float *descriptor) const=0
virtual void compute(InputArray image, std::vector< KeyPoint > &keypoints, OutputArray descriptors)=0
const ConstMap< int, std::string > NormTypeInv
Inverse norm type map for option processing.
struct mxArray_tag mxArray
Forward declaration for mxArray.
cv::Ptr< cv::xfeatures2d::DAISY > createDAISY(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of DAISY using options in arguments.
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...
int last_id
Last object id to allocate.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
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
const ConstMap< int, std::string > ClassNameInvMap
Translates data type definition used in OpenCV to that of MATLAB.
Global constant definitions.
virtual bool empty() const
virtual void save(const String &filename) const
map< int, Ptr< DAISY > > obj_
Object container.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual void GetUnnormalizedDescriptor(double y, double x, int orientation, float *descriptor) const=0