Skip to content

Commit dcf4cd3

Browse files
committed
Allow control of minimum required features and RANSAC threshold in feature detector.
1 parent 75a697d commit dcf4cd3

File tree

6 files changed

+61
-13
lines changed

6 files changed

+61
-13
lines changed

Source/ARX/ARTracker2d.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,5 +428,25 @@ PlanarTracker::FeatureDetectorType ARTracker2d::getDetectorType(void)
428428
return m_2DTracker->GetFeatureDetector();
429429
}
430430

431+
void ARTracker2d::setMinRequiredDetectedFeatures(int num)
432+
{
433+
m_2DTracker->SetMinRequiredDetectedFeatures(num);
434+
}
435+
436+
int ARTracker2d::getMinRequiredDetectedFeatures(void)
437+
{
438+
return m_2DTracker->GetMinRequiredDetectedFeatures();
439+
}
440+
441+
void ARTracker2d::setHomographyEstimationRANSACThreshold(double thresh)
442+
{
443+
m_2DTracker->SetHomographyEstimationRANSACThreshold(thresh);
444+
}
445+
446+
double ARTracker2d::getHomographyEstimationRANSACThreshold(void)
447+
{
448+
return m_2DTracker->GetHomographyEstimationRANSACThreshold();
449+
}
450+
431451
#endif // HAVE_2D
432452

Source/ARX/OCVT/OCVConfig.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
#include "OCVConfig.h"
3838

3939
int minRequiredDetectedFeatures = 50; ///< Minimum number of detected features required to consider a target matched.
40-
int markerTemplateWidth = 15;
41-
int maxLevel = 3; ///< Maximum number of levels in optical flow image pyramid.
40+
const int markerTemplateWidth = 15; ///< Width in pixels of image patches used in template matching.
41+
const int maxLevel = 3; ///< Maximum number of levels in optical flow image pyramid.
4242
const cv::Size subPixWinSize(10,10);
4343
const cv::Size winSize(31,31); ///< Window size to use in optical flow search.
4444
cv::TermCriteria termcrit(cv::TermCriteria::COUNT|cv::TermCriteria::EPS,20,0.03);
4545
const int featureDetectMaxFeatures = 300;
46-
int searchRadius = 15;
47-
int match_method = cv::TM_SQDIFF_NORMED;
46+
const int searchRadius = 15;
47+
const int match_method = cv::TM_SQDIFF_NORMED;
4848
const cv::Size featureImageMinSize(640, 480); ///< Minimum size when downscaling incoming images used for feature tracking.
4949
PlanarTracker::FeatureDetectorType defaultDetectorType = PlanarTracker::FeatureDetectorType::Akaze;
5050
const double nn_match_ratio = 0.8f; ///< Nearest-neighbour matching ratio
51-
const double ransac_thresh = 2.5f; ///< RANSAC inlier threshold
51+
double ransac_thresh = 2.5f; ///< RANSAC inlier threshold
5252
cv::RNG rng( 0xFFFFFFFF );
53-
int harrisBorder = 10;
53+
const int harrisBorder = 10; ///< Harris corners within this many pixels of the border of the image will be ignored.

Source/ARX/OCVT/OCVConfig.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@
6262
#include <ARX/OCVT/PlanarTracker.h>
6363

