Merge branch 'master' into cuda-dev

This commit is contained in:
Vladislav Vinogradov
2012-12-24 13:48:33 +04:00
66 changed files with 3506 additions and 1452 deletions

View File

@@ -45,7 +45,6 @@
#include <ctype.h>
#include <deque>
#include <iterator>
#include <wchar.h>
#define USE_ZLIB 1
@@ -156,35 +155,6 @@ cv::string cv::FileStorage::getDefaultObjectName(const string& _filename)
return cv::string(name);
}
namespace cv
{
#if !defined(ANDROID) || (defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_WCHAR_T)
string fromUtf16(const WString& str)
{
cv::AutoBuffer<char> _buf(str.size()*4 + 1);
char* buf = _buf;
size_t sz = wcstombs(buf, str.c_str(), str.size());
if( sz == (size_t)-1 )
return string();
buf[sz] = '\0';
return string(buf);
}
WString toUtf16(const string& str)
{
cv::AutoBuffer<wchar_t> _buf(str.size() + 1);
wchar_t* buf = _buf;
size_t sz = mbstowcs(buf, str.c_str(), str.size());
if( sz == (size_t)-1 )
return WString();
buf[sz] = '\0';
return WString(buf);
}
#endif
}
typedef struct CvGenericHash
{
CV_SET_FIELDS()
@@ -5200,6 +5170,7 @@ void FileStorage::release()
string FileStorage::releaseAndGetString()
{
string buf;
buf.reserve(16); // HACK: Work around for compiler bug
if( fs.obj && fs.obj->outbuf )
icvClose(fs.obj, &buf);

View File

@@ -359,26 +359,24 @@ string format( const char* fmt, ... )
string tempfile( const char* suffix )
{
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
string fname;
#if defined WIN32 || defined _WIN32
char temp_dir[MAX_PATH + 1] = { 0 };
char temp_dir2[MAX_PATH + 1] = { 0 };
char temp_file[MAX_PATH + 1] = { 0 };
::GetTempPathA(sizeof(temp_dir), temp_dir);
if (temp_dir == 0 || temp_dir[0] == 0)
{
::GetTempPathA(sizeof(temp_dir2), temp_dir2);
temp_dir = temp_dir2;
}
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
return string();
DeleteFileA(temp_file);
string name = temp_file;
if(suffix)
{
if (suffix[0] != '.')
return name + "." + suffix;
else
return name + suffix;
}
else
return name;
fname = temp_file;
# else
# ifdef ANDROID
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
@@ -387,9 +385,7 @@ string tempfile( const char* suffix )
char defaultTemplate[] = "/tmp/__opencv_temp.XXXXXX";
# endif
string fname;
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
if(temp_dir == 0 || temp_dir[0] == 0)
if (temp_dir == 0 || temp_dir[0] == 0)
fname = defaultTemplate;
else
{
@@ -401,19 +397,20 @@ string tempfile( const char* suffix )
}
const int fd = mkstemp((char*)fname.c_str());
if(fd == -1) return "";
if (fd == -1) return string();
close(fd);
remove(fname.c_str());
# endif
if(suffix)
if (suffix)
{
if (suffix[0] != '.')
fname = fname + "." + suffix;
return fname + "." + suffix;
else
fname += suffix;
return fname + suffix;
}
return fname;
# endif
}
static CvErrorCallback customErrorCallback = 0;