WinRT core compatibility fixes
Update system.cpp Update system.cpp Update ocl.cpp Update matching.cpp Update ocl.cpp Update matching.cpp
This commit is contained in:
parent
01f31dc007
commit
b1443bc1bc
@ -60,7 +60,11 @@
|
|||||||
// TODO Move to some common place
|
// TODO Move to some common place
|
||||||
static size_t getConfigurationParameterForSize(const char* name, size_t defaultValue)
|
static size_t getConfigurationParameterForSize(const char* name, size_t defaultValue)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
|
const char* envValue = NULL;
|
||||||
|
#else
|
||||||
const char* envValue = getenv(name);
|
const char* envValue = getenv(name);
|
||||||
|
#endif
|
||||||
if (envValue == NULL)
|
if (envValue == NULL)
|
||||||
{
|
{
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
@ -685,12 +689,14 @@ static void* initOpenCLAndLoad(const char* funcname)
|
|||||||
static HMODULE handle = 0;
|
static HMODULE handle = 0;
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_WINRT
|
||||||
if(!initialized)
|
if(!initialized)
|
||||||
{
|
{
|
||||||
handle = LoadLibraryA("OpenCL.dll");
|
handle = LoadLibraryA("OpenCL.dll");
|
||||||
initialized = true;
|
initialized = true;
|
||||||
g_haveOpenCL = handle != 0 && GetProcAddress(handle, oclFuncToCheck) != 0;
|
g_haveOpenCL = handle != 0 && GetProcAddress(handle, oclFuncToCheck) != 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if(!handle)
|
if(!handle)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2145,6 +2151,12 @@ static bool parseOpenCLDeviceConfiguration(const std::string& configurationStr,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WINRT
|
||||||
|
static cl_device_id selectOpenCLDevice()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static cl_device_id selectOpenCLDevice()
|
static cl_device_id selectOpenCLDevice()
|
||||||
{
|
{
|
||||||
std::string platform, deviceName;
|
std::string platform, deviceName;
|
||||||
@ -2289,6 +2301,7 @@ not_found:
|
|||||||
CV_Error(CL_INVALID_DEVICE, "Requested OpenCL device is not found");
|
CV_Error(CL_INVALID_DEVICE, "Requested OpenCL device is not found");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Context::Impl
|
struct Context::Impl
|
||||||
{
|
{
|
||||||
|
@ -442,27 +442,23 @@ String format( const char* fmt, ... )
|
|||||||
|
|
||||||
String tempfile( const char* suffix )
|
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;
|
String fname;
|
||||||
|
#ifndef HAVE_WINRT
|
||||||
|
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
#ifdef HAVE_WINRT
|
#ifdef HAVE_WINRT
|
||||||
RoInitialize(RO_INIT_MULTITHREADED);
|
RoInitialize(RO_INIT_MULTITHREADED);
|
||||||
std::wstring temp_dir2;
|
std::wstring temp_dir = L"";
|
||||||
if (temp_dir.empty())
|
const wchar_t* opencv_temp_dir = GetTempPathWinRT().c_str();
|
||||||
temp_dir = GetTempPathWinRT();
|
if (opencv_temp_dir)
|
||||||
|
temp_dir = std::wstring(opencv_temp_dir);
|
||||||
|
|
||||||
std::wstring temp_file;
|
std::wstring temp_file;
|
||||||
temp_file = GetTempFileNameWinRT(L"ocv");
|
temp_file = GetTempFileNameWinRT(L"ocv");
|
||||||
if (temp_file.empty())
|
if (temp_file.empty())
|
||||||
return std::string();
|
return String();
|
||||||
|
|
||||||
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
|
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
|
||||||
DeleteFileW(temp_file.c_str());
|
DeleteFileW(temp_file.c_str());
|
||||||
@ -470,7 +466,7 @@ String tempfile( const char* suffix )
|
|||||||
char aname[MAX_PATH];
|
char aname[MAX_PATH];
|
||||||
size_t copied = wcstombs(aname, temp_file.c_str(), MAX_PATH);
|
size_t copied = wcstombs(aname, temp_file.c_str(), MAX_PATH);
|
||||||
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
|
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
|
||||||
fname = std::string(aname);
|
fname = String(aname);
|
||||||
RoUninitialize();
|
RoUninitialize();
|
||||||
#else
|
#else
|
||||||
char temp_dir2[MAX_PATH] = { 0 };
|
char temp_dir2[MAX_PATH] = { 0 };
|
||||||
|
@ -525,7 +525,9 @@ int addNullableBorder(CvLSVMFeatureMap *map, int bx, int by)
|
|||||||
float *new_map;
|
float *new_map;
|
||||||
sizeX = map->sizeX + 2 * bx;
|
sizeX = map->sizeX + 2 * bx;
|
||||||
sizeY = map->sizeY + 2 * by;
|
sizeY = map->sizeY + 2 * by;
|
||||||
new_map = (float *)malloc(sizeof(float) * sizeX * sizeY * map->numFeatures);
|
// fix for Windows Phone 8 ARM compiler
|
||||||
|
size_t size = sizeof(float) * sizeX * sizeY * map->numFeatures;
|
||||||
|
new_map = (float *)malloc(size);
|
||||||
for (i = 0; i < sizeX * sizeY * map->numFeatures; i++)
|
for (i = 0; i < sizeX * sizeY * map->numFeatures; i++)
|
||||||
{
|
{
|
||||||
new_map[i] = 0.0;
|
new_map[i] = 0.0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user