12 #ifdef HAVE_OPENCV_XFEATURES2D 22 vector<MxArray>::const_iterator first,
23 vector<MxArray>::const_iterator last)
25 if (((last-first) % 2) != 0)
26 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
28 if ((last-first) >= 2 && !first->isChar()) {
29 vector<float> radiusList(first->toVector<
float>()); ++first;
30 vector<int> numberList(first->toVector<
int>()); ++first;
31 float dMax = 5.85f, dMin = 8.2f;
32 vector<int> indexChange;
33 for (; first != last; first += 2) {
34 string key((*first).toString());
35 const MxArray& val = *(first + 1);
38 else if (key ==
"DMin")
40 else if (key ==
"IndexChange")
41 indexChange = val.toVector<
int>();
43 mexErrMsgIdAndTxt(
"mexopencv:error",
44 "Unrecognized option %s", key.c_str());
46 return BRISK::create(radiusList, numberList, dMax, dMin, indexChange);
52 float patternScale = 1.0f;
53 for (; first != last; first += 2) {
54 string key((*first).toString());
55 const MxArray& val = *(first + 1);
56 if (key ==
"Threshold")
58 else if (key ==
"Octaves")
59 octaves = val.toInt();
60 else if (key ==
"PatternScale")
61 patternScale = val.toFloat();
63 mexErrMsgIdAndTxt(
"mexopencv:error",
64 "Unrecognized option %s", key.c_str());
66 return BRISK::create(thresh, octaves, patternScale);
71 vector<MxArray>::const_iterator first,
72 vector<MxArray>::const_iterator last)
74 if (((last-first) % 2) != 0)
75 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
77 float scaleFactor = 1.2f;
79 int edgeThreshold = 31;
82 int scoreType = ORB::HARRIS_SCORE;
84 int fastThreshold = 20;
85 for (; first != last; first += 2) {
86 string key((*first).toString());
87 const MxArray& val = *(first + 1);
88 if (key ==
"MaxFeatures")
89 nfeatures = val.
toInt();
90 else if (key ==
"ScaleFactor")
91 scaleFactor = val.toFloat();
92 else if (key ==
"NLevels")
93 nlevels = val.toInt();
94 else if (key ==
"EdgeThreshold")
95 edgeThreshold = val.toInt();
96 else if (key ==
"FirstLevel")
97 firstLevel = val.toInt();
98 else if (key ==
"WTA_K")
100 else if (key ==
"ScoreType")
102 else if (key ==
"PatchSize")
103 patchSize = val.toInt();
104 else if (key ==
"FastThreshold")
105 fastThreshold = val.toInt();
107 mexErrMsgIdAndTxt(
"mexopencv:error",
108 "Unrecognized option %s", key.c_str());
110 return ORB::create(nfeatures, scaleFactor, nlevels, edgeThreshold,
111 firstLevel, WTA_K, scoreType, patchSize, fastThreshold);
115 vector<MxArray>::const_iterator first,
116 vector<MxArray>::const_iterator last)
118 if (((last-first) % 2) != 0)
119 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
122 int max_area = 14400;
123 double max_variation = 0.25;
124 double min_diversity = 0.2;
125 int max_evolution = 200;
126 double area_threshold = 1.01;
127 double min_margin = 0.003;
128 int edge_blur_size = 5;
129 for (; first != last; first += 2) {
130 string key((*first).toString());
131 const MxArray& val = *(first + 1);
134 else if (key ==
"MinArea")
135 min_area = val.toInt();
136 else if (key ==
"MaxArea")
137 max_area = val.toInt();
138 else if (key ==
"MaxVariation")
139 max_variation = val.toDouble();
140 else if (key ==
"MinDiversity")
141 min_diversity = val.toDouble();
142 else if (key ==
"MaxEvolution")
143 max_evolution = val.toInt();
144 else if (key ==
"AreaThreshold")
145 area_threshold = val.toDouble();
146 else if (key ==
"MinMargin")
147 min_margin = val.toDouble();
148 else if (key ==
"EdgeBlurSize")
149 edge_blur_size = val.toInt();
151 mexErrMsgIdAndTxt(
"mexopencv:error",
152 "Unrecognized option %s", key.c_str());
154 return MSER::create(delta, min_area, max_area, max_variation,
155 min_diversity, max_evolution, area_threshold, min_margin,
160 vector<MxArray>::const_iterator first,
161 vector<MxArray>::const_iterator last)
163 if (((last-first) % 2) != 0)
164 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
166 bool nonmaxSuppression =
true;
167 int type = FastFeatureDetector::TYPE_9_16;
168 for (; first != last; first += 2) {
169 string key((*first).toString());
170 const MxArray& val = *(first + 1);
171 if (key ==
"Threshold")
172 threshold = val.
toInt();
173 else if (key ==
"NonmaxSuppression")
174 nonmaxSuppression = val.toBool();
175 else if (key ==
"Type")
178 mexErrMsgIdAndTxt(
"mexopencv:error",
179 "Unrecognized option %s", key.c_str());
181 return FastFeatureDetector::create(threshold, nonmaxSuppression, type);
185 vector<MxArray>::const_iterator first,
186 vector<MxArray>::const_iterator last)
188 if (((last-first) % 2) != 0)
189 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
190 int maxCorners = 1000;
191 double qualityLevel = 0.01;
192 double minDistance = 1;
194 bool useHarrisDetector =
false;
196 for (; first != last; first += 2) {
197 string key((*first).toString());
198 const MxArray& val = *(first + 1);
199 if (key ==
"MaxFeatures")
200 maxCorners = val.
toInt();
201 else if (key ==
"QualityLevel")
202 qualityLevel = val.toDouble();
203 else if (key ==
"MinDistance")
204 minDistance = val.toDouble();
205 else if (key ==
"BlockSize")
206 blockSize = val.toInt();
207 else if (key ==
"HarrisDetector")
208 useHarrisDetector = val.toBool();
212 mexErrMsgIdAndTxt(
"mexopencv:error",
213 "Unrecognized option %s", key.c_str());
215 return GFTTDetector::create(maxCorners, qualityLevel, minDistance,
216 blockSize, useHarrisDetector, k);
220 vector<MxArray>::const_iterator first,
221 vector<MxArray>::const_iterator last)
223 if (((last-first) % 2) != 0)
224 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
225 SimpleBlobDetector::Params parameters;
226 for (; first != last; first += 2) {
227 string key((*first).toString());
228 const MxArray& val = *(first + 1);
229 if (key ==
"ThresholdStep")
230 parameters.thresholdStep = val.
toFloat();
231 else if (key ==
"MinThreshold")
232 parameters.minThreshold = val.toFloat();
233 else if (key ==
"MaxThreshold")
234 parameters.maxThreshold = val.toFloat();
235 else if (key ==
"MinRepeatability")
236 parameters.minRepeatability = val.toInt();
237 else if (key ==
"MinDistBetweenBlobs")
238 parameters.minDistBetweenBlobs = val.toFloat();
239 else if (key ==
"FilterByColor")
240 parameters.filterByColor = val.toBool();
241 else if (key ==
"BlobColor")
242 parameters.blobColor =
static_cast<uchar
>(val.toInt());
243 else if (key ==
"FilterByArea")
244 parameters.filterByArea = val.toBool();
245 else if (key ==
"MinArea")
246 parameters.minArea = val.toFloat();
247 else if (key ==
"MaxArea")
248 parameters.maxArea = val.toFloat();
249 else if (key ==
"FilterByCircularity")
250 parameters.filterByCircularity = val.toBool();
251 else if (key ==
"MinCircularity")
252 parameters.minCircularity = val.toFloat();
253 else if (key ==
"MaxCircularity")
254 parameters.maxCircularity = val.toFloat();
255 else if (key ==
"FilterByInertia")
256 parameters.filterByInertia = val.toBool();
257 else if (key ==
"MinInertiaRatio")
258 parameters.minInertiaRatio = val.toFloat();
259 else if (key ==
"MaxInertiaRatio")
260 parameters.maxInertiaRatio = val.toFloat();
261 else if (key ==
"FilterByConvexity")
262 parameters.filterByConvexity = val.toBool();
263 else if (key ==
"MinConvexity")
264 parameters.minConvexity = val.toFloat();
265 else if (key ==
"MaxConvexity")
266 parameters.maxConvexity = val.toFloat();
268 mexErrMsgIdAndTxt(
"mexopencv:error",
269 "Unrecognized option %s", key.c_str());
271 return SimpleBlobDetector::create(parameters);
275 vector<MxArray>::const_iterator first,
276 vector<MxArray>::const_iterator last)
278 if (((last-first) % 2) != 0)
279 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
280 bool extended =
false;
281 bool upright =
false;
282 float threshold = 0.001f;
284 int nOctaveLayers = 4;
285 int diffusivity = KAZE::DIFF_PM_G2;
286 for (; first != last; first += 2) {
287 string key((*first).toString());
288 const MxArray& val = *(first + 1);
289 if (key ==
"Extended")
291 else if (key ==
"Upright")
292 upright = val.toBool();
293 else if (key ==
"Threshold")
294 threshold = val.toFloat();
295 else if (key ==
"NOctaves")
296 nOctaves = val.toInt();
297 else if (key ==
"NOctaveLayers")
298 nOctaveLayers = val.toInt();
299 else if(key ==
"Diffusivity")
302 mexErrMsgIdAndTxt(
"mexopencv:error",
303 "Unrecognized option %s", key.c_str());
305 return KAZE::create(extended, upright, threshold,
306 nOctaves, nOctaveLayers, diffusivity);
310 vector<MxArray>::const_iterator first,
311 vector<MxArray>::const_iterator last)
313 if (((last-first) % 2) != 0)
314 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
315 int descriptor_type = AKAZE::DESCRIPTOR_MLDB;
316 int descriptor_size = 0;
317 int descriptor_channels = 3;
318 float threshold = 0.001f;
320 int nOctaveLayers = 4;
321 int diffusivity = KAZE::DIFF_PM_G2;
322 for (; first != last; first += 2) {
323 string key((*first).toString());
324 const MxArray& val = *(first + 1);
325 if (key ==
"DescriptorType")
327 else if (key ==
"DescriptorSize")
328 descriptor_size = val.toInt();
329 else if (key ==
"DescriptorChannels")
330 descriptor_channels = val.toInt();
331 else if (key ==
"Threshold")
332 threshold = val.toFloat();
333 else if (key ==
"NOctaves")
334 nOctaves = val.toInt();
335 else if (key ==
"NOctaveLayers")
336 nOctaveLayers = val.toInt();
337 else if (key ==
"Diffusivity")
340 mexErrMsgIdAndTxt(
"mexopencv:error",
341 "Unrecognized option %s", key.c_str());
343 return AKAZE::create(descriptor_type, descriptor_size, descriptor_channels,
344 threshold, nOctaves, nOctaveLayers, diffusivity);
348 vector<MxArray>::const_iterator first,
349 vector<MxArray>::const_iterator last)
351 if (((last-first) % 2) != 0)
352 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
354 bool nonmaxSuppression =
true;
355 int type = AgastFeatureDetector::OAST_9_16;
356 for (; first != last; first += 2) {
357 string key((*first).toString());
358 const MxArray& val = *(first + 1);
359 if (key ==
"Threshold")
360 threshold = val.
toInt();
361 else if (key ==
"NonmaxSuppression")
362 nonmaxSuppression = val.toBool();
363 else if (key ==
"Type")
366 mexErrMsgIdAndTxt(
"mexopencv:error",
367 "Unrecognized option %s", key.c_str());
369 return AgastFeatureDetector::create(threshold, nonmaxSuppression, type);
372 #ifdef HAVE_OPENCV_XFEATURES2D 373 Ptr<SIFT> createSIFT(
374 vector<MxArray>::const_iterator first,
375 vector<MxArray>::const_iterator last)
377 if (((last-first) % 2) != 0)
378 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
380 int nOctaveLayers = 3;
381 double contrastThreshold = 0.04;
382 double edgeThreshold = 10;
384 for (; first != last; first += 2) {
385 string key((*first).toString());
386 const MxArray& val = *(first + 1);
387 if (key ==
"NFeatures")
388 nfeatures = val.
toInt();
389 else if (key ==
"NOctaveLayers")
390 nOctaveLayers = val.toInt();
391 else if (key ==
"ConstrastThreshold")
392 contrastThreshold = val.toDouble();
393 else if (key ==
"EdgeThreshold")
394 edgeThreshold = val.toDouble();
395 else if (key ==
"Sigma")
396 sigma = val.toDouble();
398 mexErrMsgIdAndTxt(
"mexopencv:error",
399 "Unrecognized option %s", key.c_str());
401 return SIFT::create(nfeatures, nOctaveLayers, contrastThreshold,
402 edgeThreshold, sigma);
405 Ptr<SURF> createSURF(
406 vector<MxArray>::const_iterator first,
407 vector<MxArray>::const_iterator last)
409 if (((last-first) % 2) != 0)
410 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
411 double hessianThreshold = 100;
413 int nOctaveLayers = 3;
414 bool extended =
false;
415 bool upright =
false;
416 for (; first != last; first += 2) {
417 string key((*first).toString());
418 const MxArray& val = *(first + 1);
419 if (key ==
"HessianThreshold")
421 else if (key ==
"NOctaves")
422 nOctaves = val.toInt();
423 else if (key ==
"NOctaveLayers")
424 nOctaveLayers = val.toInt();
425 else if (key ==
"Extended")
426 extended = val.toBool();
427 else if (key ==
"Upright")
428 upright = val.toBool();
430 mexErrMsgIdAndTxt(
"mexopencv:error",
431 "Unrecognized option %s", key.c_str());
433 return SURF::create(hessianThreshold, nOctaves, nOctaveLayers,
437 Ptr<FREAK> createFREAK(
438 vector<MxArray>::const_iterator first,
439 vector<MxArray>::const_iterator last)
441 if (((last-first) % 2) != 0)
442 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
443 bool orientationNormalized =
true;
444 bool scaleNormalized =
true;
445 float patternScale = 22.0f;
447 vector<int> selectedPairs;
448 for (; first != last; first += 2) {
449 string key((*first).toString());
450 const MxArray& val = *(first + 1);
451 if (key ==
"OrientationNormalized")
452 orientationNormalized = val.
toBool();
453 else if (key ==
"ScaleNormalized")
454 scaleNormalized = val.toBool();
455 else if (key ==
"PatternScale")
456 patternScale = val.toFloat();
457 else if (key ==
"NOctaves")
458 nOctaves = val.toInt();
459 else if (key ==
"SelectedPairs")
460 selectedPairs = val.toVector<
int>();
462 mexErrMsgIdAndTxt(
"mexopencv:error",
463 "Unrecognized option %s", key.c_str());
465 return FREAK::create(orientationNormalized, scaleNormalized, patternScale,
466 nOctaves, selectedPairs);
469 Ptr<StarDetector> createStarDetector(
470 vector<MxArray>::const_iterator first,
471 vector<MxArray>::const_iterator last)
473 if (((last-first) % 2) != 0)
474 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
476 int responseThreshold = 30;
477 int lineThresholdProjected = 10;
478 int lineThresholdBinarized = 8;
479 int suppressNonmaxSize = 5;
480 for (; first != last; first += 2) {
481 string key((*first).toString());
482 const MxArray& val = *(first + 1);
483 if (key ==
"MaxSize")
484 maxSize = val.
toInt();
485 else if (key ==
"ResponseThreshold")
486 responseThreshold = val.toInt();
487 else if (key ==
"LineThresholdProjected")
488 lineThresholdProjected = val.toInt();
489 else if (key ==
"LineThresholdBinarized")
490 lineThresholdBinarized = val.toInt();
491 else if (key ==
"SuppressNonmaxSize")
492 suppressNonmaxSize = val.toInt();
494 mexErrMsgIdAndTxt(
"mexopencv:error",
495 "Unrecognized option %s", key.c_str());
497 return StarDetector::create(maxSize, responseThreshold,
498 lineThresholdProjected, lineThresholdBinarized, suppressNonmaxSize);
501 Ptr<BriefDescriptorExtractor> createBriefDescriptorExtractor(
502 vector<MxArray>::const_iterator first,
503 vector<MxArray>::const_iterator last)
505 if (((last-first) % 2) != 0)
506 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
508 bool use_orientation =
false;
509 for (; first != last; first += 2) {
510 string key((*first).toString());
511 const MxArray& val = *(first + 1);
514 else if (key ==
"UseOrientation")
515 use_orientation = val.toBool();
517 mexErrMsgIdAndTxt(
"mexopencv:error",
518 "Unrecognized option %s", key.c_str());
520 return BriefDescriptorExtractor::create(bytes, use_orientation);
523 Ptr<LUCID> createLUCID(
524 vector<MxArray>::const_iterator first,
525 vector<MxArray>::const_iterator last)
527 if (((last-first) % 2) != 0)
528 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
529 int lucid_kernel = 1;
531 for (; first != last; first += 2) {
532 string key((*first).toString());
533 const MxArray& val = *(first + 1);
534 if (key ==
"LucidKernel")
535 lucid_kernel = val.
toInt();
536 else if (key ==
"BlurKernel")
537 blur_kernel = val.toInt();
539 mexErrMsgIdAndTxt(
"mexopencv:error",
540 "Unrecognized option %s", key.c_str());
542 return LUCID::create(lucid_kernel, blur_kernel);
545 Ptr<LATCH> createLATCH(
546 vector<MxArray>::const_iterator first,
547 vector<MxArray>::const_iterator last)
549 if (((last-first) % 2) != 0)
550 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
552 bool rotationInvariance =
true;
553 int half_ssd_size = 3;
554 for (; first != last; first += 2) {
555 string key(first->toString());
556 const MxArray& val = *(first + 1);
559 else if (key ==
"RotationInvariance")
560 rotationInvariance = val.toBool();
561 else if (key ==
"HalfSize")
562 half_ssd_size = val.toInt();
564 mexErrMsgIdAndTxt(
"mexopencv:error",
565 "Unrecognized option %s", key.c_str());
567 return LATCH::create(bytes, rotationInvariance, half_ssd_size);
570 Ptr<DAISY> createDAISY(
571 vector<MxArray>::const_iterator first,
572 vector<MxArray>::const_iterator last)
574 if (((last-first) % 2) != 0)
575 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
580 int norm = DAISY::NRM_NONE;
582 bool interpolation =
true;
583 bool use_orientation =
false;
584 for (; first != last; first += 2) {
585 string key(first->toString());
586 const MxArray& val = *(first + 1);
589 else if (key ==
"RadiusQuant")
590 q_radius = val.toInt();
591 else if (key ==
"AngleQuant")
592 q_theta = val.toInt();
593 else if (key ==
"GradOrientationsQuant")
594 q_hist = val.toInt();
595 else if (key ==
"Normalization")
596 norm = DAISYNormType[val.toString()];
599 else if (key ==
"Interpolation")
600 interpolation = val.toBool();
601 else if (key ==
"UseOrientation")
602 use_orientation = val.toBool();
604 mexErrMsgIdAndTxt(
"mexopencv:error",
605 "Unrecognized option %s", key.c_str());
607 return DAISY::create(radius, q_radius, q_theta, q_hist,
608 norm, H, interpolation, use_orientation);
611 Ptr<MSDDetector> createMSDDetector(
612 vector<MxArray>::const_iterator first,
613 vector<MxArray>::const_iterator last)
615 if (((last-first) % 2) != 0)
616 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
617 int patch_radius = 3;
618 int search_area_radius = 5;
620 int nms_scale_radius = 0;
621 float th_saliency = 250.0f;
623 float scale_factor = 1.25f;
625 bool compute_orientation =
false;
626 for (; first != last; first += 2) {
627 string key((*first).toString());
628 const MxArray& val = *(first + 1);
629 if (key ==
"PatchRadius")
630 patch_radius = val.
toInt();
631 else if (key ==
"SearchAreaRadius")
632 search_area_radius = val.toInt();
633 else if (key ==
"NMSRadius")
634 nms_radius = val.toInt();
635 else if (key ==
"NMSScaleRadius")
636 nms_scale_radius = val.toInt();
637 else if (key ==
"ThSaliency")
638 th_saliency = val.toFloat();
639 else if (key ==
"KNN")
641 else if (key ==
"ScaleFactor")
642 scale_factor = val.toFloat();
643 else if (key ==
"NScales")
644 n_scales = val.toInt();
645 else if (key ==
"ComputeOrientation")
646 compute_orientation = val.toBool();
648 mexErrMsgIdAndTxt(
"mexopencv:error",
649 "Unrecognized option %s", key.c_str());
651 return MSDDetector::create(patch_radius, search_area_radius, nms_radius,
652 nms_scale_radius, th_saliency, kNN, scale_factor, n_scales,
653 compute_orientation);
659 vector<MxArray>::const_iterator first,
660 vector<MxArray>::const_iterator last)
662 Ptr<FeatureDetector> p;
665 else if (type ==
"ORB")
667 else if (type ==
"MSER")
669 else if (type ==
"FastFeatureDetector")
671 else if (type ==
"GFTTDetector")
673 else if (type ==
"SimpleBlobDetector")
675 else if (type ==
"KAZE")
677 else if (type ==
"AKAZE")
679 else if (type ==
"AgastFeatureDetector")
681 #ifdef HAVE_OPENCV_XFEATURES2D 682 else if (type ==
"SIFT")
683 p = createSIFT(first, last);
684 else if (type ==
"SURF")
685 p = createSURF(first, last);
686 else if (type ==
"StarDetector")
687 p = createStarDetector(first, last);
688 else if (type ==
"MSDDetector")
689 p = createMSDDetector(first, last);
692 mexErrMsgIdAndTxt(
"mexopencv:error",
693 "Unrecognized detector %s", type.c_str());
695 mexErrMsgIdAndTxt(
"mexopencv:error",
696 "Failed to create FeatureDetector of type %s", type.c_str());
702 vector<MxArray>::const_iterator first,
703 vector<MxArray>::const_iterator last)
705 Ptr<DescriptorExtractor> p;
708 else if (type ==
"ORB")
710 else if (type ==
"KAZE")
712 else if (type ==
"AKAZE")
714 #ifdef HAVE_OPENCV_XFEATURES2D 715 else if (type ==
"SIFT")
716 p = createSIFT(first, last);
717 else if (type ==
"SURF")
718 p = createSURF(first, last);
719 else if (type ==
"FREAK")
720 p = createFREAK(first, last);
721 else if (type ==
"BriefDescriptorExtractor")
722 p = createBriefDescriptorExtractor(first, last);
723 else if (type ==
"LUCID")
724 p = createLUCID(first, last);
725 else if (type ==
"LATCH")
726 p = createLATCH(first, last);
727 else if (type ==
"DAISY")
728 p = createDAISY(first, last);
731 mexErrMsgIdAndTxt(
"mexopencv:error",
732 "Unrecognized extractor %s", type.c_str());
734 mexErrMsgIdAndTxt(
"mexopencv:error",
735 "Failed to create DescriptorExtractor of type %s", type.c_str());
747 (
"Random", cvflann::FLANN_CENTERS_RANDOM)
748 (
"Gonzales", cvflann::FLANN_CENTERS_GONZALES)
749 (
"KMeansPP", cvflann::FLANN_CENTERS_KMEANSPP)
750 (
"Groupwise", cvflann::FLANN_CENTERS_GROUPWISE);
759 Ptr<flann::IndexParams> p;
762 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
763 string type(rhs[0].toString());
764 if (type ==
"Linear") {
766 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
767 p = makePtr<flann::LinearIndexParams>();
769 else if (type ==
"KDTree") {
770 if ((rhs.size() % 2) == 0)
771 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
773 for (
size_t i = 1; i<rhs.size(); i += 2) {
774 string key(rhs[i].toString());
776 trees = rhs[i+1].toInt();
778 mexErrMsgIdAndTxt(
"mexopencv:error",
779 "Unrecognized option %s", key.c_str());
781 p = makePtr<flann::KDTreeIndexParams>(trees);
783 else if (type ==
"KMeans") {
784 if ((rhs.size() % 2) == 0)
785 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
788 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM;
789 float cb_index = 0.2f;
790 for (
size_t i = 1; i<rhs.size(); i += 2) {
791 string key(rhs[i].toString());
792 if (key ==
"Branching")
793 branching = rhs[i+1].toInt();
794 else if (key ==
"Iterations")
795 iterations = rhs[i+1].toInt();
796 else if (key ==
"CentersInit")
797 centers_init = CentersInit[rhs[i+1].toString()];
798 else if (key ==
"CBIndex")
799 cb_index = rhs[i+1].toFloat();
801 mexErrMsgIdAndTxt(
"mexopencv:error",
802 "Unrecognized option %s", key.c_str());
804 p = makePtr<flann::KMeansIndexParams>(
805 branching, iterations, centers_init, cb_index);
807 else if (type ==
"Composite") {
808 if ((rhs.size() % 2) == 0)
809 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
813 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM;
814 float cb_index = 0.2f;
815 for (
size_t i = 1; i<rhs.size(); i += 2) {
816 string key(rhs[i].toString());
818 trees = rhs[i+1].toInt();
819 else if (key ==
"Branching")
820 branching = rhs[i+1].toInt();
821 else if (key ==
"Iterations")
822 iterations = rhs[i+1].toInt();
823 else if (key ==
"CentersInit")
824 centers_init = CentersInit[rhs[i+1].toString()];
825 else if (key ==
"CBIndex")
826 cb_index = rhs[i+1].toFloat();
828 mexErrMsgIdAndTxt(
"mexopencv:error",
829 "Unrecognized option %s", key.c_str());
831 p = makePtr<flann::CompositeIndexParams>(
832 trees, branching, iterations, centers_init, cb_index);
834 else if (type ==
"LSH") {
835 if ((rhs.size() % 2) == 0)
836 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
837 int table_number = 20;
839 int multi_probe_level = 0;
840 for (
size_t i = 1; i<rhs.size(); i += 2) {
841 string key(rhs[i].toString());
842 if (key ==
"TableNumber")
843 table_number = rhs[i+1].toInt();
844 else if (key ==
"KeySize")
845 key_size = rhs[i+1].toInt();
846 else if (key ==
"MultiProbeLevel")
847 multi_probe_level = rhs[i+1].toInt();
849 mexErrMsgIdAndTxt(
"mexopencv:error",
850 "Unrecognized option %s", key.c_str());
852 p = makePtr<flann::LshIndexParams>(
853 table_number, key_size, multi_probe_level);
855 else if (type ==
"Autotuned") {
856 if ((rhs.size() % 2) == 0)
857 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
858 float target_precision = 0.8f;
859 float build_weight = 0.01f;
860 float memory_weight = 0;
861 float sample_fraction = 0.1f;
862 for (
size_t i = 1; i<rhs.size(); i += 2) {
863 string key(rhs[i].toString());
864 if (key ==
"TargetPrecision")
865 target_precision = rhs[i+1].toFloat();
866 else if (key ==
"BuildWeight")
867 build_weight = rhs[i+1].toFloat();
868 else if (key ==
"MemoryWeight")
869 memory_weight = rhs[i+1].toFloat();
870 else if (key ==
"SampleFraction")
871 sample_fraction = rhs[i+1].toFloat();
873 mexErrMsgIdAndTxt(
"mexopencv:error",
874 "Unrecognized option %s", key.c_str());
876 p = makePtr<flann::AutotunedIndexParams>(
877 target_precision, build_weight, memory_weight, sample_fraction);
879 else if (type ==
"Saved") {
881 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
882 string filename(rhs[1].toString());
883 p = makePtr<flann::SavedIndexParams>(filename);
885 else if (type ==
"HierarchicalClustering") {
886 if ((rhs.size() % 2) == 0)
887 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
889 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM;
892 for (
size_t i = 1; i<rhs.size(); i += 2) {
893 string key(rhs[i].toString());
894 if (key ==
"Branching")
895 branching = rhs[i+1].toInt();
896 else if (key ==
"CentersInit")
897 centers_init = CentersInit[rhs[i+1].toString()];
898 else if (key ==
"Trees")
899 trees = rhs[i+1].toInt();
900 else if (key ==
"LeafSize")
901 leaf_size = rhs[i+1].toInt();
903 mexErrMsgIdAndTxt(
"mexopencv:error",
904 "Unrecognized option %s", key.c_str());
906 p = makePtr<flann::HierarchicalClusteringIndexParams>(
907 branching, centers_init, trees, leaf_size);
910 mexErrMsgIdAndTxt(
"mexopencv:error",
911 "Unrecognized IndexParams type: %s", type.c_str());
923 if ((rhs.size() % 2) != 0)
924 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
928 for (
size_t i = 0; i<rhs.size(); i += 2) {
929 string key(rhs[i].toString());
931 checks = rhs[i+1].toInt();
932 else if (key ==
"EPS")
933 eps = rhs[i+1].toFloat();
934 else if (key ==
"Sorted")
935 sorted = rhs[i+1].toBool();
937 mexErrMsgIdAndTxt(
"mexopencv:error",
938 "Unrecognized option %s", key.c_str());
940 return makePtr<flann::SearchParams>(checks, eps, sorted);
944 vector<MxArray>::const_iterator first,
945 vector<MxArray>::const_iterator last)
947 if (((last-first) % 2) != 0)
948 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
949 Ptr<flann::IndexParams> indexParams;
950 Ptr<flann::SearchParams> searchParams;
951 for (; first != last; first += 2) {
952 string key((*first).toString());
953 const MxArray& val = *(first + 1);
956 else if (key ==
"Search")
959 mexErrMsgIdAndTxt(
"mexopencv:error",
960 "Unrecognized option %s", key.c_str());
962 if (indexParams.empty())
963 indexParams = makePtr<flann::KDTreeIndexParams>();
964 if (searchParams.empty())
965 searchParams = makePtr<flann::SearchParams>();
966 return makePtr<FlannBasedMatcher>(indexParams, searchParams);
970 vector<MxArray>::const_iterator first,
971 vector<MxArray>::const_iterator last)
973 if (((last-first) % 2) != 0)
974 mexErrMsgIdAndTxt(
"mexopencv:error",
"Wrong number of arguments");
975 int normType = cv::NORM_L2;
976 bool crossCheck =
false;
977 for (; first != last; first += 2) {
978 string key((*first).toString());
979 const MxArray& val = *(first + 1);
980 if (key ==
"NormType")
981 normType =
NormType[val.toString()];
982 else if (key ==
"CrossCheck")
983 crossCheck = val.toBool();
985 mexErrMsgIdAndTxt(
"mexopencv:error",
986 "Unrecognized option %s", key.c_str());
988 return makePtr<BFMatcher>(normType, crossCheck);
993 vector<MxArray>::const_iterator first,
994 vector<MxArray>::const_iterator last)
996 Ptr<DescriptorMatcher> p;
997 if ((last-first) > 0) {
998 if (type ==
"FlannBasedMatcher")
1000 else if (type ==
"BFMatcher")
1003 mexErrMsgIdAndTxt(
"mexopencv:error",
1004 "Unrecognized matcher %s", type.c_str());
1007 p = DescriptorMatcher::create(type);
1009 mexErrMsgIdAndTxt(
"mexopencv:error",
1010 "Failed to create DescriptorMatcher of type %s", type.c_str());
const ConstMap< std::string, int > AgastTypeMap
AGAST neighborhood types.
const ConstMap< std::string, int > KAZEDiffusivityType
KAZE Diffusivity type.
cv::Ptr< cv::MSER > createMSER(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of MSER using options in arguments.
const ConstMap< string, cvflann::flann_centers_init_t > CentersInit
IndexParams centers initialization methods.
cv::Ptr< cv::AKAZE > createAKAZE(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of AKAZE using options in arguments.
Ptr< flann::SearchParams > toSearchParams(const MxArray &m)
Convert MxArray to FLANN search parameters.
cv::Ptr< cv::BFMatcher > createBFMatcher(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of BFMatcher using options in arguments.
cv::Ptr< cv::DescriptorExtractor > createDescriptorExtractor(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Factory function for DescriptorExtractor creation.
const ConstMap< std::string, int > AKAZEDescriptorType
AKAZE descriptor type.
cv::Ptr< cv::GFTTDetector > createGFTTDetector(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of GFTTDetector using options in arguments.
cv::Ptr< cv::KAZE > createKAZE(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of KAZE using options in arguments.
cv::Ptr< cv::FastFeatureDetector > createFastFeatureDetector(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of FastFeatureDetector using options in arguments.
double toDouble() const
Convert MxArray to double.
int toInt() const
Convert MxArray to int.
Ptr< flann::IndexParams > toIndexParams(const MxArray &m)
Convert MxArray to FLANN index parameters.
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.
float toFloat() const
Convert MxArray to float.
std::vector< T > toVector() const
Convert MxArray to std::vector<T> of primitive types.
cv::Ptr< cv::FeatureDetector > createFeatureDetector(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Factory function for FeatureDetector creation.
mxArray object wrapper for data conversion and manipulation.
cv::Ptr< cv::FlannBasedMatcher > createFlannBasedMatcher(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of FlannBasedMatcher using options in arguments.
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.
bool toBool() const
Convert MxArray to bool.
cv::Ptr< cv::AgastFeatureDetector > createAgastFeatureDetector(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of AgastFeatureDetector using options in arguments.
std::map wrapper with one-line initialization and lookup method.
const ConstMap< std::string, int > NormType
Norm type map for option processing.
cv::Ptr< cv::SimpleBlobDetector > createSimpleBlobDetector(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of SimpleBlobDetector using options in arguments.
const ConstMap< std::string, int > FASTTypeMap
FAST types.
cv::Ptr< cv::BRISK > createBRISK(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of BRISK using options in arguments.
const ConstMap< std::string, int > ORBScoreType
ORB score types.