From 5bb08bae2884a85d42626d8af1584e59b0246282 Mon Sep 17 00:00:00 2001 From: Juha Reunanen Date: Mon, 14 Nov 2016 15:31:29 +0200 Subject: [PATCH] Merge pull request #7464 from reunanen:test-7409-7458 Change contour test images to be very wide (#7464) * Change contour test images to be very wide (#7409, #7458) Unfortunately, slows down the tests. * Decrease the number of contour test cases, in order to (at least partially) offset the test run duration increase caused by making the test images wider * Don't test with very wide images on 32-bit architectures --- modules/imgproc/test/test_contours.cpp | 45 +++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/modules/imgproc/test/test_contours.cpp b/modules/imgproc/test/test_contours.cpp index 851ec2c..7b0eafb 100644 --- a/modules/imgproc/test/test_contours.cpp +++ b/modules/imgproc/test/test_contours.cpp @@ -63,13 +63,24 @@ protected: int blob_count, max_log_blob_count; int retr_mode, approx_method; - int min_log_img_size, max_log_img_size; + int min_log_img_width, max_log_img_width; + int min_log_img_height, max_log_img_height; CvSize img_size; int count, count2; IplImage* img[NUM_IMG]; CvMemStorage* storage; CvSeq *contours, *contours2, *chain; + + static const bool useVeryWideImages = +#if SIZE_MAX <= 0xffffffff + // 32-bit: don't even try the very wide images + false +#else + // 64-bit: test with very wide images + true +#endif + ; }; @@ -77,13 +88,16 @@ CV_FindContourTest::CV_FindContourTest() { int i; - test_case_count = 300; + test_case_count = useVeryWideImages ? 10 : 300; min_blob_size = 1; max_blob_size = 50; max_log_blob_count = 10; - min_log_img_size = 3; - max_log_img_size = 10; + min_log_img_width = useVeryWideImages ? 17 : 3; + max_log_img_width = useVeryWideImages ? 17 : 10; + + min_log_img_height = 3; + max_log_img_height = 10; for( i = 0; i < NUM_IMG; i++ ) img[i] = 0; @@ -122,8 +136,10 @@ int CV_FindContourTest::read_params( CvFileStorage* fs ) min_blob_size = cvReadInt( find_param( fs, "min_blob_size" ), min_blob_size ); max_blob_size = cvReadInt( find_param( fs, "max_blob_size" ), max_blob_size ); max_log_blob_count = cvReadInt( find_param( fs, "max_log_blob_count" ), max_log_blob_count ); - min_log_img_size = cvReadInt( find_param( fs, "min_log_img_size" ), min_log_img_size ); - max_log_img_size = cvReadInt( find_param( fs, "max_log_img_size" ), max_log_img_size ); + min_log_img_width = cvReadInt( find_param( fs, "min_log_img_width" ), min_log_img_width ); + max_log_img_width = cvReadInt( find_param( fs, "max_log_img_width" ), max_log_img_width ); + min_log_img_height = cvReadInt( find_param( fs, "min_log_img_height"), min_log_img_height ); + max_log_img_height = cvReadInt( find_param( fs, "max_log_img_height"), max_log_img_height ); min_blob_size = cvtest::clipInt( min_blob_size, 1, 100 ); max_blob_size = cvtest::clipInt( max_blob_size, 1, 100 ); @@ -133,11 +149,16 @@ int CV_FindContourTest::read_params( CvFileStorage* fs ) max_log_blob_count = cvtest::clipInt( max_log_blob_count, 1, 10 ); - min_log_img_size = cvtest::clipInt( min_log_img_size, 1, 10 ); - max_log_img_size = cvtest::clipInt( max_log_img_size, 1, 10 ); + min_log_img_width = cvtest::clipInt( min_log_img_width, 1, useVeryWideImages ? 17 : 10 ); + min_log_img_width = cvtest::clipInt( max_log_img_width, 1, useVeryWideImages ? 17 : 10 ); + min_log_img_height = cvtest::clipInt( min_log_img_height, 1, 10 ); + min_log_img_height = cvtest::clipInt( max_log_img_height, 1, 10 ); + + if( min_log_img_width > max_log_img_width ) + std::swap( min_log_img_width, max_log_img_width ); - if( min_log_img_size > max_log_img_size ) - CV_SWAP( min_log_img_size, max_log_img_size, t ); + if (min_log_img_height > max_log_img_height) + std::swap(min_log_img_height, max_log_img_height); return 0; } @@ -215,9 +236,9 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx ) blob_count = cvRound(exp(cvtest::randReal(rng)*max_log_blob_count*CV_LOG2)); img_size.width = cvRound(exp((cvtest::randReal(rng)* - (max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2)); + (max_log_img_width - min_log_img_width) + min_log_img_width)*CV_LOG2)); img_size.height = cvRound(exp((cvtest::randReal(rng)* - (max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2)); + (max_log_img_height - min_log_img_height) + min_log_img_height)*CV_LOG2)); approx_method = cvtest::randInt( rng ) % 4 + 1; retr_mode = cvtest::randInt( rng ) % 4; -- 2.7.4