36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
42 obj_[++
last_id] = BinaryDescriptorMatcher::createBinaryDescriptorMatcher();
52 if (method ==
"delete") {
57 else if (method ==
"clear") {
61 else if (method ==
"load") {
62 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
64 bool loadFromString =
false;
65 for (
int i=3; i<nrhs; i+=2) {
66 string key(rhs[i].toString());
68 objname = rhs[i+1].toString();
69 else if (key ==
"FromString")
70 loadFromString = rhs[i+1].toBool();
73 "Unrecognized option %s", key.
c_str());
82 FileStorage fs(rhs[2].toString(), FileStorage::READ +
83 (loadFromString ? FileStorage::MEMORY : 0));
92 else if (method ==
"save") {
94 obj->
save(rhs[2].toString());
96 else if (method ==
"empty") {
100 else if (method ==
"getDefaultName") {
104 else if (method ==
"add") {
113 obj->
add(descriptors);
115 else if (method ==
"train") {
119 else if (method ==
"match") {
123 if (nrhs>=4 && rhs[3].isNumeric()) {
127 for (
int i=4; i<nrhs; i+=2) {
128 string key(rhs[i].toString());
130 mask = rhs[i+1].toMat(
CV_8U);
133 "Unrecognized option %s", key.
c_str());
135 obj->
match(queryDescriptors, trainDescriptors, matches, mask);
140 for (
int i=3; i<nrhs; i+=2) {
141 string key(rhs[i].toString());
152 "Unrecognized option %s", key.
c_str());
154 obj->
match(queryDescriptors, matches, masks);
158 else if (method ==
"knnMatch") {
162 if (nrhs>=5 && rhs[3].isNumeric() && rhs[4].isNumeric()) {
165 int k = rhs[4].toInt();
167 bool compactResult =
false;
168 for (
int i=5; i<nrhs; i+=2) {
169 string key(rhs[i].toString());
171 mask = rhs[i+1].toMat(
CV_8U);
172 else if (key ==
"CompactResult")
173 compactResult = rhs[i+1].toBool();
176 "Unrecognized option %s", key.
c_str());
178 obj->
knnMatch(queryDescriptors, trainDescriptors, matches,
179 k, mask, compactResult);
183 int k = rhs[3].toInt();
185 bool compactResult =
false;
186 for (
int i=4; i<nrhs; i+=2) {
187 string key(rhs[i].toString());
196 else if (key ==
"CompactResult")
197 compactResult = rhs[i+1].toBool();
200 "Unrecognized option %s", key.
c_str());
202 obj->
knnMatch(queryDescriptors, matches, k, masks, compactResult);
206 else if (method ==
"radiusMatch") {
210 if (nrhs>=5 && rhs[3].isNumeric() && rhs[4].isNumeric()) {
213 float maxDistance = rhs[4].toFloat();
215 bool compactResult =
false;
216 for (
int i=5; i<nrhs; i+=2) {
217 string key(rhs[i].toString());
219 mask = rhs[i+1].toMat(
CV_8U);
220 else if (key ==
"CompactResult")
221 compactResult = rhs[i+1].toBool();
224 "Unrecognized option %s", key.
c_str());
226 obj->
radiusMatch(queryDescriptors, trainDescriptors, matches,
227 maxDistance, mask, compactResult);
231 float maxDistance = rhs[3].toFloat();
233 bool compactResult =
false;
234 for (
int i=4; i<nrhs; i+=2) {
235 string key(rhs[i].toString());
244 else if (key ==
"CompactResult")
245 compactResult = rhs[i+1].toBool();
248 "Unrecognized option %s", key.
c_str());
251 maxDistance, masks, compactResult);
257 "Unrecognized operation %s",method.
c_str());
int last_id
Last object id to allocate.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
void knnMatch(const Mat &queryDescriptors, const Mat &trainDescriptors, std::vector< std::vector< DMatch > > &matches, int k, const Mat &mask=Mat(), bool compactResult=false) const
virtual bool isOpened() const
void add(const std::vector< Mat > &descriptors)
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void read(const FileNode &fn)
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.
void radiusMatch(const Mat &queryDescriptors, const Mat &trainDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, const Mat &mask=Mat(), bool compactResult=false) const
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
map< int, Ptr< BinaryDescriptorMatcher > > obj_
Object container.
void match(const Mat &queryDescriptors, const Mat &trainDescriptors, std::vector< DMatch > &matches, const Mat &mask=Mat()) const
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual void save(const String &filename) const
virtual bool empty() const