Commit 670fff5f authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

added workaround for strange tmpnam() output from VS2010. turned off…

added workaround for strange tmpnam() output from VS2010. turned off optimization for DCT & DFT on Win64 for VS200x (VS2010 builds it fine)
parent 39baac85
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
namespace cv namespace cv
{ {
// On Win64 (IA64) optimized versions of DFT and DCT fail the tests // On Win64 optimized versions of DFT and DCT fail the tests (fixed in VS2010)
#if defined WIN64 && !defined EM64T #if (defined WIN64 || defined _WIN64) && defined _MSC_VER && _MSC_VER < 1600
#pragma optimize("", off) #pragma optimize("", off)
#endif #endif
......
...@@ -318,6 +318,8 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) ...@@ -318,6 +318,8 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
if( !decoder->setSource(buf) ) if( !decoder->setSource(buf) )
{ {
filename = tmpnam(fnamebuf); filename = tmpnam(fnamebuf);
if(filename[0] == '\\')
filename++;
FILE* f = fopen( filename, "wb" ); FILE* f = fopen( filename, "wb" );
if( !f ) if( !f )
return 0; return 0;
...@@ -425,6 +427,8 @@ bool imencode( const string& ext, const Mat& image, ...@@ -425,6 +427,8 @@ bool imencode( const string& ext, const Mat& image,
{ {
char fnamebuf[L_tmpnam]; char fnamebuf[L_tmpnam];
const char* filename = tmpnam(fnamebuf); const char* filename = tmpnam(fnamebuf);
if(filename[0] == '\\')
filename++;
code = encoder->setDestination(filename); code = encoder->setDestination(filename);
CV_Assert( code ); CV_Assert( code );
code = encoder->write(image, params); code = encoder->write(image, params);
......
...@@ -507,6 +507,7 @@ void CV_FlannSavedIndexTest::createModel(const cv::Mat &data) ...@@ -507,6 +507,7 @@ void CV_FlannSavedIndexTest::createModel(const cv::Mat &data)
} }
char filename[50]; char filename[50];
tmpnam( filename ); tmpnam( filename );
if(filename[0] == '\\') filename[0] = '_';
index->save( filename ); index->save( filename );
createIndex( data, SavedIndexParams(filename)); createIndex( data, SavedIndexParams(filename));
......
...@@ -67,7 +67,7 @@ using namespace std; ...@@ -67,7 +67,7 @@ using namespace std;
struct TempDirHolder struct TempDirHolder
{ {
const string temp_folder; 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); } ~TempDirHolder() { exec_cmd("rm -rf " + temp_folder); }
static void exec_cmd(const string& cmd) { marker(cmd); int res = system( cmd.c_str() ); (void)res; } static void exec_cmd(const string& cmd) { marker(cmd); int res = system( cmd.c_str() ); (void)res; }
......
...@@ -829,7 +829,7 @@ void CxCore_DFTTest::prepare_to_validation( int /*test_case_idx*/ ) ...@@ -829,7 +829,7 @@ void CxCore_DFTTest::prepare_to_validation( int /*test_case_idx*/ )
} }
//CxCore_DFTTest dft_test; CxCore_DFTTest dft_test;
////////////////////// DCT //////////////////////// ////////////////////// DCT ////////////////////////
...@@ -876,7 +876,7 @@ void CxCore_DCTTest::prepare_to_validation( int /*test_case_idx*/ ) ...@@ -876,7 +876,7 @@ void CxCore_DCTTest::prepare_to_validation( int /*test_case_idx*/ )
} }
//CxCore_DCTTest dct_test; CxCore_DCTTest dct_test;
////////////////////// MulSpectrums //////////////////////// ////////////////////// MulSpectrums ////////////////////////
......
...@@ -156,6 +156,8 @@ void CV_IOTest::run( int ) ...@@ -156,6 +156,8 @@ void CV_IOTest::run( int )
char buf[L_tmpnam+16]; char buf[L_tmpnam+16];
char* filename = tmpnam(buf); char* filename = tmpnam(buf);
strcat(filename, idx % 2 ? ".yml" : ".xml"); strcat(filename, idx % 2 ? ".yml" : ".xml");
if(filename[0] == '\\')
filename++;
FileStorage fs(filename, FileStorage::WRITE); FileStorage fs(filename, FileStorage::WRITE);
......
...@@ -61,10 +61,14 @@ int CV_SLMLTest::run_test_case( int testCaseIdx ) ...@@ -61,10 +61,14 @@ int CV_SLMLTest::run_test_case( int testCaseIdx )
if( code == CvTS::OK ) if( code == CvTS::OK )
{ {
get_error( testCaseIdx, CV_TEST_ERROR, &test_resps1 ); get_error( testCaseIdx, CV_TEST_ERROR, &test_resps1 );
save( tmpnam( fname1 ) ); tmpnam(fname1);
if(fname1[0] == '\\') fname1[0] = '_';
save( fname1 );
load( fname1); load( fname1);
get_error( testCaseIdx, CV_TEST_ERROR, &test_resps2 ); get_error( testCaseIdx, CV_TEST_ERROR, &test_resps2 );
save( tmpnam( fname2 ) ); tmpnam(fname2);
if(fname2[0] == '\\') fname2[0] = '_';
save( fname2 );
} }
else else
ts->printf( CvTS::LOG, "model can not be trained" ); ts->printf( CvTS::LOG, "model can not be trained" );
......
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