mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
cosmetic changes, removed trailing spaces
This commit is contained in:
parent
eedde64902
commit
0064bd516b
@ -65,7 +65,7 @@ protected:
|
||||
CvSize img_size;
|
||||
int count, count2;
|
||||
|
||||
IplImage *img[NUM_IMG];
|
||||
IplImage* img[NUM_IMG];
|
||||
CvMemStorage* storage;
|
||||
CvSeq *contours, *contours2, *chain;
|
||||
};
|
||||
@ -75,6 +75,7 @@ CV_FindContourTest::CV_FindContourTest() :
|
||||
CvTest( "contour-find", "cvFindContours, cvDrawContours, cvApproxChains" )
|
||||
{
|
||||
int i;
|
||||
|
||||
test_case_count = 300;
|
||||
min_blob_size = 1;
|
||||
max_blob_size = 50;
|
||||
@ -85,6 +86,7 @@ CV_FindContourTest::CV_FindContourTest() :
|
||||
|
||||
for( i = 0; i < NUM_IMG; i++ )
|
||||
img[i] = 0;
|
||||
|
||||
storage = 0;
|
||||
}
|
||||
|
||||
@ -97,10 +99,13 @@ CV_FindContourTest::~CV_FindContourTest()
|
||||
|
||||
void CV_FindContourTest::clear()
|
||||
{
|
||||
CvTest::clear();
|
||||
int i;
|
||||
|
||||
CvTest::clear();
|
||||
|
||||
for( i = 0; i < NUM_IMG; i++ )
|
||||
cvReleaseImage( &img[i] );
|
||||
|
||||
cvReleaseMemStorage( &storage );
|
||||
}
|
||||
|
||||
@ -123,8 +128,8 @@ int CV_FindContourTest::write_default_params( CvFileStorage* fs )
|
||||
|
||||
int CV_FindContourTest::read_params( CvFileStorage* fs )
|
||||
{
|
||||
int code = CvTest::read_params( fs );
|
||||
int t;
|
||||
int code = CvTest::read_params( fs );
|
||||
|
||||
if( code < 0 )
|
||||
return code;
|
||||
@ -137,6 +142,7 @@ int CV_FindContourTest::read_params( CvFileStorage* fs )
|
||||
|
||||
min_blob_size = cvTsClipInt( min_blob_size, 1, 100 );
|
||||
max_blob_size = cvTsClipInt( max_blob_size, 1, 100 );
|
||||
|
||||
if( min_blob_size > max_blob_size )
|
||||
CV_SWAP( min_blob_size, max_blob_size, t );
|
||||
|
||||
@ -144,6 +150,7 @@ int CV_FindContourTest::read_params( CvFileStorage* fs )
|
||||
|
||||
min_log_img_size = cvTsClipInt( min_log_img_size, 1, 10 );
|
||||
max_log_img_size = cvTsClipInt( max_log_img_size, 1, 10 );
|
||||
|
||||
if( min_log_img_size > max_log_img_size )
|
||||
CV_SWAP( min_log_img_size, max_log_img_size, t );
|
||||
|
||||
@ -158,8 +165,11 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
|
||||
{
|
||||
int i;
|
||||
CvSize size;
|
||||
|
||||
assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 );
|
||||
|
||||
cvZero( img );
|
||||
|
||||
// keep the border clear
|
||||
cvSetImageROI( img, cvRect(1,1,img->width-2,img->height-2) );
|
||||
size = cvGetSize( img );
|
||||
@ -173,6 +183,7 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
|
||||
(max_brightness - min_brightness) + min_brightness;
|
||||
center.x = cvTsRandInt(rng) % size.width;
|
||||
center.y = cvTsRandInt(rng) % size.height;
|
||||
|
||||
axes.width = (cvTsRandInt(rng) %
|
||||
(max_blob_size - min_blob_size) + min_blob_size + 1)/2;
|
||||
axes.height = (cvTsRandInt(rng) %
|
||||
@ -192,6 +203,7 @@ cvTsMarkContours( IplImage* img, int val )
|
||||
int step = img->widthStep;
|
||||
|
||||
assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 && (val&1) != 0);
|
||||
|
||||
for( i = 1; i < img->height - 1; i++ )
|
||||
for( j = 1; j < img->width - 1; j++ )
|
||||
{
|
||||
@ -209,12 +221,14 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx )
|
||||
CvRNG* rng = ts->get_rng();
|
||||
const int min_brightness = 0, max_brightness = 2;
|
||||
int i, code = CvTest::prepare_test_case( test_case_idx );
|
||||
|
||||
if( code < 0 )
|
||||
return code;
|
||||
|
||||
clear();
|
||||
|
||||
blob_count = cvRound(exp(cvTsRandReal(rng)*max_log_blob_count*CV_LOG2));
|
||||
|
||||
img_size.width = cvRound(exp((cvTsRandReal(rng)*
|
||||
(max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2));
|
||||
img_size.height = cvRound(exp((cvTsRandReal(rng)*
|
||||
@ -230,8 +244,10 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
cvTsGenerateBlobImage( img[0], min_blob_size, max_blob_size,
|
||||
blob_count, min_brightness, max_brightness, rng );
|
||||
|
||||
cvCopy( img[0], img[1] );
|
||||
cvCopy( img[0], img[2] );
|
||||
|
||||
cvTsMarkContours( img[1], 255 );
|
||||
|
||||
return 1;
|
||||
@ -242,14 +258,21 @@ void CV_FindContourTest::run_func()
|
||||
{
|
||||
contours = contours2 = chain = 0;
|
||||
count = cvFindContours( img[2], storage, &contours, sizeof(CvContour), retr_mode, approx_method );
|
||||
|
||||
cvZero( img[3] );
|
||||
|
||||
if( contours && retr_mode != CV_RETR_EXTERNAL && approx_method < CV_CHAIN_APPROX_TC89_L1 )
|
||||
cvDrawContours( img[3], contours, cvScalar(255), cvScalar(255), INT_MAX, -1 );
|
||||
|
||||
cvCopy( img[0], img[2] );
|
||||
|
||||
count2 = cvFindContours( img[2], storage, &chain, sizeof(CvChain), retr_mode, CV_CHAIN_CODE );
|
||||
|
||||
if( chain )
|
||||
contours2 = cvApproxChains( chain, storage, approx_method, 0, 0, 1 );
|
||||
|
||||
cvZero( img[2] );
|
||||
|
||||
if( contours && retr_mode != CV_RETR_EXTERNAL && approx_method < CV_CHAIN_APPROX_TC89_L1 )
|
||||
cvDrawContours( img[2], contours2, cvScalar(255), cvScalar(255), INT_MAX );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user