@@ -63,6 +63,7 @@ namespace opencv_test { namespace {
63
63
#define MESSAGE_RANSAC_DIFF " Reprojection error for current pair of points more than required."
64
64
65
65
#define MAX_COUNT_OF_POINTS 303
66
+ #define MIN_COUNT_OF_POINTS 4
66
67
#define COUNT_NORM_TYPES 3
67
68
#define METHODS_COUNT 4
68
69
@@ -249,7 +250,7 @@ void CV_HomographyTest::print_information_8(int _method, int j, int N, int k, in
249
250
250
251
void CV_HomographyTest::run (int )
251
252
{
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)
253
254
{
254
255
RNG& rng = ts->get_rng ();
255
256
@@ -711,4 +712,27 @@ TEST(Calib3d_Homography, fromImages)
711
712
ASSERT_GE (ninliers1, 80 );
712
713
}
713
714
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
+
714
738
}} // namespace
0 commit comments