Commit e9e9e00d authored by Konstantin Matskevich's avatar Konstantin Matskevich

replaced sprintf with cv::format

parent ab18c2d1
...@@ -290,8 +290,8 @@ int CV_CameraCalibrationTest::compare(double* val, double* ref_val, int len, ...@@ -290,8 +290,8 @@ int CV_CameraCalibrationTest::compare(double* val, double* ref_val, int len,
void CV_CameraCalibrationTest::run( int start_from ) void CV_CameraCalibrationTest::run( int start_from )
{ {
int code = cvtest::TS::OK; int code = cvtest::TS::OK;
char filepath[200]; cv::String filepath;
char filename[200]; cv::String filename;
CvSize imageSize; CvSize imageSize;
CvSize etalonSize; CvSize etalonSize;
...@@ -337,12 +337,12 @@ void CV_CameraCalibrationTest::run( int start_from ) ...@@ -337,12 +337,12 @@ void CV_CameraCalibrationTest::run( int start_from )
int progress = 0; int progress = 0;
int values_read = -1; int values_read = -1;
sprintf( filepath, "%scv/cameracalibration/", ts->get_data_path().c_str() ); filepath = cv::format("%scv/cameracalibration/", ts->get_data_path().c_str() );
sprintf( filename, "%sdatafiles.txt", filepath ); filename = cv::format("%sdatafiles.txt", filepath.c_str() );
datafile = fopen( filename, "r" ); datafile = fopen( filename.c_str(), "r" );
if( datafile == 0 ) if( datafile == 0 )
{ {
ts->printf( cvtest::TS::LOG, "Could not open file with list of test files: %s\n", filename ); ts->printf( cvtest::TS::LOG, "Could not open file with list of test files: %s\n", filename.c_str() );
code = cvtest::TS::FAIL_MISSING_TEST_DATA; code = cvtest::TS::FAIL_MISSING_TEST_DATA;
goto _exit_; goto _exit_;
} }
...@@ -354,15 +354,15 @@ void CV_CameraCalibrationTest::run( int start_from ) ...@@ -354,15 +354,15 @@ void CV_CameraCalibrationTest::run( int start_from )
{ {
values_read = fscanf(datafile,"%s",i_dat_file); values_read = fscanf(datafile,"%s",i_dat_file);
CV_Assert(values_read == 1); CV_Assert(values_read == 1);
sprintf(filename, "%s%s", filepath, i_dat_file); filename = cv::format("%s%s", filepath.c_str(), i_dat_file);
file = fopen(filename,"r"); file = fopen(filename.c_str(),"r");
ts->update_context( this, currTest, true ); ts->update_context( this, currTest, true );
if( file == 0 ) if( file == 0 )
{ {
ts->printf( cvtest::TS::LOG, ts->printf( cvtest::TS::LOG,
"Can't open current test file: %s\n",filename); "Can't open current test file: %s\n",filename.c_str());
if( numTests == 1 ) if( numTests == 1 )
{ {
code = cvtest::TS::FAIL_MISSING_TEST_DATA; code = cvtest::TS::FAIL_MISSING_TEST_DATA;
...@@ -1382,16 +1382,16 @@ void CV_StereoCalibrationTest::run( int ) ...@@ -1382,16 +1382,16 @@ void CV_StereoCalibrationTest::run( int )
for(int testcase = 1; testcase <= ntests; testcase++) for(int testcase = 1; testcase <= ntests; testcase++)
{ {
char filepath[1000]; cv::String filepath;
char buf[1000]; char buf[1000];
sprintf( filepath, "%scv/stereo/case%d/stereo_calib.txt", ts->get_data_path().c_str(), testcase ); filepath = cv::format("%scv/stereo/case%d/stereo_calib.txt", ts->get_data_path().c_str(), testcase );
f = fopen(filepath, "rt"); f = fopen(filepath.c_str(), "rt");
Size patternSize; Size patternSize;
vector<string> imglist; vector<string> imglist;
if( !f || !fgets(buf, sizeof(buf)-3, f) || sscanf(buf, "%d%d", &patternSize.width, &patternSize.height) != 2 ) if( !f || !fgets(buf, sizeof(buf)-3, f) || sscanf(buf, "%d%d", &patternSize.width, &patternSize.height) != 2 )
{ {
ts->printf( cvtest::TS::LOG, "The file %s can not be opened or has invalid content\n", filepath ); ts->printf( cvtest::TS::LOG, "The file %s can not be opened or has invalid content\n", filepath.c_str() );
ts->set_failed_test_info( f ? cvtest::TS::FAIL_INVALID_TEST_DATA : cvtest::TS::FAIL_MISSING_TEST_DATA ); ts->set_failed_test_info( f ? cvtest::TS::FAIL_INVALID_TEST_DATA : cvtest::TS::FAIL_MISSING_TEST_DATA );
return; return;
} }
...@@ -1405,7 +1405,7 @@ void CV_StereoCalibrationTest::run( int ) ...@@ -1405,7 +1405,7 @@ void CV_StereoCalibrationTest::run( int )
buf[--len] = '\0'; buf[--len] = '\0';
if( buf[0] == '#') if( buf[0] == '#')
continue; continue;
sprintf(filepath, "%scv/stereo/case%d/%s", ts->get_data_path().c_str(), testcase, buf ); filepath = cv::format("%scv/stereo/case%d/%s", ts->get_data_path().c_str(), testcase, buf );
imglist.push_back(string(filepath)); imglist.push_back(string(filepath));
} }
fclose(f); fclose(f);
......
...@@ -62,8 +62,8 @@ void CV_ChessboardDetectorTimingTest::run( int start_from ) ...@@ -62,8 +62,8 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
int code = cvtest::TS::OK; int code = cvtest::TS::OK;
/* test parameters */ /* test parameters */
char filepath[1000]; std::string filepath;
char filename[1000]; std::string filename;
CvMat* _v = 0; CvMat* _v = 0;
CvPoint2D32f* v; CvPoint2D32f* v;
...@@ -75,9 +75,9 @@ void CV_ChessboardDetectorTimingTest::run( int start_from ) ...@@ -75,9 +75,9 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
int idx, max_idx; int idx, max_idx;
int progress = 0; int progress = 0;
sprintf( filepath, "%scv/cameracalibration/", ts->get_data_path().c_str() ); filepath = cv::format("%scv/cameracalibration/", ts->get_data_path().c_str() );
sprintf( filename, "%schessboard_timing_list.dat", filepath ); filename = cv::format("%schessboard_timing_list.dat", filepath.c_str() );
CvFileStorage* fs = cvOpenFileStorage( filename, 0, CV_STORAGE_READ ); CvFileStorage* fs = cvOpenFileStorage( filename.c_str(), 0, CV_STORAGE_READ );
CvFileNode* board_list = fs ? cvGetFileNodeByName( fs, 0, "boards" ) : 0; CvFileNode* board_list = fs ? cvGetFileNodeByName( fs, 0, "boards" ) : 0;
if( !fs || !board_list || !CV_NODE_IS_SEQ(board_list->tag) || if( !fs || !board_list || !CV_NODE_IS_SEQ(board_list->tag) ||
...@@ -105,14 +105,14 @@ void CV_ChessboardDetectorTimingTest::run( int start_from ) ...@@ -105,14 +105,14 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
ts->update_context( this, idx-1, true ); ts->update_context( this, idx-1, true );
/* read the image */ /* read the image */
sprintf( filename, "%s%s", filepath, imgname ); filename = cv::format("%s%s", filepath.c_str(), imgname );
cv::Mat img2 = cv::imread( filename ); cv::Mat img2 = cv::imread( filename );
img = img2; img = img2;
if( img2.empty() ) if( img2.empty() )
{ {
ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename ); ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename.c_str() );
if( max_idx == 1 ) if( max_idx == 1 )
{ {
code = cvtest::TS::FAIL_MISSING_TEST_DATA; code = cvtest::TS::FAIL_MISSING_TEST_DATA;
......
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