added workaround for strange tmpnam() output from VS2010. turned off optimization for DCT & DFT on Win64 for VS200x (VS2010 builds it fine)

This commit is contained in:
Vadim Pisarevsky 2010-07-16 14:16:18 +00:00
parent 39baac85dd
commit 670fff5f42
7 changed files with 34 additions and 23 deletions

View File

@ -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

View File

@ -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);

View File

@ -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));

View File

@ -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; }

View File

@ -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 ////////////////////////

View File

@ -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);

View File

@ -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. */