Skip to content

Commit cbf978d

Browse files
committed
added minPoints Homography test
1 parent 94e0ac7 commit cbf978d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

modules/calib3d/test/test_homography.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ namespace opencv_test { namespace {
6363
#define MESSAGE_RANSAC_DIFF "Reprojection error for current pair of points more than required."
6464

6565
#define MAX_COUNT_OF_POINTS 303
66+
#define MIN_COUNT_OF_POINTS 4
6667
#define COUNT_NORM_TYPES 3
6768
#define METHODS_COUNT 4
6869

@@ -249,7 +250,7 @@ void CV_HomographyTest::print_information_8(int _method, int j, int N, int k, in
249250

250251
void CV_HomographyTest::run(int)
251252
{
252-
for (int N = 4; N <= MAX_COUNT_OF_POINTS; ++N)
253+
for (int N = MIN_COUNT_OF_POINTS; N <= MAX_COUNT_OF_POINTS; ++N)
253254
{
254255
RNG& rng = ts->get_rng();
255256

@@ -711,4 +712,27 @@ TEST(Calib3d_Homography, fromImages)
711712
ASSERT_GE(ninliers1, 80);
712713
}
713714

715+
TEST(Calib3d_Homography, minPoints)
716+
{
717+
float pt1data[] =
718+
{
719+
2.80073029e+002f, 2.39591217e+002f, 2.21912201e+002f, 2.59783997e+002f
720+
};
721+
722+
float pt2data[] =
723+
{
724+
1.84072723e+002f, 1.43591202e+002f, 1.25912483e+002f, 1.63783859e+002f
725+
};
726+
727+
int npoints = (int)(sizeof(pt1data)/sizeof(pt1data[0])/2);
728+
printf("npoints = %d\n", npoints); // npoints = 2
729+
730+
Mat p1(1, npoints, CV_32FC2, pt1data);
731+
Mat p2(1, npoints, CV_32FC2, pt2data);
732+
Mat mask;
733+
734+
// findHomography should raise an error since npoints < MIN_COUNT_OF_POINTS
735+
EXPECT_THROW(findHomography(p1, p2, RANSAC, 0.01, mask), cv::Exception);
736+
}
737+
714738
}} // namespace

0 commit comments

Comments
 (0)