Commit 0064bd51 authored by Vladimir Dudnik's avatar Vladimir Dudnik

cosmetic changes, removed trailing spaces

parent eedde649
...@@ -65,7 +65,7 @@ protected: ...@@ -65,7 +65,7 @@ protected:
CvSize img_size; CvSize img_size;
int count, count2; int count, count2;
IplImage *img[NUM_IMG]; IplImage* img[NUM_IMG];
CvMemStorage* storage; CvMemStorage* storage;
CvSeq *contours, *contours2, *chain; CvSeq *contours, *contours2, *chain;
}; };
...@@ -75,6 +75,7 @@ CV_FindContourTest::CV_FindContourTest() : ...@@ -75,6 +75,7 @@ CV_FindContourTest::CV_FindContourTest() :
CvTest( "contour-find", "cvFindContours, cvDrawContours, cvApproxChains" ) CvTest( "contour-find", "cvFindContours, cvDrawContours, cvApproxChains" )
{ {
int i; int i;
test_case_count = 300; test_case_count = 300;
min_blob_size = 1; min_blob_size = 1;
max_blob_size = 50; max_blob_size = 50;
...@@ -85,6 +86,7 @@ CV_FindContourTest::CV_FindContourTest() : ...@@ -85,6 +86,7 @@ CV_FindContourTest::CV_FindContourTest() :
for( i = 0; i < NUM_IMG; i++ ) for( i = 0; i < NUM_IMG; i++ )
img[i] = 0; img[i] = 0;
storage = 0; storage = 0;
} }
...@@ -97,10 +99,13 @@ CV_FindContourTest::~CV_FindContourTest() ...@@ -97,10 +99,13 @@ CV_FindContourTest::~CV_FindContourTest()
void CV_FindContourTest::clear() void CV_FindContourTest::clear()
{ {
CvTest::clear();
int i; int i;
CvTest::clear();
for( i = 0; i < NUM_IMG; i++ ) for( i = 0; i < NUM_IMG; i++ )
cvReleaseImage( &img[i] ); cvReleaseImage( &img[i] );
cvReleaseMemStorage( &storage ); cvReleaseMemStorage( &storage );
} }
...@@ -123,8 +128,8 @@ int CV_FindContourTest::write_default_params( CvFileStorage* fs ) ...@@ -123,8 +128,8 @@ int CV_FindContourTest::write_default_params( CvFileStorage* fs )
int CV_FindContourTest::read_params( CvFileStorage* fs ) int CV_FindContourTest::read_params( CvFileStorage* fs )
{ {
int code = CvTest::read_params( fs );
int t; int t;
int code = CvTest::read_params( fs );
if( code < 0 ) if( code < 0 )
return code; return code;
...@@ -137,6 +142,7 @@ int CV_FindContourTest::read_params( CvFileStorage* fs ) ...@@ -137,6 +142,7 @@ int CV_FindContourTest::read_params( CvFileStorage* fs )
min_blob_size = cvTsClipInt( min_blob_size, 1, 100 ); min_blob_size = cvTsClipInt( min_blob_size, 1, 100 );
max_blob_size = cvTsClipInt( max_blob_size, 1, 100 ); max_blob_size = cvTsClipInt( max_blob_size, 1, 100 );
if( min_blob_size > max_blob_size ) if( min_blob_size > max_blob_size )
CV_SWAP( min_blob_size, max_blob_size, t ); CV_SWAP( min_blob_size, max_blob_size, t );
...@@ -144,6 +150,7 @@ int CV_FindContourTest::read_params( CvFileStorage* fs ) ...@@ -144,6 +150,7 @@ int CV_FindContourTest::read_params( CvFileStorage* fs )
min_log_img_size = cvTsClipInt( min_log_img_size, 1, 10 ); min_log_img_size = cvTsClipInt( min_log_img_size, 1, 10 );
max_log_img_size = cvTsClipInt( max_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 ) if( min_log_img_size > max_log_img_size )
CV_SWAP( min_log_img_size, max_log_img_size, t ); 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, ...@@ -158,8 +165,11 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
{ {
int i; int i;
CvSize size; CvSize size;
assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 ); assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 );
cvZero( img ); cvZero( img );
// keep the border clear // keep the border clear
cvSetImageROI( img, cvRect(1,1,img->width-2,img->height-2) ); cvSetImageROI( img, cvRect(1,1,img->width-2,img->height-2) );
size = cvGetSize( img ); size = cvGetSize( img );
...@@ -173,6 +183,7 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size, ...@@ -173,6 +183,7 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
(max_brightness - min_brightness) + min_brightness; (max_brightness - min_brightness) + min_brightness;
center.x = cvTsRandInt(rng) % size.width; center.x = cvTsRandInt(rng) % size.width;
center.y = cvTsRandInt(rng) % size.height; center.y = cvTsRandInt(rng) % size.height;
axes.width = (cvTsRandInt(rng) % axes.width = (cvTsRandInt(rng) %
(max_blob_size - min_blob_size) + min_blob_size + 1)/2; (max_blob_size - min_blob_size) + min_blob_size + 1)/2;
axes.height = (cvTsRandInt(rng) % axes.height = (cvTsRandInt(rng) %
...@@ -192,6 +203,7 @@ cvTsMarkContours( IplImage* img, int val ) ...@@ -192,6 +203,7 @@ cvTsMarkContours( IplImage* img, int val )
int step = img->widthStep; int step = img->widthStep;
assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 && (val&1) != 0); assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 && (val&1) != 0);
for( i = 1; i < img->height - 1; i++ ) for( i = 1; i < img->height - 1; i++ )
for( j = 1; j < img->width - 1; j++ ) for( j = 1; j < img->width - 1; j++ )
{ {
...@@ -209,12 +221,14 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx ) ...@@ -209,12 +221,14 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx )
CvRNG* rng = ts->get_rng(); CvRNG* rng = ts->get_rng();
const int min_brightness = 0, max_brightness = 2; const int min_brightness = 0, max_brightness = 2;
int i, code = CvTest::prepare_test_case( test_case_idx ); int i, code = CvTest::prepare_test_case( test_case_idx );
if( code < 0 ) if( code < 0 )
return code; return code;
clear(); clear();
blob_count = cvRound(exp(cvTsRandReal(rng)*max_log_blob_count*CV_LOG2)); blob_count = cvRound(exp(cvTsRandReal(rng)*max_log_blob_count*CV_LOG2));
img_size.width = cvRound(exp((cvTsRandReal(rng)* img_size.width = cvRound(exp((cvTsRandReal(rng)*
(max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2)); (max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2));
img_size.height = cvRound(exp((cvTsRandReal(rng)* img_size.height = cvRound(exp((cvTsRandReal(rng)*
...@@ -230,8 +244,10 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx ) ...@@ -230,8 +244,10 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx )
cvTsGenerateBlobImage( img[0], min_blob_size, max_blob_size, cvTsGenerateBlobImage( img[0], min_blob_size, max_blob_size,
blob_count, min_brightness, max_brightness, rng ); blob_count, min_brightness, max_brightness, rng );
cvCopy( img[0], img[1] ); cvCopy( img[0], img[1] );
cvCopy( img[0], img[2] ); cvCopy( img[0], img[2] );
cvTsMarkContours( img[1], 255 ); cvTsMarkContours( img[1], 255 );
return 1; return 1;
...@@ -242,14 +258,21 @@ void CV_FindContourTest::run_func() ...@@ -242,14 +258,21 @@ void CV_FindContourTest::run_func()
{ {
contours = contours2 = chain = 0; contours = contours2 = chain = 0;
count = cvFindContours( img[2], storage, &contours, sizeof(CvContour), retr_mode, approx_method ); count = cvFindContours( img[2], storage, &contours, sizeof(CvContour), retr_mode, approx_method );
cvZero( img[3] ); cvZero( img[3] );
if( contours && retr_mode != CV_RETR_EXTERNAL && approx_method < CV_CHAIN_APPROX_TC89_L1 ) 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 ); cvDrawContours( img[3], contours, cvScalar(255), cvScalar(255), INT_MAX, -1 );
cvCopy( img[0], img[2] ); cvCopy( img[0], img[2] );
count2 = cvFindContours( img[2], storage, &chain, sizeof(CvChain), retr_mode, CV_CHAIN_CODE ); count2 = cvFindContours( img[2], storage, &chain, sizeof(CvChain), retr_mode, CV_CHAIN_CODE );
if( chain ) if( chain )
contours2 = cvApproxChains( chain, storage, approx_method, 0, 0, 1 ); contours2 = cvApproxChains( chain, storage, approx_method, 0, 0, 1 );
cvZero( img[2] ); cvZero( img[2] );
if( contours && retr_mode != CV_RETR_EXTERNAL && approx_method < CV_CHAIN_APPROX_TC89_L1 ) if( contours && retr_mode != CV_RETR_EXTERNAL && approx_method < CV_CHAIN_APPROX_TC89_L1 )
cvDrawContours( img[2], contours2, cvScalar(255), cvScalar(255), INT_MAX ); cvDrawContours( img[2], contours2, cvScalar(255), cvScalar(255), INT_MAX );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment