38 int id = rhs[0].toInt();
39 string method(rhs[1].toString());
42 if (method ==
"new") {
45 rhs[2].toString(), rhs.
begin() + 3, rhs.
end());
55 if (method ==
"delete") {
60 else if (method ==
"typeid") {
62 plhs[0] =
MxArray(
string(
typeid(*obj).name()));
64 else if (method ==
"clear") {
68 else if (method ==
"load") {
69 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
71 bool loadFromString =
false;
72 for (
int i=3; i<nrhs; i+=2) {
73 string key(rhs[i].toString());
75 objname = rhs[i+1].toString();
76 else if (key ==
"FromString")
77 loadFromString = rhs[i+1].toBool();
80 "Unrecognized option %s", key.
c_str());
89 FileStorage fs(rhs[2].toString(), FileStorage::READ +
90 (loadFromString ? FileStorage::MEMORY : 0));
99 else if (method ==
"save") {
101 obj->
save(rhs[2].toString());
103 else if (method ==
"empty") {
107 else if (method ==
"getDefaultName") {
111 else if (method ==
"isMaskSupported") {
115 else if (method ==
"getTrainDescriptors") {
119 else if (method ==
"add") {
129 obj->
add(descriptors);
131 else if (method ==
"train") {
135 else if (method ==
"match") {
139 if (nrhs>=4 && rhs[3].isNumeric()) {
143 for (
int i=4; i<nrhs; i+=2) {
144 string key(rhs[i].toString());
146 mask = rhs[i+1].toMat(
CV_8U);
149 "Unrecognized option %s", key.
c_str());
151 obj->
match(queryDescriptors, trainDescriptors, matches, mask);
156 for (
int i=3; i<nrhs; i+=2) {
157 string key(rhs[i].toString());
168 "Unrecognized option %s", key.
c_str());
170 obj->
match(queryDescriptors, matches, masks);
174 else if (method ==
"knnMatch") {
178 if (nrhs>=5 && rhs[3].isNumeric() && rhs[4].isNumeric()) {
181 int k = rhs[4].toInt();
183 bool compactResult =
false;
184 for (
int i=5; i<nrhs; i+=2) {
185 string key(rhs[i].toString());
187 mask = rhs[i+1].toMat(
CV_8U);
188 else if (key ==
"CompactResult")
189 compactResult = rhs[i+1].toBool();
192 "Unrecognized option %s", key.
c_str());
194 obj->
knnMatch(queryDescriptors, trainDescriptors, matches,
195 k, mask, compactResult);
199 int k = rhs[3].toInt();
201 bool compactResult =
false;
202 for (
int i=4; i<nrhs; i+=2) {
203 string key(rhs[i].toString());
212 else if (key ==
"CompactResult")
213 compactResult = rhs[i+1].toBool();
216 "Unrecognized option %s", key.
c_str());
218 obj->
knnMatch(queryDescriptors, matches, k, masks, compactResult);
222 else if (method ==
"radiusMatch") {
226 if (nrhs>=5 && rhs[3].isNumeric() && rhs[4].isNumeric()) {
229 float maxDistance = rhs[4].toFloat();
231 bool compactResult =
false;
232 for (
int i=5; i<nrhs; i+=2) {
233 string key(rhs[i].toString());
235 mask = rhs[i+1].toMat(
CV_8U);
236 else if (key ==
"CompactResult")
237 compactResult = rhs[i+1].toBool();
240 "Unrecognized option %s", key.
c_str());
242 obj->
radiusMatch(queryDescriptors, trainDescriptors, matches,
243 maxDistance, mask, compactResult);
247 float maxDistance = rhs[3].toFloat();
249 bool compactResult =
false;
250 for (
int i=4; i<nrhs; i+=2) {
251 string key(rhs[i].toString());
260 else if (key ==
"CompactResult")
261 compactResult = rhs[i+1].toBool();
264 "Unrecognized option %s", key.
c_str());
267 maxDistance, masks, compactResult);
273 "Unrecognized operation %s",method.
c_str());
map< int, Ptr< DescriptorMatcher > > obj_
Object container.
virtual bool empty() const
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual bool isMaskSupported() const=0
const std::vector< Mat > & getTrainDescriptors() const
void match(InputArray queryDescriptors, InputArray trainDescriptors, std::vector< DMatch > &matches, InputArray mask=noArray()) 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...
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.
Common definitions for the features2d and xfeatures2d modules.
cv::Ptr< cv::DescriptorMatcher > createDescriptorMatcher(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Factory function for DescriptorMatcher creation.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
void knnMatch(InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArray mask=noArray(), bool compactResult=false) const
virtual void add(InputArrayOfArrays descriptors)
virtual void save(const String &filename) const
void radiusMatch(InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArray mask=noArray(), bool compactResult=false) const
void read(const String &fileName)
int last_id
Last object id to allocate.