1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

features2d: improve detector parameter validation

This commit is contained in:
Primary-H
2026-05-31 23:40:50 +08:00
parent ebb46d5f17
commit a7bb1d1e1e
9 changed files with 72 additions and 4 deletions
+10 -2
View File
@@ -441,6 +441,14 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
{
CV_INSTRUMENT_REGION();
if (type != FastFeatureDetector::TYPE_5_8 &&
type != FastFeatureDetector::TYPE_7_12 &&
type != FastFeatureDetector::TYPE_9_16)
{
CV_Error_(Error::StsBadArg,
("Unknown FastFeatureDetector detector type: %d", static_cast<int>(type)));
}
const size_t max_fast_features = std::max(_img.total()/100, size_t(1000)); // Simple heuristic that depends on resolution.
CV_OCL_RUN(_img.isUMat() && type == FastFeatureDetector::TYPE_9_16,
@@ -549,7 +557,7 @@ public:
else if(prop == FAST_N)
type = static_cast<FastFeatureDetector::DetectorType>(cvRound(value));
else
CV_Error(Error::StsBadArg, "");
CV_Error_(Error::StsBadArg, ("Unknown FastFeatureDetector property: %d", prop));
}
double get(int prop) const
@@ -560,7 +568,7 @@ public:
return nonmaxSuppression;
if(prop == FAST_N)
return static_cast<int>(type);
CV_Error(Error::StsBadArg, "");
CV_Error_(Error::StsBadArg, ("Unknown FastFeatureDetector property: %d", prop));
return 0;
}