6464
OCV_EXTERN extern int minRequiredDetectedFeatures; ///< Minimum number of detected features required to consider a target matched.
65-
OCV_EXTERN extern int markerTemplateWidth;
66-
OCV_EXTERN extern int maxLevel; ///< Maximum number of levels in optical flow image pyramid.
65+
OCV_EXTERN extern const int markerTemplateWidth; ///< Width in pixels of image patches used in template matching.
66+
OCV_EXTERN extern const int maxLevel; ///< Maximum number of levels in optical flow image pyramid.
6767
OCV_EXTERN extern const cv::Size subPixWinSize;
68-
OCV_EXTERN extern const cv::Size winSize;
68+
OCV_EXTERN extern const cv::Size winSize; ///< Window size to use in optical flow search.
6969
OCV_EXTERN extern cv::TermCriteria termcrit;
7070
OCV_EXTERN extern const int featureDetectMaxFeatures;
71-
OCV_EXTERN extern int searchRadius;
72-
OCV_EXTERN extern int match_method;
71+
OCV_EXTERN extern const int searchRadius;
72+
OCV_EXTERN extern const int match_method;
7373
OCV_EXTERN extern const cv::Size featureImageMinSize; ///< Minimum size when downscaling incoming images used for feature tracking.
7474
OCV_EXTERN extern PlanarTracker::FeatureDetectorType defaultDetectorType;
7575
OCV_EXTERN extern const double nn_match_ratio; ///< Nearest-neighbour matching ratio
76-
OCV_EXTERN extern const double ransac_thresh; ///< RANSAC inlier threshold
76+
OCV_EXTERN extern double ransac_thresh; ///< RANSAC inlier threshold
7777
OCV_EXTERN extern cv::RNG rng;
78-
OCV_EXTERN extern int harrisBorder; ///< Harris corners within this many pixels of the border of the image will be ignored.
78+
OCV_EXTERN extern const int harrisBorder; ///< Harris corners within this many pixels of the border of the image will be ignored.
7979

8080
#endif // OCV_CONFIG_H

Source/ARX/OCVT/PlanarTracker.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,26 @@ PlanarTracker::FeatureDetectorType PlanarTracker::GetFeatureDetector(void)
793793
return _trackerImpl->GetFeatureDetector();
794794
}
795795

796+
void PlanarTracker::SetMinRequiredDetectedFeatures(int num)
797+
{
798+
minRequiredDetectedFeatures = num; // OCVConfig
799+
}
800+
801+
int PlanarTracker::GetMinRequiredDetectedFeatures(void)
802+
{
803+
return minRequiredDetectedFeatures; // OCVConfig
804+
}
805+
806+
void PlanarTracker::SetHomographyEstimationRANSACThreshold(double thresh)
807+
{
808+
ransac_thresh = thresh; // OCVConfig
809+
}
810+
811+
double PlanarTracker::GetHomographyEstimationRANSACThreshold(void)
812+
{
813+
return ransac_thresh; // OCVConfig
814+
}
815+
796816
void PlanarTracker::SetMaximumNumberOfMarkersToTrack(int maximumNumberOfMarkersToTrack)
797817
{
798818
_trackerImpl->SetMaximumNumberOfMarkersToTrack(maximumNumberOfMarkersToTrack);

Source/ARX/OCVT/include/ARX/OCVT/PlanarTracker.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class PlanarTracker
102102
};
103103
void SetFeatureDetector(FeatureDetectorType detectorType);
104104
FeatureDetectorType GetFeatureDetector(void);
105+
void SetMinRequiredDetectedFeatures(int num);
106+
int GetMinRequiredDetectedFeatures(void);
107+
void SetHomographyEstimationRANSACThreshold(double thresh);
108+
double GetHomographyEstimationRANSACThreshold(void);
105109

106110
void SetMaximumNumberOfMarkersToTrack(int maximumNumberOfMarkersToTrack);
107111
int GetMaximumNumberOfMarkersToTrack(void);

Source/ARX/include/ARX/ARTracker2d.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ class ARTracker2d : public ARTrackerVideo {
9191

9292
void setDetectorType(PlanarTracker::FeatureDetectorType detectorType);
9393
PlanarTracker::FeatureDetectorType getDetectorType(void);
94+
void setMinRequiredDetectedFeatures(int num);
95+
int getMinRequiredDetectedFeatures(void);
96+
void setHomographyEstimationRANSACThreshold(double thresh);
97+
double getHomographyEstimationRANSACThreshold(void);
9498

9599
bool threaded(void) const;
96100
/// \brief Enable or disable running the 2D tracking task in a separate thread. See caveats in detailed description.

0 commit comments

Comments
 (0)