37 int id = rhs[0].toInt();
38 string method(rhs[1].toString());
41 if (method ==
"new") {
53 if (method ==
"delete") {
58 else if (method ==
"typeid") {
60 plhs[0] =
MxArray(
string(
typeid(*obj).name()));
62 else if (method ==
"clear") {
66 else if (method ==
"load") {
67 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
69 bool loadFromString =
false;
70 for (
int i=3; i<nrhs; i+=2) {
71 string key(rhs[i].toString());
73 objname = rhs[i+1].toString();
74 else if (key ==
"FromString")
75 loadFromString = rhs[i+1].toBool();
78 "Unrecognized option %s", key.
c_str());
80 obj_[id] = (loadFromString ?
81 Algorithm::loadFromString<ORB>(rhs[2].toString(), objname) :
82 Algorithm::load<ORB>(rhs[2].toString(), objname));
84 else if (method ==
"save") {
86 obj->
save(rhs[2].toString());
88 else if (method ==
"empty") {
92 else if (method ==
"getDefaultName") {
96 else if (method ==
"defaultNorm") {
100 else if (method ==
"descriptorSize") {
104 else if (method ==
"descriptorType") {
108 else if (method ==
"detect") {
109 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
110 if (rhs[2].isNumeric()) {
112 for (
int i=3; i<nrhs; i+=2) {
113 string key(rhs[i].toString());
115 mask = rhs[i+1].toMat(
CV_8U);
118 "Unrecognized option %s", key.
c_str());
122 obj->
detect(image, keypoints, mask);
125 else if (rhs[2].isCell()) {
127 for (
int i=3; i<nrhs; i+=2) {
128 string key(rhs[i].toString());
139 "Unrecognized option %s", key.
c_str());
150 obj->
detect(images, keypoints, masks);
156 else if (method ==
"compute") {
158 if (rhs[2].isNumeric()) {
161 obj->
compute(image, keypoints, descriptors);
162 plhs[0] =
MxArray(descriptors);
166 else if (rhs[2].isCell()) {
177 &MxArray::toVector<KeyPoint>)));
178 obj->
compute(images, keypoints, descriptors);
179 plhs[0] =
MxArray(descriptors);
186 else if (method ==
"detectAndCompute") {
187 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=2);
190 bool useProvidedKeypoints =
false;
191 for (
int i=3; i<nrhs; i+=2) {
192 string key(rhs[i].toString());
194 mask = rhs[i+1].toMat(
CV_8U);
195 else if (key ==
"Keypoints") {
196 keypoints = rhs[i+1].toVector<
KeyPoint>();
197 useProvidedKeypoints =
true;
201 "Unrecognized option %s", key.
c_str());
205 useProvidedKeypoints);
208 plhs[1] =
MxArray(descriptors);
210 else if (method ==
"get") {
212 string prop(rhs[2].toString());
213 if (prop ==
"EdgeThreshold")
215 else if (prop ==
"FastThreshold")
217 else if (prop ==
"FirstLevel")
219 else if (prop ==
"MaxFeatures")
221 else if (prop ==
"NLevels")
223 else if (prop ==
"PatchSize")
225 else if (prop ==
"ScaleFactor")
227 else if (prop ==
"ScoreType")
229 else if (prop ==
"WTA_K")
233 "Unrecognized property %s", prop.
c_str());
235 else if (method ==
"set") {
237 string prop(rhs[2].toString());
238 if (prop ==
"EdgeThreshold")
240 else if (prop ==
"FastThreshold")
242 else if (prop ==
"FirstLevel")
244 else if (prop ==
"MaxFeatures")
246 else if (prop ==
"NLevels")
248 else if (prop ==
"PatchSize")
250 else if (prop ==
"ScaleFactor")
252 else if (prop ==
"ScoreType")
254 else if (prop ==
"WTA_K")
258 "Unrecognized property %s", prop.
c_str());
262 "Unrecognized operation %s",method.
c_str());
virtual void setPatchSize(int patchSize)=0
virtual int descriptorType() const
map< int, Ptr< ORB > > obj_
Object container.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
const ConstMap< int, std::string > ORBScoreTypeInv
inverse ORB score types
virtual void setFirstLevel(int firstLevel)=0
virtual void setFastThreshold(int fastThreshold)=0
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())
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void setMaxFeatures(int maxFeatures)=0
virtual void setNLevels(int nlevels)=0
virtual int getNLevels() const=0
virtual int getWTA_K() const=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual int defaultNorm() const
cv::Ptr< cv::ORB > createORB(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of ORB using options in arguments.
virtual void setWTA_K(int wta_k)=0
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...
virtual int getPatchSize() const=0
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 void setScoreType(int scoreType)=0
virtual int getEdgeThreshold() const=0
virtual void setScaleFactor(double scaleFactor)=0
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 int getMaxFeatures() const=0
Global constant definitions.
virtual double getScaleFactor() const=0
virtual int getScoreType() const=0
virtual void compute(InputArray image, std::vector< KeyPoint > &keypoints, OutputArray descriptors)
virtual void setEdgeThreshold(int edgeThreshold)=0
virtual int getFastThreshold() const=0
virtual bool empty() const
virtual int getFirstLevel() const=0
virtual void save(const String &filename) const
int last_id
Last object id to allocate.
virtual String getDefaultName() const
const ConstMap< std::string, int > ORBScoreType
ORB score types.