mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
API restricted on WinRT partially removed from core.
Additional CMAKE flag WITH_WINRT added.
This commit is contained in:
parent
4c35449b7d
commit
6257df1c4b
@ -147,6 +147,7 @@ OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON
|
|||||||
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS) )
|
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||||
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) )
|
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||||
OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 )
|
OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 )
|
||||||
|
OCV_OPTION(WITH_WINRT "Build with Windows Runtime support" OFF IF WIN32 )
|
||||||
OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
|
OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
|
||||||
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) )
|
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) )
|
||||||
OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 )
|
OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 )
|
||||||
|
@ -2,6 +2,21 @@ if(NOT MSVC)
|
|||||||
message(FATAL_ERROR "CRT options are available only for MSVC")
|
message(FATAL_ERROR "CRT options are available only for MSVC")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#INCLUDE (CheckIncludeFiles)
|
||||||
|
|
||||||
|
if (WITH_WINRT)
|
||||||
|
#CHECK_INCLUDE_FILES("wrl/client.h" HAVE_WINRT)
|
||||||
|
TRY_COMPILE(HAVE_WINRT
|
||||||
|
"${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp"
|
||||||
|
"${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp"
|
||||||
|
CMAKE_FLAGS "\"kernel.lib\" \"user32.lib\""
|
||||||
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
if (HAVE_WINRT)
|
||||||
|
add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602)
|
||||||
|
endif()
|
||||||
|
message(STATUS "Windows RT: ${HAVE_WINRT}")
|
||||||
|
endif(WITH_WINRT)
|
||||||
|
|
||||||
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
|
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
|
||||||
foreach(flag_var
|
foreach(flag_var
|
||||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||||
|
@ -76,6 +76,12 @@
|
|||||||
/* GTK+ 2.0 Thread support */
|
/* GTK+ 2.0 Thread support */
|
||||||
#cmakedefine HAVE_GTHREAD
|
#cmakedefine HAVE_GTHREAD
|
||||||
|
|
||||||
|
/* Windows Runtime support */
|
||||||
|
#cmakedefine HAVE_WINRT
|
||||||
|
|
||||||
|
/* Win32 UI */
|
||||||
|
#cmakedefine HAVE_WIN32UI
|
||||||
|
|
||||||
/* GTK+ 2.x toolkit */
|
/* GTK+ 2.x toolkit */
|
||||||
#cmakedefine HAVE_GTK
|
#cmakedefine HAVE_GTK
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@ set(the_description "The Core Functionality")
|
|||||||
ocv_add_module(core ${ZLIB_LIBRARIES})
|
ocv_add_module(core ${ZLIB_LIBRARIES})
|
||||||
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
|
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
|
||||||
|
|
||||||
|
if (HAVE_WINRT)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"C:/Program Files/Windows Kits/8.0/References/CommonConfiguration/Neutral\" /AI\"C:/Program Files/Microsoft Visual Studio 11.0/VC/vcpackages\"")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(HAVE_CUDA)
|
if(HAVE_CUDA)
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
|
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||||
|
@ -42,6 +42,10 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
|
#if (_WIN32_WINNT >= 0x0602)
|
||||||
|
#include <synchapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CV_USE_SYSTEM_MALLOC 1
|
#define CV_USE_SYSTEM_MALLOC 1
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
@ -96,7 +100,14 @@ void fastFree(void* ptr)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
struct CriticalSection
|
struct CriticalSection
|
||||||
{
|
{
|
||||||
CriticalSection() { InitializeCriticalSection(&cs); }
|
CriticalSection()
|
||||||
|
{
|
||||||
|
#if (_WIN32_WINNT >= 0x0600)
|
||||||
|
InitializeCriticalSectionEx(&cs, 1000, 0);
|
||||||
|
#else
|
||||||
|
InitializeCriticalSection(&cs);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
~CriticalSection() { DeleteCriticalSection(&cs); }
|
~CriticalSection() { DeleteCriticalSection(&cs); }
|
||||||
void lock() { EnterCriticalSection(&cs); }
|
void lock() { EnterCriticalSection(&cs); }
|
||||||
void unlock() { LeaveCriticalSection(&cs); }
|
void unlock() { LeaveCriticalSection(&cs); }
|
||||||
|
@ -56,16 +56,40 @@ namespace
|
|||||||
|
|
||||||
struct DIR
|
struct DIR
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
|
WIN32_FIND_DATAW data;
|
||||||
|
#else
|
||||||
WIN32_FIND_DATA data;
|
WIN32_FIND_DATA data;
|
||||||
|
#endif
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
dirent ent;
|
dirent ent;
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
|
DIR() {};
|
||||||
|
~DIR()
|
||||||
|
{
|
||||||
|
if (ent.d_name)
|
||||||
|
free((void*)ent.d_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
DIR* opendir(const char* path)
|
DIR* opendir(const char* path)
|
||||||
{
|
{
|
||||||
DIR* dir = new DIR;
|
DIR* dir = new DIR;
|
||||||
dir->ent.d_name = 0;
|
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());
|
||||||
|
wchar_t* wfull_path = (wchar_t*)malloc((size+1)*sizeof(wchar_t));
|
||||||
|
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);
|
||||||
|
free(wfull_path);
|
||||||
|
#else
|
||||||
|
dir->handle = ::FindFirstFileExA((cv::String(path) + "\\*").c_str(),
|
||||||
|
FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0);
|
||||||
|
#endif
|
||||||
if(dir->handle == INVALID_HANDLE_VALUE)
|
if(dir->handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/*closedir will do all cleanup*/
|
/*closedir will do all cleanup*/
|
||||||
@ -76,12 +100,25 @@ namespace
|
|||||||
|
|
||||||
dirent* readdir(DIR* dir)
|
dirent* readdir(DIR* dir)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
if (dir->ent.d_name != 0)
|
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 = (char*)malloc((asize+1)*sizeof(char));
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
dir->ent.d_name = dir->data.cFileName;
|
dir->ent.d_name = dir->data.cFileName;
|
||||||
|
#endif
|
||||||
return &dir->ent;
|
return &dir->ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +144,20 @@ static bool isDir(const cv::String& path, DIR* dir)
|
|||||||
if (dir)
|
if (dir)
|
||||||
attributes = dir->data.dwFileAttributes;
|
attributes = dir->data.dwFileAttributes;
|
||||||
else
|
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());
|
||||||
|
wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t));
|
||||||
|
wpath[size] = 0;
|
||||||
|
mbstowcs(wpath, path.c_str(), path.size());
|
||||||
|
::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs);
|
||||||
|
free(wpath);
|
||||||
|
#else
|
||||||
|
::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs);
|
||||||
|
#endif
|
||||||
|
attributes = all_attrs.dwFileAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
||||||
#else
|
#else
|
||||||
|
@ -453,7 +453,11 @@ int cv::getNumberOfCPUs(void)
|
|||||||
{
|
{
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
|
#if defined(_M_ARM) || defined(_M_X64) || defined(HAVE_WINRT)
|
||||||
|
GetNativeSystemInfo( &sysinfo );
|
||||||
|
#else
|
||||||
GetSystemInfo( &sysinfo );
|
GetSystemInfo( &sysinfo );
|
||||||
|
#endif
|
||||||
|
|
||||||
return (int)sysinfo.dwNumberOfProcessors;
|
return (int)sysinfo.dwNumberOfProcessors;
|
||||||
#elif defined ANDROID
|
#elif defined ANDROID
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#if (_WIN32_WINNT >= 0x0602)
|
||||||
|
#include <synchapi.h>
|
||||||
|
#endif
|
||||||
#undef small
|
#undef small
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
@ -75,6 +78,32 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
|
#pragma comment(lib, "MinCore_Downlevel")
|
||||||
|
#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[120];
|
||||||
|
GUID* g = 0x00;
|
||||||
|
g = new GUID;
|
||||||
|
CoCreateGuid(g);
|
||||||
|
wchar_t* mask = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x";
|
||||||
|
swprintf(&guidStr[0],mask, 120, 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]));
|
||||||
|
delete g;
|
||||||
|
|
||||||
|
return prefix + std::wstring(guidStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -359,10 +388,39 @@ string format( const char* fmt, ... )
|
|||||||
|
|
||||||
string tempfile( const char* suffix )
|
string tempfile( const char* suffix )
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
|
std::wstring temp_dir = L"";
|
||||||
|
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");
|
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||||
|
#endif
|
||||||
string fname;
|
string fname;
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#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);
|
||||||
|
char* aname = (char*)malloc((asize+1)*sizeof(char));
|
||||||
|
aname[asize] = 0;
|
||||||
|
wcstombs(aname, temp_file.c_str(), asize);
|
||||||
|
fname = std::string(aname);
|
||||||
|
free(aname);
|
||||||
|
RoUninitialize();
|
||||||
|
#else
|
||||||
char temp_dir2[MAX_PATH + 1] = { 0 };
|
char temp_dir2[MAX_PATH + 1] = { 0 };
|
||||||
char temp_file[MAX_PATH + 1] = { 0 };
|
char temp_file[MAX_PATH + 1] = { 0 };
|
||||||
|
|
||||||
@ -377,6 +435,7 @@ string tempfile( const char* suffix )
|
|||||||
DeleteFileA(temp_file);
|
DeleteFileA(temp_file);
|
||||||
|
|
||||||
fname = temp_file;
|
fname = temp_file;
|
||||||
|
#endif
|
||||||
# else
|
# else
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
|
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
|
||||||
@ -766,7 +825,15 @@ namespace cv
|
|||||||
|
|
||||||
struct Mutex::Impl
|
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); }
|
~Impl() { DeleteCriticalSection(&cs); }
|
||||||
|
|
||||||
void lock() { EnterCriticalSection(&cs); }
|
void lock() { EnterCriticalSection(&cs); }
|
||||||
|
Loading…
Reference in New Issue
Block a user