From 670fff5f428e1e8a727be8ff0e86eca671c6b080 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Fri, 16 Jul 2010 14:16:18 +0000 Subject: [PATCH] added workaround for strange tmpnam() output from VS2010. turned off optimization for DCT & DFT on Win64 for VS200x (VS2010 builds it fine) --- modules/core/src/dxt.cpp | 4 +-- modules/highgui/src/loadsave.cpp | 4 +++ tests/cv/src/anearestneighbors.cpp | 1 + tests/cv/src/highguitest.cpp | 2 +- tests/cxcore/src/adxt.cpp | 4 +-- tests/cxcore/src/aio.cpp | 2 ++ tests/ml/src/slmltests.cpp | 40 ++++++++++++++++-------------- 7 files changed, 34 insertions(+), 23 deletions(-) diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index d7f0c89703..60ebe72fce 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -44,8 +44,8 @@ namespace cv { -// On Win64 (IA64) optimized versions of DFT and DCT fail the tests -#if defined WIN64 && !defined EM64T +// On Win64 optimized versions of DFT and DCT fail the tests (fixed in VS2010) +#if (defined WIN64 || defined _WIN64) && defined _MSC_VER && _MSC_VER < 1600 #pragma optimize("", off) #endif diff --git a/modules/highgui/src/loadsave.cpp b/modules/highgui/src/loadsave.cpp index 977bfd2cc8..ff823860bf 100644 --- a/modules/highgui/src/loadsave.cpp +++ b/modules/highgui/src/loadsave.cpp @@ -318,6 +318,8 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) if( !decoder->setSource(buf) ) { filename = tmpnam(fnamebuf); + if(filename[0] == '\\') + filename++; FILE* f = fopen( filename, "wb" ); if( !f ) return 0; @@ -425,6 +427,8 @@ bool imencode( const string& ext, const Mat& image, { char fnamebuf[L_tmpnam]; const char* filename = tmpnam(fnamebuf); + if(filename[0] == '\\') + filename++; code = encoder->setDestination(filename); CV_Assert( code ); code = encoder->write(image, params); diff --git a/tests/cv/src/anearestneighbors.cpp b/tests/cv/src/anearestneighbors.cpp index 5bc9904d2f..0b3659982d 100644 --- a/tests/cv/src/anearestneighbors.cpp +++ b/tests/cv/src/anearestneighbors.cpp @@ -507,6 +507,7 @@ void CV_FlannSavedIndexTest::createModel(const cv::Mat &data) } char filename[50]; tmpnam( filename ); + if(filename[0] == '\\') filename[0] = '_'; index->save( filename ); createIndex( data, SavedIndexParams(filename)); diff --git a/tests/cv/src/highguitest.cpp b/tests/cv/src/highguitest.cpp index ed8ca6c3dd..a63004abea 100644 --- a/tests/cv/src/highguitest.cpp +++ b/tests/cv/src/highguitest.cpp @@ -67,7 +67,7 @@ using namespace std; struct TempDirHolder { const string temp_folder; - TempDirHolder() : temp_folder(tmpnam(0)) {exec_cmd("mkdir " + temp_folder); } + TempDirHolder() { char* p = tmpnam(0); if(p[0] == '\\') p++; temp_folder = p; exec_cmd("mkdir " + temp_folder); } ~TempDirHolder() { exec_cmd("rm -rf " + temp_folder); } static void exec_cmd(const string& cmd) { marker(cmd); int res = system( cmd.c_str() ); (void)res; } diff --git a/tests/cxcore/src/adxt.cpp b/tests/cxcore/src/adxt.cpp index 484c2fcec4..6f9783e52b 100644 --- a/tests/cxcore/src/adxt.cpp +++ b/tests/cxcore/src/adxt.cpp @@ -829,7 +829,7 @@ void CxCore_DFTTest::prepare_to_validation( int /*test_case_idx*/ ) } -//CxCore_DFTTest dft_test; +CxCore_DFTTest dft_test; ////////////////////// DCT //////////////////////// @@ -876,7 +876,7 @@ void CxCore_DCTTest::prepare_to_validation( int /*test_case_idx*/ ) } -//CxCore_DCTTest dct_test; +CxCore_DCTTest dct_test; ////////////////////// MulSpectrums //////////////////////// diff --git a/tests/cxcore/src/aio.cpp b/tests/cxcore/src/aio.cpp index ff9d7f2f5d..2ca6a51d25 100644 --- a/tests/cxcore/src/aio.cpp +++ b/tests/cxcore/src/aio.cpp @@ -156,6 +156,8 @@ void CV_IOTest::run( int ) char buf[L_tmpnam+16]; char* filename = tmpnam(buf); strcat(filename, idx % 2 ? ".yml" : ".xml"); + if(filename[0] == '\\') + filename++; FileStorage fs(filename, FileStorage::WRITE); diff --git a/tests/ml/src/slmltests.cpp b/tests/ml/src/slmltests.cpp index 8b3d264698..5d7500a499 100644 --- a/tests/ml/src/slmltests.cpp +++ b/tests/ml/src/slmltests.cpp @@ -51,7 +51,7 @@ CV_SLMLTest::CV_SLMLTest( const char* _modelName, const char* _testName ) : int CV_SLMLTest::run_test_case( int testCaseIdx ) { - int code = CvTS::OK; + int code = CvTS::OK; code = prepare_test_case( testCaseIdx ); if( code == CvTS::OK ) @@ -61,10 +61,14 @@ int CV_SLMLTest::run_test_case( int testCaseIdx ) if( code == CvTS::OK ) { get_error( testCaseIdx, CV_TEST_ERROR, &test_resps1 ); - save( tmpnam( fname1 ) ); + tmpnam(fname1); + if(fname1[0] == '\\') fname1[0] = '_'; + save( fname1 ); load( fname1); get_error( testCaseIdx, CV_TEST_ERROR, &test_resps2 ); - save( tmpnam( fname2 ) ); + tmpnam(fname2); + if(fname2[0] == '\\') fname2[0] = '_'; + save( fname2 ); } else ts->printf( CvTS::LOG, "model can not be trained" ); @@ -87,15 +91,15 @@ int CV_SLMLTest::validate_test_results( int testCaseIdx ) getline( f2, s2 ); if( s1.compare(s2) ) { - ts->printf( CvTS::LOG, "first and second saved files differ in %n-line; first %n line: %s; second %n-line: %s", - lineIdx, lineIdx, s1.c_str(), lineIdx, s2.c_str() ); + ts->printf( CvTS::LOG, "first and second saved files differ in %n-line; first %n line: %s; second %n-line: %s", + lineIdx, lineIdx, s1.c_str(), lineIdx, s2.c_str() ); code = CvTS::FAIL_INVALID_OUTPUT; } } if( !f1.eof() || !f2.eof() ) { - ts->printf( CvTS::LOG, "in test case %d first and second saved files differ in %n-line; first %n line: %s; second %n-line: %s", - testCaseIdx, lineIdx, lineIdx, s1.c_str(), lineIdx, s2.c_str() ); + ts->printf( CvTS::LOG, "in test case %d first and second saved files differ in %n-line; first %n line: %s; second %n-line: %s", + testCaseIdx, lineIdx, lineIdx, s1.c_str(), lineIdx, s2.c_str() ); code = CvTS::FAIL_INVALID_OUTPUT; } f1.close(); @@ -111,21 +115,21 @@ int CV_SLMLTest::validate_test_results( int testCaseIdx ) { if( fabs(*it1 - *it2) > FLT_EPSILON ) { - ts->printf( CvTS::LOG, "in test case %d responses predicted before saving and after loading is different", testCaseIdx ); + ts->printf( CvTS::LOG, "in test case %d responses predicted before saving and after loading is different", testCaseIdx ); code = CvTS::FAIL_INVALID_OUTPUT; } } return code; } -CV_SLMLTest lsmlnbayes( CV_NBAYES, "slnbayes" ); -//CV_SLMLTest lsmlknearest( CV_KNEAREST, "slknearest" ); // does not support save! -CV_SLMLTest lsmlsvm( CV_SVM, "slsvm" ); -//CV_SLMLTest lsmlem( CV_EM, "slem" ); // does not support save! -CV_SLMLTest lsmlann( CV_ANN, "slann" ); -CV_SLMLTest slmldtree( CV_DTREE, "sldtree" ); -CV_SLMLTest slmlboost( CV_BOOST, "slboost" ); -CV_SLMLTest slmlrtrees( CV_RTREES, "slrtrees" ); -CV_SLMLTest slmlertrees( CV_ERTREES, "slertrees" ); - +CV_SLMLTest lsmlnbayes( CV_NBAYES, "slnbayes" ); +//CV_SLMLTest lsmlknearest( CV_KNEAREST, "slknearest" ); // does not support save! +CV_SLMLTest lsmlsvm( CV_SVM, "slsvm" ); +//CV_SLMLTest lsmlem( CV_EM, "slem" ); // does not support save! +CV_SLMLTest lsmlann( CV_ANN, "slann" ); +CV_SLMLTest slmldtree( CV_DTREE, "sldtree" ); +CV_SLMLTest slmlboost( CV_BOOST, "slboost" ); +CV_SLMLTest slmlrtrees( CV_RTREES, "slrtrees" ); +CV_SLMLTest slmlertrees( CV_ERTREES, "slertrees" ); + /* End of file. */