1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +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
View File
@@ -135,4 +135,14 @@ void CV_AgastTest::run( int )
TEST(Features2d_AGAST, regression) { CV_AgastTest test; test.safe_run(); }
TEST(Features2d_AGAST, invalidDetectorType)
{
Mat img = Mat::zeros(16, 16, CV_8UC1);
vector<KeyPoint> keypoints;
EXPECT_THROW(AGAST(img, keypoints, 10, true,
static_cast<AgastFeatureDetector::DetectorType>(-1)),
cv::Exception);
}
}} // namespace
+6
View File
@@ -105,4 +105,10 @@ void CV_BRISKTest::run( int )
TEST(Features2d_BRISK, regression) { CV_BRISKTest test; test.safe_run(); }
TEST(Features2d_BRISK, invalidCreateParameters)
{
EXPECT_THROW(BRISK::create(30, 3, 0.0f), cv::Exception);
EXPECT_THROW(BRISK::create(30, 3, -1.0f), cv::Exception);
}
}} // namespace
+10
View File
@@ -165,4 +165,14 @@ TEST(Features2d_FAST, noNMS)
ASSERT_EQ( 0, cvtest::norm(gt_kps, kps, NORM_L2));
}
TEST(Features2d_FAST, invalidDetectorType)
{
Mat img = Mat::zeros(16, 16, CV_8UC1);
vector<KeyPoint> keypoints;
EXPECT_THROW(FAST(img, keypoints, 10, true,
static_cast<FastFeatureDetector::DetectorType>(-1)),
cv::Exception);
}
}} // namespace
+11
View File
@@ -195,4 +195,15 @@ TEST(Features2D_ORB, MaskValue)
ASSERT_EQ(countNonZero(diff), 0);
}
TEST(Features2D_ORB, invalidCreateParameters)
{
EXPECT_THROW(ORB::create(500, 1.0f), cv::Exception);
EXPECT_THROW(ORB::create(500, 1.2f, 0), cv::Exception);
EXPECT_THROW(ORB::create(500, 1.2f, 8, 31, 0, 5), cv::Exception);
EXPECT_THROW(ORB::create(500, 1.2f, 8, 31, 0, 2,
static_cast<ORB::ScoreType>(-1)), cv::Exception);
EXPECT_THROW(ORB::create(500, 1.2f, 8, 31, 0, 2,
ORB::HARRIS_SCORE, 1), cv::Exception);
}
}} // namespace