32 #include <QtCore/QSettings> 33 #include <QtCore/QStringList> 34 #include <QtCore/QDir> 36 #include <opencv2/calib3d/calib3d.hpp> 37 #include <opencv2/opencv_modules.hpp> 39 #if CV_MAJOR_VERSION < 3 40 #include <opencv2/gpu/gpu.hpp> 41 #define CVCUDA cv::gpu 43 #include <opencv2/core/cuda.hpp> 44 #define CVCUDA cv::cuda 45 #ifdef HAVE_OPENCV_CUDAFEATURES2D 46 #include <opencv2/cudafeatures2d.hpp> 50 #ifdef HAVE_OPENCV_NONFREE 51 #if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >=4 52 #include <opencv2/nonfree/gpu.hpp> 53 #include <opencv2/nonfree/features2d.hpp> 56 #ifdef HAVE_OPENCV_XFEATURES2D 57 #include <opencv2/xfeatures2d.hpp> 58 #include <opencv2/xfeatures2d/cuda.hpp> 61 #if FINDOBJECT_TORCH == 1 77 return QString(
"%1/Documents/%2").arg(QDir::homePath()).arg(PROJECT_NAME);
79 return QString(
"%1").arg(QDir::homePath());
110 QString path = fileName;
111 if(fileName.isEmpty())
117 QSettings ini(path, QSettings::IniFormat);
120 const QString & key = iter.key();
121 QVariant value = ini.value(key, QVariant());
124 QString str = value.toString();
125 if(str.contains(
";"))
131 int index = str.split(
':').first().toInt();
133 str = QString::number(index)+
":"+ str.split(
':').back();
134 value = QVariant(str);
135 UINFO(
"Updated list of parameter \"%s\"", key.toStdString().c_str());
137 int index = str.split(
':').first().toInt();
138 if(key.compare(Settings::kFeature2D_1Detector()) == 0)
140 #if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11))) 141 #if FINDOBJECT_NONFREE == 0 142 if(index == 5 || index == 7)
144 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
145 UWARN(
"Trying to set \"%s\" to SIFT/SURF but Find-Object isn't built " 146 "with the nonfree module from OpenCV. Keeping default combo value: %s.",
147 Settings::kFeature2D_1Detector().toStdString().c_str(),
148 Settings::defaultFeature2D_1Detector().split(
':').last().split(
";").at(index).toStdString().c_str());
151 #elif FINDOBJECT_NONFREE == 0 154 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
155 UWARN(
"Trying to set \"%s\" to SURF but Find-Object isn't built " 156 "with the nonfree module from OpenCV. Keeping default combo value: %s.",
157 Settings::kFeature2D_1Detector().toStdString().c_str(),
158 Settings::defaultFeature2D_1Detector().split(
':').last().split(
";").at(index).toStdString().c_str());
161 #if FINDOBJECT_TORCH == 0 164 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
165 UWARN(
"Trying to set \"%s\" to SuperPointTorch but Find-Object isn't built " 166 "with the Torch. Keeping default combo value: %s.",
167 Settings::kFeature2D_1Detector().toStdString().c_str(),
168 Settings::defaultFeature2D_1Detector().split(
':').last().split(
";").at(index).toStdString().c_str());
172 else if(key.compare(Settings::kFeature2D_2Descriptor()) == 0)
174 #if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11))) 175 #if FINDOBJECT_NONFREE == 0 176 if(index == 2 || index == 3)
178 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
179 UWARN(
"Trying to set \"%s\" to SIFT/SURF but Find-Object isn't built " 180 "with the nonfree module from OpenCV. Keeping default combo value: %s.",
181 Settings::kFeature2D_2Descriptor().toStdString().c_str(),
182 Settings::defaultFeature2D_2Descriptor().split(
':').last().split(
";").at(index).toStdString().c_str());
185 #elif FINDOBJECT_NONFREE == 0 188 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
189 UWARN(
"Trying to set \"%s\" to SURF but Find-Object isn't built " 190 "with the nonfree module from OpenCV. Keeping default combo value: %s.",
191 Settings::kFeature2D_2Descriptor().toStdString().c_str(),
192 Settings::defaultFeature2D_2Descriptor().split(
':').last().split(
";").at(index).toStdString().c_str());
195 #if FINDOBJECT_TORCH == 0 198 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
199 UWARN(
"Trying to set \"%s\" to SuperPointTorch but Find-Object isn't built " 200 "with the Torch. Keeping default combo value: %s.",
201 Settings::kFeature2D_1Detector().toStdString().c_str(),
202 Settings::defaultFeature2D_1Detector().split(
':').last().split(
";").at(index).toStdString().c_str());
207 str = QString::number(index)+
":"+ str.split(
':').back();
208 value = QVariant(str);
210 loadedParameters.insert(key, value);
223 bool binToFloat = getNearestNeighbor_7ConvertBinToFloat();
226 UWARN(
"Current selected descriptor type (\"%s\") is binary while nearest neighbor strategy is not (\"%s\").\n" 227 "Falling back to \"BruteForce\" nearest neighbor strategy with Hamming distance (by default).",
230 QString tmp = Settings::getNearestNeighbor_1Strategy();
232 setNearestNeighbor_1Strategy(tmp);
233 loadedParameters.insert(Settings::kNearestNeighbor_1Strategy(), tmp);
234 tmp = Settings::getNearestNeighbor_2Distance_type();
236 setNearestNeighbor_2Distance_type(tmp);
237 loadedParameters.insert(Settings::kNearestNeighbor_2Distance_type(), tmp);
240 UINFO(
"Settings loaded from %s.", path.toStdString().c_str());
245 UINFO(
"Settings set to defaults.");
248 if(CVCUDA::getCudaEnabledDeviceCount() == 0)
250 #if FINDOBJECT_NONFREE == 1 251 Settings::setFeature2D_SURF_gpu(
false);
253 Settings::setFeature2D_Fast_gpu(
false);
254 Settings::setFeature2D_ORB_gpu(
false);
255 Settings::setNearestNeighbor_BruteForce_gpu(
false);
257 return loadedParameters;
262 QString path = fileName;
263 if(fileName.isEmpty())
270 QSettings ini(path, QSettings::IniFormat);
272 QVariant value = ini.value(
"windowGeometry", QVariant());
275 windowGeometry = value.toByteArray();
278 value = ini.value(
"windowState", QVariant());
281 windowState = value.toByteArray();
284 UINFO(
"Window settings loaded from %s", path.toStdString().c_str());
290 QString path = fileName;
291 if(fileName.isEmpty())
297 QSettings ini(path, QSettings::IniFormat);
301 if(type.compare(
"float") == 0)
303 ini.setValue(iter.key(), QString::number(iter.value().toFloat(),
'g',6));
307 ini.setValue(iter.key(), iter.value());
310 UINFO(
"Settings saved to %s", path.toStdString().c_str());
316 QString path = fileName;
317 if(fileName.isEmpty())
323 QSettings ini(path, QSettings::IniFormat);
324 if(!windowGeometry.isEmpty())
326 ini.setValue(
"windowGeometry", windowGeometry);
328 if(!windowState.isEmpty())
330 ini.setValue(
"windowState", windowState);
332 UINFO(
"Window settings saved to %s", path.toStdString().c_str());
336 #if FINDOBJECT_NONFREE == 1 340 GPUSURF(
double hessianThreshold,
344 float keypointsRatio,
346 surf_(hessianThreshold,
354 virtual ~GPUSURF() {}
356 virtual void detect(
const cv::Mat & image,
357 std::vector<cv::KeyPoint> & keypoints,
358 const cv::Mat & mask = cv::Mat())
360 CVCUDA::GpuMat imgGpu(image);
361 CVCUDA::GpuMat maskGpu(mask);
364 surf_(imgGpu, maskGpu, keypoints);
366 catch(cv::Exception &e)
368 UERROR(
"GPUSURF error: %s \n(If something about layer_rows, parameter nOctaves=%d of SURF " 369 "is too high for the size of the image (%d,%d).)",
377 virtual void compute(
const cv::Mat& image,
378 std::vector<cv::KeyPoint>& keypoints,
379 cv::Mat& descriptors)
381 std::vector<float>
d;
382 CVCUDA::GpuMat imgGpu(image);
383 CVCUDA::GpuMat descriptorsGPU;
386 surf_(imgGpu, CVCUDA::GpuMat(), keypoints, descriptorsGPU,
true);
388 catch(cv::Exception &e)
390 UERROR(
"GPUSURF error: %s \n(If something about layer_rows, parameter nOctaves=%d of SURF " 391 "is too high for the size of the image (%d,%d).)",
399 if (descriptorsGPU.empty())
400 descriptors = cv::Mat();
403 UASSERT(descriptorsGPU.type() == CV_32F);
404 descriptors = cv::Mat(descriptorsGPU.size(), CV_32F);
405 descriptorsGPU.download(descriptors);
409 virtual void detectAndCompute(
const cv::Mat& image,
410 std::vector<cv::KeyPoint>& keypoints,
411 cv::Mat& descriptors,
412 const cv::Mat & mask = cv::Mat())
414 std::vector<float>
d;
415 CVCUDA::GpuMat imgGpu(image);
416 CVCUDA::GpuMat descriptorsGPU;
417 CVCUDA::GpuMat maskGpu(mask);
420 surf_(imgGpu, maskGpu, keypoints, descriptorsGPU,
false);
422 catch(cv::Exception &e)
424 UERROR(
"GPUSURF error: %s \n(If something about layer_rows, parameter nOctaves=%d of SURF " 425 "is too high for the size of the image (%d,%d).)",
433 if (descriptorsGPU.empty())
434 descriptors = cv::Mat();
437 UASSERT(descriptorsGPU.type() == CV_32F);
438 descriptors = cv::Mat(descriptorsGPU.size(), CV_32F);
439 descriptorsGPU.download(descriptors);
444 #if CV_MAJOR_VERSION < 3 445 CVCUDA::SURF_GPU surf_;
447 CVCUDA::SURF_CUDA surf_;
455 GPUFAST(
int threshold=Settings::defaultFeature2D_Fast_threshold(),
456 bool nonmaxSuppression=Settings::defaultFeature2D_Fast_nonmaxSuppression(),
457 #
if CV_MAJOR_VERSION < 3
458 double keypointsRatio=Settings::defaultFeature2D_Fast_keypointsRatio())
463 int max_npoints=
Settings::defaultFeature2D_Fast_maxNpoints())
464 #ifdef HAVE_OPENCV_CUDAFEATURES2D
465 : fast_(
CVCUDA::FastFeatureDetector::create(
468 cv::FastFeatureDetector::TYPE_9_16,
476 virtual void detect(
const cv::Mat & image,
477 std::vector<cv::KeyPoint> & keypoints,
478 const cv::Mat & mask = cv::Mat())
480 CVCUDA::GpuMat imgGpu(image);
481 CVCUDA::GpuMat maskGpu(mask);
482 #if CV_MAJOR_VERSION < 3 483 fast_(imgGpu, maskGpu, keypoints);
485 #ifdef HAVE_OPENCV_CUDAFEATURES2D 486 CVCUDA::GpuMat keypointsGpu;
487 fast_->detectAsync(imgGpu, keypointsGpu, maskGpu);
488 fast_->convert(keypointsGpu, keypoints);
493 std::vector<cv::KeyPoint>& keypoints,
494 cv::Mat& descriptors)
496 UERROR(
"GPUFAST:computeDescriptors() Should not be used!");
499 std::vector<cv::KeyPoint>& keypoints,
500 cv::Mat& descriptors,
501 const cv::Mat & mask = cv::Mat())
503 UERROR(
"GPUFAST:detectAndCompute() Should not be used!");
507 #if CV_MAJOR_VERSION < 3 510 #ifdef HAVE_OPENCV_CUDAFEATURES2D 511 cv::Ptr<CVCUDA::FastFeatureDetector> fast_;
519 GPUORB(
int nFeatures = Settings::defaultFeature2D_ORB_nFeatures(),
520 float scaleFactor = Settings::defaultFeature2D_ORB_scaleFactor(),
521 int nLevels = Settings::defaultFeature2D_ORB_nLevels(),
522 int edgeThreshold = Settings::defaultFeature2D_ORB_edgeThreshold(),
523 int firstLevel = Settings::defaultFeature2D_ORB_firstLevel(),
524 int WTA_K = Settings::defaultFeature2D_ORB_WTA_K(),
525 int scoreType = Settings::defaultFeature2D_ORB_scoreType(),
526 int patchSize = Settings::defaultFeature2D_ORB_patchSize(),
527 int fastThreshold = Settings::defaultFeature2D_Fast_threshold(),
528 #
if CV_MAJOR_VERSION < 3
529 bool fastNonmaxSupression = Settings::defaultFeature2D_Fast_nonmaxSuppression())
539 bool blurForDescriptor =
Settings::defaultFeature2D_ORB_blurForDescriptor())
540 #ifdef HAVE_OPENCV_CUDAFEATURES2D
541 : orb_(
CVCUDA::ORB::create(nFeatures,
554 #if CV_MAJOR_VERSION < 3 555 orb_.setFastParams(fastThreshold, fastNonmaxSupression);
560 virtual void detect(
const cv::Mat & image,
561 std::vector<cv::KeyPoint> & keypoints,
562 const cv::Mat & mask = cv::Mat())
565 CVCUDA::GpuMat imgGpu(image);
566 CVCUDA::GpuMat maskGpu(mask);
570 #if CV_MAJOR_VERSION < 3 571 orb_(imgGpu, maskGpu, keypoints);
573 #ifdef HAVE_OPENCV_CUDAFEATURES2D 574 CVCUDA::GpuMat keypointsGpu;
575 orb_->detectAsync(imgGpu, keypointsGpu, maskGpu);
576 orb_->convert(keypointsGpu, keypoints);
580 catch(cv::Exception &e)
582 UERROR(
"GPUORB error: %s \n(If something about matrix size, the image/object may be too small (%d,%d).)",
590 std::vector<cv::KeyPoint>& keypoints,
591 cv::Mat& descriptors)
593 std::vector<float>
d;
595 CVCUDA::GpuMat imgGpu(image);
596 CVCUDA::GpuMat descriptorsGPU;
600 #if CV_MAJOR_VERSION < 3 601 orb_(imgGpu, CVCUDA::GpuMat(), keypoints, descriptorsGPU);
603 #ifdef HAVE_OPENCV_CUDAFEATURES2D 604 UERROR(
"OpenCV 3 ORB-GPU doesn't support extracting ORB descriptors from already extracted keypoints. " 605 "Use ORB as feature detector too or desactivate ORB-GPU.");
610 catch(cv::Exception &e)
612 UERROR(
"GPUORB error: %s \n(If something about matrix size, the image/object may be too small (%d,%d).)",
618 if (descriptorsGPU.empty())
619 descriptors = cv::Mat();
622 UASSERT(descriptorsGPU.type() == CV_8U);
623 descriptors = cv::Mat(descriptorsGPU.size(), CV_8U);
624 descriptorsGPU.download(descriptors);
629 std::vector<cv::KeyPoint>& keypoints,
630 cv::Mat& descriptors,
631 const cv::Mat & mask = cv::Mat())
633 std::vector<float>
d;
635 CVCUDA::GpuMat imgGpu(image);
636 CVCUDA::GpuMat descriptorsGPU;
637 CVCUDA::GpuMat maskGpu(mask);
641 #if CV_MAJOR_VERSION < 3 642 orb_(imgGpu, CVCUDA::GpuMat(), keypoints, descriptorsGPU);
644 #ifdef HAVE_OPENCV_CUDAFEATURES2D 645 CVCUDA::GpuMat keypointsGpu;
646 orb_->detectAndComputeAsync(imgGpu, maskGpu, keypointsGpu, descriptorsGPU,
false);
647 orb_->convert(keypointsGpu, keypoints);
651 catch(cv::Exception &e)
653 UERROR(
"GPUORB error: %s \n(If something about matrix size, the image/object may be too small (%d,%d).)",
659 if (descriptorsGPU.empty())
660 descriptors = cv::Mat();
663 UASSERT(descriptorsGPU.type() == CV_8U);
664 descriptors = cv::Mat(descriptorsGPU.size(), CV_8U);
665 descriptorsGPU.download(descriptors);
670 #if CV_MAJOR_VERSION < 3 673 #ifdef HAVE_OPENCV_CUDAFEATURES2D 674 cv::Ptr<CVCUDA::ORB> orb_;
679 #if FINDOBJECT_TORCH == 1 684 const QString & modelPath,
685 float threshold = Settings::defaultFeature2D_SuperPointTorch_threshold(),
686 bool nms = Settings::defaultFeature2D_SuperPointTorch_NMS(),
687 int nmsRadius = Settings::defaultFeature2D_SuperPointTorch_NMS_radius(),
688 bool cuda = Settings::defaultFeature2D_SuperPointTorch_cuda())
690 superPoint_ = cv::Ptr<SPDetector>(
new SPDetector(modelPath.toStdString(), threshold, nms, nmsRadius, cuda));
693 virtual ~SuperPointTorch() {}
695 virtual void detect(
const cv::Mat & image,
696 std::vector<cv::KeyPoint> & keypoints,
697 const cv::Mat & mask = cv::Mat())
699 keypoints = superPoint_->detect(image);
702 virtual void compute(
const cv::Mat& image,
703 std::vector<cv::KeyPoint>& keypoints,
704 cv::Mat& descriptors)
706 descriptors = superPoint_->compute(keypoints);
709 virtual void detectAndCompute(
const cv::Mat& image,
710 std::vector<cv::KeyPoint>& keypoints,
711 cv::Mat& descriptors,
712 const cv::Mat & mask = cv::Mat())
714 keypoints = superPoint_->detect(image);
715 descriptors = superPoint_->compute(keypoints);
718 cv::Ptr<SPDetector> superPoint_;
725 QString str = getFeature2D_1Detector();
726 UDEBUG(
"Type=%s", str.toStdString().c_str());
727 QStringList split = str.split(
':');
731 int index = split.first().toInt(&ok);
734 QStringList strategies = split.last().split(
';');
736 if(index>=0 && index<strategies.size())
740 #if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11))) 741 #if FINDOBJECT_NONFREE == 0 742 if(strategies.at(index).compare(
"SIFT") == 0 ||
743 strategies.at(index).compare(
"SURF") == 0)
745 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
746 UERROR(
"Find-Object is not built with OpenCV nonfree module so " 747 "SIFT/SURF cannot be used! Using default \"%s\" instead.",
748 strategies.at(index).toStdString().c_str());
752 #elif FINDOBJECT_NONFREE == 0 753 if(strategies.at(index).compare(
"SURF") == 0)
755 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
756 UERROR(
"Find-Object is not built with OpenCV nonfree module so " 757 "SURF cannot be used! Using default \"%s\" instead.",
758 strategies.at(index).toStdString().c_str());
763 #if FINDOBJECT_TORCH == 0 765 if(strategies.at(index).compare(
"SuperPointTorch") == 0)
767 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
768 UERROR(
"Find-Object is not built with Torch so " 769 "SuperPointTorch cannot be used! Using default \"%s\" instead.",
770 strategies.at(index).toStdString().c_str());
775 #if CV_MAJOR_VERSION < 3 776 if(strategies.at(index).compare(
"AGAST") == 0 ||
777 strategies.at(index).compare(
"KAZE") == 0 ||
778 strategies.at(index).compare(
"AKAZE") == 0)
780 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
781 UERROR(
"Find-Object is built with OpenCV 2 so " 782 "AGAST/KAZE/AKAZE cannot be used! Using default \"%s\" instead.",
783 strategies.at(index).toStdString().c_str());
787 if(strategies.at(index).compare(
"Dense") == 0)
789 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
790 UERROR(
"Find-Object is built with OpenCV 3 so " 791 "Dense cannot be used! Using default \"%s\" instead.",
792 strategies.at(index).toStdString().c_str());
795 #ifndef HAVE_OPENCV_XFEATURES2D 796 if(strategies.at(index).compare(
"Star") == 0)
798 index = Settings::defaultFeature2D_1Detector().split(
':').first().toInt();
799 UERROR(
"Find-Object is not built with OpenCV xfeatures2d module so " 800 "Star cannot be used! Using default \"%s\" instead.",
801 strategies.at(index).toStdString().c_str());
807 if(strategies.at(index).compare(
"Dense") == 0)
809 #if CV_MAJOR_VERSION < 3 810 feature2D =
new Feature2D(cv::Ptr<cv::FeatureDetector>(
new cv::DenseFeatureDetector(
811 getFeature2D_Dense_initFeatureScale(),
812 getFeature2D_Dense_featureScaleLevels(),
813 getFeature2D_Dense_featureScaleMul(),
814 getFeature2D_Dense_initXyStep(),
815 getFeature2D_Dense_initImgBound(),
816 getFeature2D_Dense_varyXyStepWithScale(),
817 getFeature2D_Dense_varyImgBoundWithScale())));
819 UWARN(
"Find-Object is not built with OpenCV 2 so Dense cannot be used!");
821 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
823 else if(strategies.at(index).compare(
"Fast") == 0)
825 if(getFeature2D_Fast_gpu() && CVCUDA::getCudaEnabledDeviceCount())
828 getFeature2D_Fast_threshold(),
829 getFeature2D_Fast_nonmaxSuppression());
830 UDEBUG(
"type=%s GPU", strategies.at(index).toStdString().c_str());
834 #if CV_MAJOR_VERSION < 3 835 feature2D =
new Feature2D(cv::Ptr<cv::FeatureDetector>(
new cv::FastFeatureDetector(
836 getFeature2D_Fast_threshold(),
837 getFeature2D_Fast_nonmaxSuppression())));
839 feature2D =
new Feature2D(cv::FastFeatureDetector::create(
840 getFeature2D_Fast_threshold(),
841 getFeature2D_Fast_nonmaxSuppression()));
843 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
846 else if(strategies.at(index).compare(
"AGAST") == 0)
848 #if CV_MAJOR_VERSION < 3 849 UWARN(
"Find-Object is not built with OpenCV 3 so AGAST cannot be used!");
851 feature2D =
new Feature2D(cv::AgastFeatureDetector::create(
852 getFeature2D_AGAST_threshold(),
853 getFeature2D_AGAST_nonmaxSuppression()));
855 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
857 else if(strategies.at(index).compare(
"GFTT") == 0)
859 #if CV_MAJOR_VERSION < 3 860 feature2D =
new Feature2D(cv::Ptr<cv::FeatureDetector>(
new cv::GFTTDetector(
861 getFeature2D_GFTT_maxCorners(),
862 getFeature2D_GFTT_qualityLevel(),
863 getFeature2D_GFTT_minDistance(),
864 getFeature2D_GFTT_blockSize(),
865 getFeature2D_GFTT_useHarrisDetector(),
866 getFeature2D_GFTT_k())));
868 feature2D =
new Feature2D(cv::GFTTDetector::create(
869 getFeature2D_GFTT_maxCorners(),
870 getFeature2D_GFTT_qualityLevel(),
871 getFeature2D_GFTT_minDistance(),
872 getFeature2D_GFTT_blockSize(),
873 getFeature2D_GFTT_useHarrisDetector(),
874 getFeature2D_GFTT_k()));
876 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
878 else if(strategies.at(index).compare(
"MSER") == 0)
880 #if CV_MAJOR_VERSION < 3 881 feature2D =
new Feature2D(cv::Ptr<cv::FeatureDetector>(
new cv::MSER(
882 getFeature2D_MSER_delta(),
883 getFeature2D_MSER_minArea(),
884 getFeature2D_MSER_maxArea(),
885 getFeature2D_MSER_maxVariation(),
886 getFeature2D_MSER_minDiversity(),
887 getFeature2D_MSER_maxEvolution(),
888 getFeature2D_MSER_areaThreshold(),
889 getFeature2D_MSER_minMargin(),
890 getFeature2D_MSER_edgeBlurSize())));
892 feature2D =
new Feature2D(cv::MSER::create(
893 getFeature2D_MSER_delta(),
894 getFeature2D_MSER_minArea(),
895 getFeature2D_MSER_maxArea(),
896 getFeature2D_MSER_maxVariation(),
897 getFeature2D_MSER_minDiversity(),
898 getFeature2D_MSER_maxEvolution(),
899 getFeature2D_MSER_areaThreshold(),
900 getFeature2D_MSER_minMargin(),
901 getFeature2D_MSER_edgeBlurSize()));
903 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
905 else if(strategies.at(index).compare(
"ORB") == 0)
907 if(getFeature2D_ORB_gpu() && CVCUDA::getCudaEnabledDeviceCount())
910 getFeature2D_ORB_nFeatures(),
911 getFeature2D_ORB_scaleFactor(),
912 getFeature2D_ORB_nLevels(),
913 getFeature2D_ORB_edgeThreshold(),
914 getFeature2D_ORB_firstLevel(),
915 getFeature2D_ORB_WTA_K(),
916 getFeature2D_ORB_scoreType(),
917 getFeature2D_ORB_patchSize(),
918 getFeature2D_Fast_threshold(),
919 #
if CV_MAJOR_VERSION < 3
920 getFeature2D_Fast_nonmaxSuppression());
922 getFeature2D_ORB_blurForDescriptor());
924 UDEBUG(
"type=%s (GPU)", strategies.at(index).toStdString().c_str());
928 #if CV_MAJOR_VERSION < 3 929 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::ORB(
930 getFeature2D_ORB_nFeatures(),
931 getFeature2D_ORB_scaleFactor(),
932 getFeature2D_ORB_nLevels(),
933 getFeature2D_ORB_edgeThreshold(),
934 getFeature2D_ORB_firstLevel(),
935 getFeature2D_ORB_WTA_K(),
936 getFeature2D_ORB_scoreType(),
937 getFeature2D_ORB_patchSize())));
939 feature2D =
new Feature2D(cv::ORB::create(
940 getFeature2D_ORB_nFeatures(),
941 getFeature2D_ORB_scaleFactor(),
942 getFeature2D_ORB_nLevels(),
943 getFeature2D_ORB_edgeThreshold(),
944 getFeature2D_ORB_firstLevel(),
945 getFeature2D_ORB_WTA_K(),
946 #
if CV_MAJOR_VERSION > 3
947 (cv::ORB::ScoreType)getFeature2D_ORB_scoreType(),
949 getFeature2D_ORB_scoreType(),
951 getFeature2D_ORB_patchSize(),
952 getFeature2D_Fast_threshold()));
954 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
957 else if(strategies.at(index).compare(
"Star") == 0)
959 #if CV_MAJOR_VERSION < 3 960 feature2D =
new Feature2D(cv::Ptr<cv::FeatureDetector>(
new cv::StarFeatureDetector(
961 getFeature2D_Star_maxSize(),
962 getFeature2D_Star_responseThreshold(),
963 getFeature2D_Star_lineThresholdProjected(),
964 getFeature2D_Star_lineThresholdBinarized(),
965 getFeature2D_Star_suppressNonmaxSize())));
967 #ifdef HAVE_OPENCV_XFEATURES2D 968 feature2D =
new Feature2D(cv::xfeatures2d::StarDetector::create(
969 getFeature2D_Star_maxSize(),
970 getFeature2D_Star_responseThreshold(),
971 getFeature2D_Star_lineThresholdProjected(),
972 getFeature2D_Star_lineThresholdBinarized(),
973 getFeature2D_Star_suppressNonmaxSize()));
975 UWARN(
"Find-Object is not built with OpenCV xfeatures2d module so Star cannot be used!");
978 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
980 else if(strategies.at(index).compare(
"BRISK") == 0)
982 #if CV_MAJOR_VERSION < 3 983 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::BRISK(
984 getFeature2D_BRISK_thresh(),
985 getFeature2D_BRISK_octaves(),
986 getFeature2D_BRISK_patternScale())));
988 feature2D =
new Feature2D(cv::BRISK::create(
989 getFeature2D_BRISK_thresh(),
990 getFeature2D_BRISK_octaves(),
991 getFeature2D_BRISK_patternScale()));
993 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
995 else if(strategies.at(index).compare(
"KAZE") == 0)
997 #if CV_MAJOR_VERSION < 3 998 UWARN(
"Find-Object is not built with OpenCV 3 so KAZE cannot be used!");
1000 feature2D =
new Feature2D(cv::KAZE::create(
1001 getFeature2D_KAZE_extended(),
1002 getFeature2D_KAZE_upright(),
1003 getFeature2D_KAZE_threshold(),
1004 getFeature2D_KAZE_nOctaves(),
1005 getFeature2D_KAZE_nOctaveLayers(),
1006 cv::KAZE::DIFF_PM_G2));
1008 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1010 else if(strategies.at(index).compare(
"AKAZE") == 0)
1012 #if CV_MAJOR_VERSION < 3 1013 UWARN(
"Find-Object is not built with OpenCV 3 so AKAZE cannot be used!");
1015 feature2D =
new Feature2D(cv::AKAZE::create(
1016 cv::AKAZE::DESCRIPTOR_MLDB,
1017 getFeature2D_AKAZE_descriptorSize(),
1018 getFeature2D_AKAZE_descriptorChannels(),
1019 getFeature2D_AKAZE_threshold(),
1020 getFeature2D_AKAZE_nOctaves(),
1021 getFeature2D_AKAZE_nOctaveLayers(),
1022 cv::KAZE::DIFF_PM_G2));
1024 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1026 #if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11))) 1027 #if FINDOBJECT_NONFREE == 1 1028 else if(strategies.at(index).compare(
"SIFT") == 0)
1030 #if CV_MAJOR_VERSION < 3 1031 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::SIFT(
1032 getFeature2D_SIFT_nfeatures(),
1033 getFeature2D_SIFT_nOctaveLayers(),
1034 getFeature2D_SIFT_contrastThreshold(),
1035 getFeature2D_SIFT_edgeThreshold(),
1036 getFeature2D_SIFT_sigma())));
1038 feature2D =
new Feature2D(cv::xfeatures2d::SIFT::create(
1039 getFeature2D_SIFT_nfeatures(),
1040 getFeature2D_SIFT_nOctaveLayers(),
1041 getFeature2D_SIFT_contrastThreshold(),
1042 getFeature2D_SIFT_edgeThreshold(),
1043 getFeature2D_SIFT_sigma()));
1045 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1047 else if(strategies.at(index).compare(
"SURF") == 0)
1049 if(getFeature2D_SURF_gpu() && CVCUDA::getCudaEnabledDeviceCount())
1051 feature2D =
new GPUSURF(
1052 getFeature2D_SURF_hessianThreshold(),
1053 getFeature2D_SURF_nOctaves(),
1054 getFeature2D_SURF_nOctaveLayers(),
1055 getFeature2D_SURF_extended(),
1056 getFeature2D_SURF_keypointsRatio(),
1057 getFeature2D_SURF_upright());
1058 UDEBUG(
"type=%s (GPU)", strategies.at(index).toStdString().c_str());
1062 #if CV_MAJOR_VERSION < 3 1063 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::SURF(
1064 getFeature2D_SURF_hessianThreshold(),
1065 getFeature2D_SURF_nOctaves(),
1066 getFeature2D_SURF_nOctaveLayers(),
1067 getFeature2D_SURF_extended(),
1068 getFeature2D_SURF_upright())));
1070 feature2D =
new Feature2D(cv::xfeatures2d::SURF::create(
1071 getFeature2D_SURF_hessianThreshold(),
1072 getFeature2D_SURF_nOctaves(),
1073 getFeature2D_SURF_nOctaveLayers(),
1074 getFeature2D_SURF_extended(),
1075 getFeature2D_SURF_upright()));
1077 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1081 #else // >= 4.3.0-dev 1082 else if(strategies.at(index).compare(
"SIFT") == 0)
1084 feature2D =
new Feature2D(cv::SIFT::create(
1085 getFeature2D_SIFT_nfeatures(),
1086 getFeature2D_SIFT_nOctaveLayers(),
1087 getFeature2D_SIFT_contrastThreshold(),
1088 getFeature2D_SIFT_edgeThreshold(),
1089 getFeature2D_SIFT_sigma()));
1090 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1092 #if FINDOBJECT_NONFREE == 1 1093 else if(strategies.at(index).compare(
"SURF") == 0)
1095 if(getFeature2D_SURF_gpu() && CVCUDA::getCudaEnabledDeviceCount())
1097 feature2D =
new GPUSURF(
1098 getFeature2D_SURF_hessianThreshold(),
1099 getFeature2D_SURF_nOctaves(),
1100 getFeature2D_SURF_nOctaveLayers(),
1101 getFeature2D_SURF_extended(),
1102 getFeature2D_SURF_keypointsRatio(),
1103 getFeature2D_SURF_upright());
1104 UDEBUG(
"type=%s (GPU)", strategies.at(index).toStdString().c_str());
1108 feature2D =
new Feature2D(cv::xfeatures2d::SURF::create(
1109 getFeature2D_SURF_hessianThreshold(),
1110 getFeature2D_SURF_nOctaves(),
1111 getFeature2D_SURF_nOctaveLayers(),
1112 getFeature2D_SURF_extended(),
1113 getFeature2D_SURF_upright()));
1114 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1119 #if FINDOBJECT_TORCH == 1 1120 else if(strategies.at(index).compare(
"SuperPointTorch") == 0)
1122 feature2D =
new SuperPointTorch(
1123 getFeature2D_SuperPointTorch_modelPath(),
1124 getFeature2D_SuperPointTorch_threshold(),
1125 getFeature2D_SuperPointTorch_NMS(),
1126 getFeature2D_SuperPointTorch_NMS_radius(),
1127 getFeature2D_SuperPointTorch_cuda());
1128 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1141 QString str = getFeature2D_2Descriptor();
1142 UDEBUG(
"Type=%s", str.toStdString().c_str());
1143 QStringList split = str.split(
':');
1147 int index = split.first().toInt(&ok);
1150 QStringList strategies = split.last().split(
';');
1151 if(index>=0 && index<strategies.size())
1155 #if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11))) 1156 #if FINDOBJECT_NONFREE == 0 1157 if(strategies.at(index).compare(
"SIFT") == 0 ||
1158 strategies.at(index).compare(
"SURF") == 0)
1160 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
1161 UERROR(
"Find-Object is not built with OpenCV nonfree module so " 1162 "SIFT/SURF cannot be used! Using default \"%s\" instead.",
1163 strategies.at(index).toStdString().c_str());
1167 #elif FINDOBJECT_NONFREE == 0 // >= 4.3.0 1168 if(strategies.at(index).compare(
"SURF") == 0)
1170 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
1171 UERROR(
"Find-Object is not built with OpenCV nonfree module so " 1172 "SURF cannot be used! Using default \"%s\" instead.",
1173 strategies.at(index).toStdString().c_str());
1178 #if FINDOBJECT_TORCH == 0 1180 if(strategies.at(index).compare(
"SuperPointTorch") == 0)
1182 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
1183 UERROR(
"Find-Object is not built with Torch so " 1184 "SuperPointTorch cannot be used! Using default \"%s\" instead.",
1185 strategies.at(index).toStdString().c_str());
1190 #if CV_MAJOR_VERSION < 3 1191 if(strategies.at(index).compare(
"KAZE") == 0 ||
1192 strategies.at(index).compare(
"AKAZE") == 0)
1194 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
1195 UERROR(
"Find-Object is built with OpenCV 2 so " 1196 "KAZE/AKAZE cannot be used! Using default \"%s\" instead.",
1197 strategies.at(index).toStdString().c_str());
1201 #ifndef HAVE_OPENCV_XFEATURES2D 1202 if(strategies.at(index).compare(
"Brief") == 0 ||
1203 strategies.at(index).compare(
"FREAK") == 0 ||
1204 strategies.at(index).compare(
"LUCID") == 0 ||
1205 strategies.at(index).compare(
"LATCH") == 0 ||
1206 strategies.at(index).compare(
"DAISY") == 0)
1208 index = Settings::defaultFeature2D_2Descriptor().split(
':').first().toInt();
1209 UERROR(
"Find-Object is not built with OpenCV xfeatures2d module so " 1210 "Brief/FREAK/LUCID/LATCH/DAISY cannot be used! Using default \"%s\" instead.",
1211 strategies.at(index).toStdString().c_str());
1217 if(strategies.at(index).compare(
"Brief") == 0)
1219 #if CV_MAJOR_VERSION < 3 1220 feature2D =
new Feature2D(cv::Ptr<cv::DescriptorExtractor>(
new cv::BriefDescriptorExtractor(
1221 getFeature2D_Brief_bytes())));
1223 #ifdef HAVE_OPENCV_XFEATURES2D 1224 feature2D =
new Feature2D(cv::xfeatures2d::BriefDescriptorExtractor::create(
1225 getFeature2D_Brief_bytes()));
1227 UWARN(
"Find-Object is not built with OpenCV xfeatures2d module so Brief cannot be used!");
1230 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1232 else if(strategies.at(index).compare(
"ORB") == 0)
1234 if(getFeature2D_ORB_gpu() && CVCUDA::getCudaEnabledDeviceCount())
1237 getFeature2D_ORB_nFeatures(),
1238 getFeature2D_ORB_scaleFactor(),
1239 getFeature2D_ORB_nLevels(),
1240 getFeature2D_ORB_edgeThreshold(),
1241 getFeature2D_ORB_firstLevel(),
1242 getFeature2D_ORB_WTA_K(),
1243 getFeature2D_ORB_scoreType(),
1244 getFeature2D_ORB_patchSize(),
1245 getFeature2D_Fast_threshold(),
1246 getFeature2D_Fast_nonmaxSuppression());
1247 UDEBUG(
"type=%s (GPU)", strategies.at(index).toStdString().c_str());
1251 #if CV_MAJOR_VERSION < 3 1252 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::ORB(
1253 getFeature2D_ORB_nFeatures(),
1254 getFeature2D_ORB_scaleFactor(),
1255 getFeature2D_ORB_nLevels(),
1256 getFeature2D_ORB_edgeThreshold(),
1257 getFeature2D_ORB_firstLevel(),
1258 getFeature2D_ORB_WTA_K(),
1259 getFeature2D_ORB_scoreType(),
1260 getFeature2D_ORB_patchSize())));
1262 feature2D =
new Feature2D(cv::ORB::create(
1263 getFeature2D_ORB_nFeatures(),
1264 getFeature2D_ORB_scaleFactor(),
1265 getFeature2D_ORB_nLevels(),
1266 getFeature2D_ORB_edgeThreshold(),
1267 getFeature2D_ORB_firstLevel(),
1268 getFeature2D_ORB_WTA_K(),
1269 #
if CV_MAJOR_VERSION > 3
1270 (cv::ORB::ScoreType)getFeature2D_ORB_scoreType(),
1272 getFeature2D_ORB_scoreType(),
1274 getFeature2D_ORB_patchSize(),
1275 getFeature2D_Fast_threshold()));
1277 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1280 else if(strategies.at(index).compare(
"BRISK") == 0)
1282 #if CV_MAJOR_VERSION < 3 1283 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::BRISK(
1284 getFeature2D_BRISK_thresh(),
1285 getFeature2D_BRISK_octaves(),
1286 getFeature2D_BRISK_patternScale())));
1288 feature2D =
new Feature2D(cv::BRISK::create(
1289 getFeature2D_BRISK_thresh(),
1290 getFeature2D_BRISK_octaves(),
1291 getFeature2D_BRISK_patternScale()));
1293 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1295 else if(strategies.at(index).compare(
"KAZE") == 0)
1297 #if CV_MAJOR_VERSION < 3 1298 UWARN(
"Find-Object is not built with OpenCV 3 so KAZE cannot be used!");
1300 feature2D =
new Feature2D(cv::KAZE::create(
1301 getFeature2D_KAZE_extended(),
1302 getFeature2D_KAZE_upright(),
1303 getFeature2D_KAZE_threshold(),
1304 getFeature2D_KAZE_nOctaves(),
1305 getFeature2D_KAZE_nOctaveLayers(),
1306 cv::KAZE::DIFF_PM_G2));
1308 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1310 else if(strategies.at(index).compare(
"AKAZE") == 0)
1312 #if CV_MAJOR_VERSION < 3 1313 UWARN(
"Find-Object is not built with OpenCV 3 so AKAZE cannot be used!");
1315 feature2D =
new Feature2D(cv::AKAZE::create(
1316 cv::AKAZE::DESCRIPTOR_MLDB,
1317 getFeature2D_AKAZE_descriptorSize(),
1318 getFeature2D_AKAZE_descriptorChannels(),
1319 getFeature2D_AKAZE_threshold(),
1320 getFeature2D_AKAZE_nOctaves(),
1321 getFeature2D_AKAZE_nOctaveLayers(),
1322 cv::KAZE::DIFF_PM_G2));
1324 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1326 else if(strategies.at(index).compare(
"FREAK") == 0)
1328 #if CV_MAJOR_VERSION < 3 1329 feature2D =
new Feature2D(cv::Ptr<cv::DescriptorExtractor>(
new cv::FREAK(
1330 getFeature2D_FREAK_orientationNormalized(),
1331 getFeature2D_FREAK_scaleNormalized(),
1332 getFeature2D_FREAK_patternScale(),
1333 getFeature2D_FREAK_nOctaves())));
1335 #ifdef HAVE_OPENCV_XFEATURES2D 1336 feature2D =
new Feature2D(cv::xfeatures2d::FREAK::create(
1337 getFeature2D_FREAK_orientationNormalized(),
1338 getFeature2D_FREAK_scaleNormalized(),
1339 getFeature2D_FREAK_patternScale(),
1340 getFeature2D_FREAK_nOctaves()));
1342 UWARN(
"Find-Object is not built with OpenCV xfeatures2d module so Freak cannot be used!");
1346 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1348 #ifdef HAVE_OPENCV_XFEATURES2D 1349 else if(strategies.at(index).compare(
"LUCID") == 0)
1351 feature2D =
new Feature2D(cv::xfeatures2d::LUCID::create(
1352 getFeature2D_LUCID_kernel(),
1353 getFeature2D_LUCID_blur_kernel()));
1355 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1357 else if(strategies.at(index).compare(
"LATCH") == 0)
1359 feature2D =
new Feature2D(cv::xfeatures2d::LATCH::create(
1360 getFeature2D_LATCH_bytes(),
1361 getFeature2D_LATCH_rotationInvariance(),
1362 getFeature2D_LATCH_half_ssd_size()));
1364 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1366 else if(strategies.at(index).compare(
"DAISY") == 0)
1368 feature2D =
new Feature2D(cv::xfeatures2d::DAISY::create(
1369 getFeature2D_DAISY_radius(),
1370 getFeature2D_DAISY_q_radius(),
1371 getFeature2D_DAISY_q_theta(),
1372 getFeature2D_DAISY_q_hist(),
1373 cv::xfeatures2d::DAISY::NRM_NONE,
1375 getFeature2D_DAISY_interpolation(),
1376 getFeature2D_DAISY_use_orientation()));
1378 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1381 #if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11))) 1382 #if FINDOBJECT_NONFREE == 1 1383 else if(strategies.at(index).compare(
"SIFT") == 0)
1385 #if CV_MAJOR_VERSION < 3 1386 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::SIFT(
1387 getFeature2D_SIFT_nfeatures(),
1388 getFeature2D_SIFT_nOctaveLayers(),
1389 getFeature2D_SIFT_contrastThreshold(),
1390 getFeature2D_SIFT_edgeThreshold(),
1391 getFeature2D_SIFT_sigma())));
1393 feature2D =
new Feature2D(cv::xfeatures2d::SIFT::create(
1394 getFeature2D_SIFT_nfeatures(),
1395 getFeature2D_SIFT_nOctaveLayers(),
1396 getFeature2D_SIFT_contrastThreshold(),
1397 getFeature2D_SIFT_edgeThreshold(),
1398 getFeature2D_SIFT_sigma()));
1400 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1402 else if(strategies.at(index).compare(
"SURF") == 0)
1404 if(getFeature2D_SURF_gpu() && CVCUDA::getCudaEnabledDeviceCount())
1406 feature2D =
new GPUSURF(
1407 getFeature2D_SURF_hessianThreshold(),
1408 getFeature2D_SURF_nOctaves(),
1409 getFeature2D_SURF_nOctaveLayers(),
1410 getFeature2D_SURF_extended(),
1411 getFeature2D_SURF_keypointsRatio(),
1412 getFeature2D_SURF_upright());
1413 UDEBUG(
"type=%s (GPU)", strategies.at(index).toStdString().c_str());
1417 #if CV_MAJOR_VERSION < 3 1418 feature2D =
new Feature2D(cv::Ptr<cv::Feature2D>(
new cv::SURF(
1419 getFeature2D_SURF_hessianThreshold(),
1420 getFeature2D_SURF_nOctaves(),
1421 getFeature2D_SURF_nOctaveLayers(),
1422 getFeature2D_SURF_extended(),
1423 getFeature2D_SURF_upright())));
1425 feature2D =
new Feature2D(cv::xfeatures2d::SURF::create(
1426 getFeature2D_SURF_hessianThreshold(),
1427 getFeature2D_SURF_nOctaves(),
1428 getFeature2D_SURF_nOctaveLayers(),
1429 getFeature2D_SURF_extended(),
1430 getFeature2D_SURF_upright()));
1432 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1436 #else // >= 4.3.0-dev 1437 else if(strategies.at(index).compare(
"SIFT") == 0)
1439 feature2D =
new Feature2D(cv::SIFT::create(
1440 getFeature2D_SIFT_nfeatures(),
1441 getFeature2D_SIFT_nOctaveLayers(),
1442 getFeature2D_SIFT_contrastThreshold(),
1443 getFeature2D_SIFT_edgeThreshold(),
1444 getFeature2D_SIFT_sigma()));
1445 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1447 #if FINDOBJECT_NONFREE == 1 1448 else if(strategies.at(index).compare(
"SURF") == 0)
1450 if(getFeature2D_SURF_gpu() && CVCUDA::getCudaEnabledDeviceCount())
1452 feature2D =
new GPUSURF(
1453 getFeature2D_SURF_hessianThreshold(),
1454 getFeature2D_SURF_nOctaves(),
1455 getFeature2D_SURF_nOctaveLayers(),
1456 getFeature2D_SURF_extended(),
1457 getFeature2D_SURF_keypointsRatio(),
1458 getFeature2D_SURF_upright());
1459 UDEBUG(
"type=%s (GPU)", strategies.at(index).toStdString().c_str());
1463 feature2D =
new Feature2D(cv::xfeatures2d::SURF::create(
1464 getFeature2D_SURF_hessianThreshold(),
1465 getFeature2D_SURF_nOctaves(),
1466 getFeature2D_SURF_nOctaveLayers(),
1467 getFeature2D_SURF_extended(),
1468 getFeature2D_SURF_upright()));
1469 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1475 #if FINDOBJECT_TORCH == 1 1476 else if(strategies.at(index).compare(
"SuperPointTorch") == 0)
1478 feature2D =
new SuperPointTorch(
1479 getFeature2D_SuperPointTorch_modelPath(),
1480 getFeature2D_SuperPointTorch_threshold(),
1481 getFeature2D_SuperPointTorch_NMS(),
1482 getFeature2D_SuperPointTorch_NMS_radius(),
1483 getFeature2D_SuperPointTorch_cuda());
1484 UDEBUG(
"type=%s", strategies.at(index).toStdString().c_str());
1496 int index = getFeature2D_1Detector().split(
':').first().toInt();
1497 return getFeature2D_1Detector().split(
':').last().split(
';').at(index);
1502 int index = getFeature2D_2Descriptor().split(
':').first().toInt();
1503 return getFeature2D_2Descriptor().split(
':').last().split(
';').at(index);
1508 int index = getNearestNeighbor_1Strategy().split(
':').first().toInt();
1509 return getNearestNeighbor_1Strategy().split(
':').last().split(
';').at(index);
1514 bool bruteForce =
false;
1515 QString str = getNearestNeighbor_1Strategy();
1516 QStringList split = str.split(
':');
1520 int index = split.first().toInt(&ok);
1523 QStringList strategies = split.last().split(
';');
1524 if(strategies.size() >= 7 && index == 6)
1535 cv::flann::IndexParams * params = 0;
1536 QString str = getNearestNeighbor_1Strategy();
1537 QStringList split = str.split(
':');
1541 int index = split.first().toInt(&ok);
1544 QStringList strategies = split.last().split(
';');
1545 if(strategies.size() >= 6 && index>=0 && index<6)
1550 if(strategies.at(index).compare(
"Linear") == 0)
1552 UDEBUG(
"type=%s",
"Linear");
1553 params =
new cv::flann::LinearIndexParams();
1557 if(strategies.at(index).compare(
"KDTree") == 0)
1559 UDEBUG(
"type=%s",
"KDTree");
1560 params =
new cv::flann::KDTreeIndexParams(
1561 getNearestNeighbor_KDTree_trees());
1565 if(strategies.at(index).compare(
"KMeans") == 0)
1567 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM;
1568 QString str = getNearestNeighbor_KMeans_centers_init();
1569 QStringList split = str.split(
':');
1573 int index = split.first().toInt(&ok);
1576 centers_init = (cvflann::flann_centers_init_t)index;
1579 UDEBUG(
"type=%s",
"KMeans");
1580 params =
new cv::flann::KMeansIndexParams(
1581 getNearestNeighbor_KMeans_branching(),
1582 getNearestNeighbor_KMeans_iterations(),
1584 getNearestNeighbor_KMeans_cb_index());
1588 if(strategies.at(index).compare(
"Composite") == 0)
1590 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM;
1591 QString str = getNearestNeighbor_Composite_centers_init();
1592 QStringList split = str.split(
':');
1596 int index = split.first().toInt(&ok);
1599 centers_init = (cvflann::flann_centers_init_t)index;
1602 UDEBUG(
"type=%s",
"Composite");
1603 params =
new cv::flann::CompositeIndexParams(
1604 getNearestNeighbor_Composite_trees(),
1605 getNearestNeighbor_Composite_branching(),
1606 getNearestNeighbor_Composite_iterations(),
1608 getNearestNeighbor_Composite_cb_index());
1612 if(strategies.at(index).compare(
"Autotuned") == 0)
1614 UDEBUG(
"type=%s",
"Autotuned");
1615 params =
new cv::flann::AutotunedIndexParams(
1616 getNearestNeighbor_Autotuned_target_precision(),
1617 getNearestNeighbor_Autotuned_build_weight(),
1618 getNearestNeighbor_Autotuned_memory_weight(),
1619 getNearestNeighbor_Autotuned_sample_fraction());
1623 if(strategies.at(index).compare(
"Lsh") == 0)
1625 UDEBUG(
"type=%s",
"Lsh");
1626 params =
new cv::flann::LshIndexParams(
1627 getNearestNeighbor_Lsh_table_number(),
1628 getNearestNeighbor_Lsh_key_size(),
1629 getNearestNeighbor_Lsh_multi_probe_level());
1641 UERROR(
"NN strategy not found !? Using default KDTRee...");
1642 params =
new cv::flann::KDTreeIndexParams();
1649 cvflann::flann_distance_t distance = cvflann::FLANN_DIST_L2;
1650 QString str = getNearestNeighbor_2Distance_type();
1651 QStringList split = str.split(
':');
1655 int index = split.first().toInt(&ok);
1658 QStringList strategies = split.last().split(
';');
1659 if(strategies.size() == 9 && index>=0 && index<=8)
1661 distance = (cvflann::flann_distance_t)(index+1);
1670 int method = cv::RANSAC;
1671 QString str = getHomography_method();
1672 QStringList split = str.split(
':');
1676 int index = split.first().toInt(&ok);
1679 QStringList strategies = split.last().split(
';');
1680 if(strategies.size() == 2 && index>=0 && index<2)
1684 #if CV_MAJOR_VERSION >= 3 1693 method = cv::RANSAC;
1699 UDEBUG(
"method=%d", method);
1703 #if CV_MAJOR_VERSION < 3 1705 featureDetector_(featureDetector)
1722 std::vector<cv::KeyPoint> & keypoints,
1723 const cv::Mat & mask)
1725 #if CV_MAJOR_VERSION < 3 1738 UERROR(
"Feature2D not set!?!?");
1743 std::vector<cv::KeyPoint> & keypoints,
1744 cv::Mat & descriptors)
1746 #if CV_MAJOR_VERSION < 3 1755 feature2D_->compute(image, keypoints, descriptors);
1759 UERROR(
"Feature2D not set!?!?");
1764 std::vector<cv::KeyPoint> & keypoints,
1765 cv::Mat & descriptors,
1766 const cv::Mat & mask)
1770 #if CV_MAJOR_VERSION < 3 1771 (*feature2D_)(image, mask, keypoints, descriptors);
1773 feature2D_->detectAndCompute(image, mask, keypoints, descriptors);
1778 UERROR(
"Cannot use Feature2D::detectAndCompute() if feature2D member is not set.");
static QString iniDefaultPath()
static cv::flann::IndexParams * createFlannIndexParams()
static int getHomographyMethod()
GPUORB(int nFeatures=Settings::defaultFeature2D_ORB_nFeatures(), float scaleFactor=Settings::defaultFeature2D_ORB_scaleFactor(), int nLevels=Settings::defaultFeature2D_ORB_nLevels(), int edgeThreshold=Settings::defaultFeature2D_ORB_edgeThreshold(), int firstLevel=Settings::defaultFeature2D_ORB_firstLevel(), int WTA_K=Settings::defaultFeature2D_ORB_WTA_K(), int scoreType=Settings::defaultFeature2D_ORB_scoreType(), int patchSize=Settings::defaultFeature2D_ORB_patchSize(), int fastThreshold=Settings::defaultFeature2D_Fast_threshold(), bool fastNonmaxSupression=Settings::defaultFeature2D_Fast_nonmaxSuppression())
static Feature2D * createKeypointDetector()
static QVariant getParameter(const QString &key)
virtual void detectAndCompute(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors, const cv::Mat &mask=cv::Mat())
static const ParametersType & getParametersType()
cv::Ptr< cv::FeatureDetector > featureDetector_
static ParametersType parametersType_
GPUFAST(int threshold=Settings::defaultFeature2D_Fast_threshold(), bool nonmaxSuppression=Settings::defaultFeature2D_Fast_nonmaxSuppression(), double keypointsRatio=Settings::defaultFeature2D_Fast_keypointsRatio())
static cvflann::flann_distance_t getFlannDistanceType()
static void loadWindowSettings(QByteArray &windowGeometry, QByteArray &windowState, const QString &fileName=QString())
#define UASSERT(condition)
static QString currentDetectorType()
static DescriptionsMap descriptions_
virtual void detect(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, const cv::Mat &mask=cv::Mat())
virtual void compute(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
virtual void detect(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, const cv::Mat &mask=cv::Mat())
virtual void detect(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, const cv::Mat &mask=cv::Mat())
QMap< QString, QString > ParametersType
static void setParameter(const QString &key, const QVariant &value)
QMap< QString, QVariant > ParametersMap
static QString currentDescriptorType()
static ParametersMap parameters_
static Settings dummyInit_
static ParametersMap loadSettings(const QString &fileName=QString())
virtual void detectAndCompute(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors, const cv::Mat &mask=cv::Mat())
QMap< QString, QString > DescriptionsMap
static void saveWindowSettings(const QByteArray &windowGeometry, const QByteArray &windowState, const QString &fileName=QString())
static QString workingDirectory()
static QString currentNearestNeighborType()
static bool isBruteForceNearestNeighbor()
virtual void compute(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
static QString iniDefaultFileName()
ULogger class and convenient macros.
static Feature2D * createDescriptorExtractor()
static ParametersMap defaultParameters_
virtual void compute(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
cv::Ptr< cv::DescriptorExtractor > descriptorExtractor_
cv::Ptr< cv::Feature2D > feature2D_
virtual void detectAndCompute(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors, const cv::Mat &mask=cv::Mat())
static ParametersMap init(const QString &fileName)
static void saveSettings(const QString &fileName=QString())