mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge remote-tracking branch 'origin/2.4'
Conflicts: 3rdparty/ffmpeg/ffmpeg_version.cmake cmake/OpenCVFindLibsGrfmt.cmake cmake/templates/cvconfig.h.cmake modules/bioinspired/doc/retina/index.rst modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst modules/calib3d/src/precomp.hpp modules/contrib/src/inputoutput.cpp modules/contrib/src/precomp.hpp modules/core/include/opencv2/core/internal.hpp modules/core/include/opencv2/core/types_c.h modules/core/src/drawing.cpp modules/core/src/precomp.hpp modules/core/src/system.cpp modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst modules/features2d/doc/common_interfaces_of_feature_detectors.rst modules/features2d/include/opencv2/features2d/features2d.hpp modules/features2d/src/precomp.hpp modules/flann/src/precomp.hpp modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst modules/gpu/doc/image_filtering.rst modules/gpu/doc/image_processing.rst modules/gpu/doc/video.rst modules/gpu/perf/perf_imgproc.cpp modules/gpu/perf4au/main.cpp modules/gpu/src/imgproc.cpp modules/gpu/src/precomp.hpp modules/gpu/test/test_imgproc.cpp modules/highgui/CMakeLists.txt modules/highgui/test/test_precomp.hpp modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst modules/imgproc/src/precomp.hpp modules/java/generator/src/cpp/Mat.cpp modules/legacy/src/precomp.hpp modules/ml/doc/k_nearest_neighbors.rst modules/ml/src/precomp.hpp modules/nonfree/doc/feature_detection.rst modules/nonfree/src/precomp.hpp modules/objdetect/include/opencv2/objdetect/objdetect.hpp modules/objdetect/src/cascadedetect.cpp modules/objdetect/src/hog.cpp modules/objdetect/src/precomp.hpp modules/objdetect/test/test_latentsvmdetector.cpp modules/ocl/src/hog.cpp modules/ocl/src/opencl/objdetect_hog.cl modules/ocl/src/precomp.hpp modules/photo/src/precomp.hpp modules/stitching/src/precomp.hpp modules/superres/perf/perf_precomp.hpp modules/superres/src/optical_flow.cpp modules/superres/src/precomp.hpp modules/superres/test/test_precomp.hpp modules/ts/include/opencv2/ts.hpp modules/video/src/precomp.hpp modules/videostab/src/precomp.hpp modules/world/src/precomp.hpp
This commit is contained in:
@@ -94,9 +94,20 @@ void fastFree(void* ptr)
|
||||
#define STAT(stmt)
|
||||
|
||||
#ifdef WIN32
|
||||
#if (_WIN32_WINNT >= 0x0602)
|
||||
#include <synchapi.h>
|
||||
#endif
|
||||
|
||||
struct CriticalSection
|
||||
{
|
||||
CriticalSection() { InitializeCriticalSection(&cs); }
|
||||
CriticalSection()
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0600)
|
||||
InitializeCriticalSectionEx(&cs, 1000, 0);
|
||||
#else
|
||||
InitializeCriticalSection(&cs);
|
||||
#endif
|
||||
}
|
||||
~CriticalSection() { DeleteCriticalSection(&cs); }
|
||||
void lock() { EnterCriticalSection(&cs); }
|
||||
void unlock() { LeaveCriticalSection(&cs); }
|
||||
|
||||
@@ -886,12 +886,14 @@ void ellipse2Poly( Point center, Size axes, int angle,
|
||||
Point pt;
|
||||
pt.x = cvRound( cx + x * alpha - y * beta );
|
||||
pt.y = cvRound( cy + x * beta + y * alpha );
|
||||
if( pt != prevPt )
|
||||
if( pt != prevPt ){
|
||||
pts.push_back(pt);
|
||||
prevPt = pt;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no points, it's a zero-size polygon
|
||||
if( pts.size() < 2) {
|
||||
if( pts.size() == 1) {
|
||||
pts.assign(2,center);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,39 @@ namespace
|
||||
|
||||
struct DIR
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
WIN32_FIND_DATAW data;
|
||||
#else
|
||||
WIN32_FIND_DATA data;
|
||||
#endif
|
||||
HANDLE handle;
|
||||
dirent ent;
|
||||
#ifdef HAVE_WINRT
|
||||
DIR() {};
|
||||
~DIR()
|
||||
{
|
||||
if (ent.d_name)
|
||||
delete[] ent.d_name;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
DIR* opendir(const char* path)
|
||||
{
|
||||
DIR* dir = new DIR;
|
||||
dir->ent.d_name = 0;
|
||||
dir->handle = ::FindFirstFileA((cv::String(path) + "\\*").c_str(), &dir->data);
|
||||
#ifdef HAVE_WINRT
|
||||
cv::String full_path = cv::String(path) + "\\*";
|
||||
size_t size = mbstowcs(NULL, full_path.c_str(), full_path.size());
|
||||
cv::Ptr<wchar_t> wfull_path = new wchar_t[size+1];
|
||||
wfull_path[size] = 0;
|
||||
mbstowcs(wfull_path, full_path.c_str(), full_path.size());
|
||||
dir->handle = ::FindFirstFileExW(wfull_path, FindExInfoStandard,
|
||||
&dir->data, FindExSearchNameMatch, NULL, 0);
|
||||
#else
|
||||
dir->handle = ::FindFirstFileExA((cv::String(path) + "\\*").c_str(),
|
||||
FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0);
|
||||
#endif
|
||||
if(dir->handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/*closedir will do all cleanup*/
|
||||
@@ -76,12 +99,25 @@ namespace
|
||||
|
||||
dirent* readdir(DIR* dir)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
if (dir->ent.d_name != 0)
|
||||
{
|
||||
if (::FindNextFile(dir->handle, &dir->data) != TRUE)
|
||||
if (::FindNextFileW(dir->handle, &dir->data) != TRUE)
|
||||
return 0;
|
||||
}
|
||||
size_t asize = wcstombs(NULL, dir->data.cFileName, 0);
|
||||
char* aname = new char[asize+1];
|
||||
aname[asize] = 0;
|
||||
wcstombs(aname, dir->data.cFileName, asize);
|
||||
dir->ent.d_name = aname;
|
||||
#else
|
||||
if (dir->ent.d_name != 0)
|
||||
{
|
||||
if (::FindNextFileA(dir->handle, &dir->data) != TRUE)
|
||||
return 0;
|
||||
}
|
||||
dir->ent.d_name = dir->data.cFileName;
|
||||
#endif
|
||||
return &dir->ent;
|
||||
}
|
||||
|
||||
@@ -107,7 +143,19 @@ static bool isDir(const cv::String& path, DIR* dir)
|
||||
if (dir)
|
||||
attributes = dir->data.dwFileAttributes;
|
||||
else
|
||||
attributes = ::GetFileAttributes(path.c_str());
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
|
||||
#ifdef HAVE_WINRT
|
||||
size_t size = mbstowcs(NULL, path.c_str(), path.size());
|
||||
cv::Ptr<wchar_t> wpath = new wchar_t[size+1];
|
||||
wpath[size] = 0;
|
||||
mbstowcs(wpath, path.c_str(), path.size());
|
||||
::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs);
|
||||
#else
|
||||
::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs);
|
||||
#endif
|
||||
attributes = all_attrs.dwFileAttributes;
|
||||
}
|
||||
|
||||
return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
||||
#else
|
||||
@@ -241,4 +289,4 @@ void cv::glob(String pattern, std::vector<String>& result, bool recursive)
|
||||
|
||||
glob_rec(path, wildchart, result, recursive);
|
||||
std::sort(result.begin(), result.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,11 @@ int cv::getNumberOfCPUs(void)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
SYSTEM_INFO sysinfo;
|
||||
#if defined(_M_ARM) || defined(_M_X64) || defined(HAVE_WINRT)
|
||||
GetNativeSystemInfo( &sysinfo );
|
||||
#else
|
||||
GetSystemInfo( &sysinfo );
|
||||
#endif
|
||||
|
||||
return (int)sysinfo.dwNumberOfProcessors;
|
||||
#elif defined ANDROID
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
#endif
|
||||
|
||||
#if USE_ZLIB
|
||||
# undef HAVE_UNISTD_H //to avoid redefinition
|
||||
# ifndef _LFS64_LARGEFILE
|
||||
# define _LFS64_LARGEFILE 0
|
||||
# endif
|
||||
|
||||
@@ -728,33 +728,54 @@ void RNG::fill( InputOutputArray _mat, int disttype,
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
// using C++11 thread attribute for local thread data
|
||||
__declspec( thread ) RNG* rng = NULL;
|
||||
|
||||
void deleteThreadRNGData()
|
||||
{
|
||||
if (rng)
|
||||
delete rng;
|
||||
}
|
||||
|
||||
RNG& theRNG()
|
||||
{
|
||||
if (!rng)
|
||||
{
|
||||
rng = new RNG;
|
||||
}
|
||||
return *rng;
|
||||
}
|
||||
#else
|
||||
#ifdef WINCE
|
||||
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
#endif
|
||||
static DWORD tlsRNGKey = TLS_OUT_OF_INDEXES;
|
||||
|
||||
void deleteThreadRNGData()
|
||||
{
|
||||
if( tlsRNGKey != TLS_OUT_OF_INDEXES )
|
||||
delete (RNG*)TlsGetValue( tlsRNGKey );
|
||||
void deleteThreadRNGData()
|
||||
{
|
||||
if( tlsRNGKey != TLS_OUT_OF_INDEXES )
|
||||
delete (RNG*)TlsGetValue( tlsRNGKey );
|
||||
}
|
||||
|
||||
RNG& theRNG()
|
||||
{
|
||||
if( tlsRNGKey == TLS_OUT_OF_INDEXES )
|
||||
{
|
||||
tlsRNGKey = TlsAlloc();
|
||||
CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES);
|
||||
tlsRNGKey = TlsAlloc();
|
||||
CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES);
|
||||
}
|
||||
RNG* rng = (RNG*)TlsGetValue( tlsRNGKey );
|
||||
if( !rng )
|
||||
{
|
||||
rng = new RNG;
|
||||
TlsSetValue( tlsRNGKey, rng );
|
||||
rng = new RNG;
|
||||
TlsSetValue( tlsRNGKey, rng );
|
||||
}
|
||||
return *rng;
|
||||
}
|
||||
|
||||
#endif //HAVE_WINRT
|
||||
#else
|
||||
|
||||
static pthread_key_t tlsRNGKey = 0;
|
||||
|
||||
+71
-37
@@ -47,6 +47,9 @@
|
||||
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#if (_WIN32_WINNT >= 0x0602)
|
||||
#include <synchapi.h>
|
||||
#endif
|
||||
#undef small
|
||||
#undef min
|
||||
#undef max
|
||||
@@ -75,6 +78,30 @@
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#include <wrl/client.h>
|
||||
|
||||
std::wstring GetTempPathWinRT()
|
||||
{
|
||||
return std::wstring(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data());
|
||||
}
|
||||
|
||||
std::wstring GetTempFileNameWinRT(std::wstring prefix)
|
||||
{
|
||||
wchar_t guidStr[40];
|
||||
GUID g;
|
||||
CoCreateGuid(&g);
|
||||
wchar_t* mask = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x";
|
||||
swprintf(&guidStr[0], sizeof(guidStr)/sizeof(wchar_t), mask,
|
||||
g.Data1, g.Data2, g.Data3, UINT(g.Data4[0]), UINT(g.Data4[1]),
|
||||
UINT(g.Data4[2]), UINT(g.Data4[3]), UINT(g.Data4[4]),
|
||||
UINT(g.Data4[5]), UINT(g.Data4[6]), UINT(g.Data4[7]));
|
||||
|
||||
return prefix + std::wstring(guidStr);
|
||||
}
|
||||
|
||||
#endif
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
@@ -371,10 +398,38 @@ String format( const char* fmt, ... )
|
||||
|
||||
String tempfile( const char* suffix )
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
std::wstring temp_dir = L"";
|
||||
const wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH");
|
||||
if (opencv_temp_dir)
|
||||
temp_dir = std::wstring(opencv_temp_dir);
|
||||
#else
|
||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||
String fname;
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#ifdef HAVE_WINRT
|
||||
RoInitialize(RO_INIT_MULTITHREADED);
|
||||
std::wstring temp_dir2;
|
||||
if (temp_dir.empty())
|
||||
temp_dir = GetTempPathWinRT();
|
||||
|
||||
std::wstring temp_file;
|
||||
temp_file = GetTempFileNameWinRT(L"ocv");
|
||||
if (temp_file.empty())
|
||||
return std::string();
|
||||
|
||||
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
|
||||
DeleteFileW(temp_file.c_str());
|
||||
|
||||
size_t asize = wcstombs(NULL, temp_file.c_str(), 0);
|
||||
Ptr<char> aname = new char[asize+1];
|
||||
aname[asize] = 0;
|
||||
wcstombs(aname, temp_file.c_str(), asize);
|
||||
fname = std::string(aname);
|
||||
RoUninitialize();
|
||||
#else
|
||||
char temp_dir2[MAX_PATH + 1] = { 0 };
|
||||
char temp_file[MAX_PATH + 1] = { 0 };
|
||||
|
||||
@@ -389,6 +444,7 @@ String tempfile( const char* suffix )
|
||||
DeleteFileA(temp_file);
|
||||
|
||||
fname = temp_file;
|
||||
#endif
|
||||
# else
|
||||
# ifdef ANDROID
|
||||
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
|
||||
@@ -486,40 +542,6 @@ redirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata)
|
||||
|
||||
}
|
||||
|
||||
/*CV_IMPL int
|
||||
cvGuiBoxReport( int code, const char *func_name, const char *err_msg,
|
||||
const char *file, int line, void* )
|
||||
{
|
||||
#if (!defined WIN32 && !defined _WIN32) || defined WINCE
|
||||
return cvStdErrReport( code, func_name, err_msg, file, line, 0 );
|
||||
#else
|
||||
if( code != CV_StsBackTrace && code != CV_StsAutoTrace )
|
||||
{
|
||||
size_t msg_len = strlen(err_msg ? err_msg : "") + 1024;
|
||||
char* message = (char*)alloca(msg_len);
|
||||
char title[100];
|
||||
|
||||
wsprintf( message, "%s (%s)\nin function %s, %s(%d)\n\n"
|
||||
"Press \"Abort\" to terminate application.\n"
|
||||
"Press \"Retry\" to debug (if the app is running under debugger).\n"
|
||||
"Press \"Ignore\" to continue (this is not safe).\n",
|
||||
cvErrorStr(code), err_msg ? err_msg : "no description",
|
||||
func_name, file, line );
|
||||
|
||||
wsprintf( title, "OpenCV GUI Error Handler" );
|
||||
|
||||
int answer = MessageBox( NULL, message, title, MB_ICONERROR|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL );
|
||||
|
||||
if( answer == IDRETRY )
|
||||
{
|
||||
CV_DBG_BREAK();
|
||||
}
|
||||
return answer != IDIGNORE;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}*/
|
||||
|
||||
CV_IMPL int cvCheckHardwareSupport(int feature)
|
||||
{
|
||||
CV_DbgAssert( 0 <= feature && feature <= CV_HARDWARE_MAX_FEATURE );
|
||||
@@ -677,7 +699,11 @@ cvErrorFromIppStatus( int status )
|
||||
}
|
||||
|
||||
|
||||
#if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
|
||||
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
|
||||
#ifdef HAVE_WINRT
|
||||
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
|
||||
#endif
|
||||
|
||||
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID );
|
||||
|
||||
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
|
||||
@@ -698,7 +724,15 @@ namespace cv
|
||||
|
||||
struct Mutex::Impl
|
||||
{
|
||||
Impl() { InitializeCriticalSection(&cs); refcount = 1; }
|
||||
Impl()
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0600)
|
||||
::InitializeCriticalSectionEx(&cs, 1000, 0);
|
||||
#else
|
||||
::InitializeCriticalSection(&cs);
|
||||
#endif
|
||||
refcount = 1;
|
||||
}
|
||||
~Impl() { DeleteCriticalSection(&cs); }
|
||||
|
||||
void lock() { EnterCriticalSection(&cs); }
|
||||
@@ -791,4 +825,4 @@ bool Mutex::trylock() { return impl->trylock(); }
|
||||
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
/* End of file. */
|
||||
|
||||
Reference in New Issue
Block a user