Adding support for WinRT(WinPhone 8/8.1 and Win Store) via CMake 3.1
- Substituted HAVE_WINRT with WINRT - Fixed compilation issues in ocl.cpp and parallel.cpp - Fixed compiler issue for WP8: "C2678: binary '+' : no operator found which takes a left-hand - Fixed gitignore - Added #ifdef HAVE_OPENCL to remove compiler warnings in ocl.cpp - Used NO_GETENV similar to '3rdparty\libjpeg\jmemmgr.c; - Added ole32.lib for core module (for WindowsStore 8.0 builds) - Made OpenCV_ARCH aware of ARM Signed-off-by: Maxim Kostin <v-maxkos@microsoft.com>
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
set(the_description "The Core Functionality")
|
||||
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" OPTIONAL opencv_cudev)
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
if(HAVE_WINRT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
|
||||
set(extra_libs "")
|
||||
|
||||
if(WINRT AND CMAKE_SYSTEM_NAME MATCHES WindowsStore AND CMAKE_SYSTEM_VERSION MATCHES "8.0")
|
||||
list(APPEND extra_libs ole32.lib)
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
@@ -22,7 +21,7 @@ ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version
|
||||
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
||||
|
||||
ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS})
|
||||
ocv_create_module()
|
||||
ocv_create_module(${extra_libs})
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
ocv_add_perf_tests()
|
||||
|
||||
@@ -56,14 +56,14 @@ namespace
|
||||
|
||||
struct DIR
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
WIN32_FIND_DATAW data;
|
||||
#else
|
||||
WIN32_FIND_DATA data;
|
||||
#endif
|
||||
HANDLE handle;
|
||||
dirent ent;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
DIR() { }
|
||||
~DIR()
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace
|
||||
{
|
||||
DIR* dir = new DIR;
|
||||
dir->ent.d_name = 0;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
cv::String full_path = cv::String(path) + "\\*";
|
||||
wchar_t wfull_path[MAX_PATH];
|
||||
size_t copied = mbstowcs(wfull_path, full_path.c_str(), MAX_PATH);
|
||||
@@ -99,7 +99,7 @@ namespace
|
||||
|
||||
dirent* readdir(DIR* dir)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
if (dir->ent.d_name != 0)
|
||||
{
|
||||
if (::FindNextFileW(dir->handle, &dir->data) != TRUE)
|
||||
@@ -147,7 +147,7 @@ static bool isDir(const cv::String& path, DIR* dir)
|
||||
else
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
wchar_t wpath[MAX_PATH];
|
||||
size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH);
|
||||
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
|
||||
|
||||
@@ -64,7 +64,15 @@
|
||||
// TODO Move to some common place
|
||||
static bool getBoolParameter(const char* name, bool defaultValue)
|
||||
{
|
||||
/*
|
||||
* If your system doesn't support getenv(), define NO_GETENV to disable
|
||||
* this feature.
|
||||
*/
|
||||
#ifdef NO_GETENV
|
||||
const char* envValue = NULL;
|
||||
#else
|
||||
const char* envValue = getenv(name);
|
||||
#endif
|
||||
if (envValue == NULL)
|
||||
{
|
||||
return defaultValue;
|
||||
@@ -85,7 +93,7 @@ static bool getBoolParameter(const char* name, bool defaultValue)
|
||||
// TODO Move to some common place
|
||||
static size_t getConfigurationParameterForSize(const char* name, size_t defaultValue)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef NO_GETENV
|
||||
const char* envValue = NULL;
|
||||
#else
|
||||
const char* envValue = getenv(name);
|
||||
@@ -728,7 +736,7 @@ static void* initOpenCLAndLoad(const char* funcname)
|
||||
static HMODULE handle = 0;
|
||||
if (!handle)
|
||||
{
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
if(!initialized)
|
||||
{
|
||||
handle = LoadLibraryA("OpenCL.dll");
|
||||
@@ -2190,6 +2198,7 @@ inline cl_int getStringInfo(Functor f, ObjectType obj, cl_uint name, std::string
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static void split(const std::string &s, char delim, std::vector<std::string> &elems)
|
||||
{
|
||||
elems.clear();
|
||||
@@ -2230,8 +2239,9 @@ static bool parseOpenCLDeviceConfiguration(const std::string& configurationStr,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
static cl_device_id selectOpenCLDevice()
|
||||
{
|
||||
return NULL;
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
#define HAVE_GCD
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1600
|
||||
#if defined _MSC_VER && _MSC_VER >= 1600 && !defined(WINRT)
|
||||
#define HAVE_CONCURRENCY
|
||||
#endif
|
||||
|
||||
@@ -458,7 +458,7 @@ int cv::getNumberOfCPUs(void)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
SYSTEM_INFO sysinfo;
|
||||
#if defined(_M_ARM) || defined(_M_X64) || defined(HAVE_WINRT)
|
||||
#if defined(_M_ARM) || defined(_M_X64) || defined(WINRT)
|
||||
GetNativeSystemInfo( &sysinfo );
|
||||
#else
|
||||
GetSystemInfo( &sysinfo );
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#include <wrl/client.h>
|
||||
#ifndef __cplusplus_winrt
|
||||
#include <windows.storage.h>
|
||||
@@ -159,7 +159,7 @@ std::wstring GetTempFileNameWinRT(std::wstring prefix)
|
||||
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);
|
||||
return prefix.append(std::wstring(guidStr));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -542,12 +542,12 @@ String format( const char* fmt, ... )
|
||||
String tempfile( const char* suffix )
|
||||
{
|
||||
String fname;
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
RoInitialize(RO_INIT_MULTITHREADED);
|
||||
std::wstring temp_dir = L"";
|
||||
const wchar_t* opencv_temp_dir = GetTempPathWinRT().c_str();
|
||||
@@ -559,7 +559,7 @@ String tempfile( const char* suffix )
|
||||
if (temp_file.empty())
|
||||
return String();
|
||||
|
||||
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
|
||||
temp_file = temp_dir.append(std::wstring(L"\\")).append(temp_file);
|
||||
DeleteFileW(temp_file.c_str());
|
||||
|
||||
char aname[MAX_PATH];
|
||||
@@ -955,7 +955,7 @@ public:
|
||||
#pragma warning(disable:4505) // unreferenced local function has been removed
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
// using C++11 thread attribute for local thread data
|
||||
static __declspec( thread ) TLSStorage* g_tlsdata = NULL;
|
||||
|
||||
@@ -1006,10 +1006,10 @@ public:
|
||||
}
|
||||
return d;
|
||||
}
|
||||
#endif //HAVE_WINRT
|
||||
#endif //WINRT
|
||||
|
||||
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudaarithm)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR APPLE OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR APPLE OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudacodec)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudafeatures2d)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudafilters)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudaimgproc)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudaoptflow)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudastereo)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
if(IOS OR WINRT OR (NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS))
|
||||
ocv_module_disable(cudawarping)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
if (WINRT)
|
||||
ocv_module_disable(highgui)
|
||||
endif()
|
||||
|
||||
set(the_description "High-level GUI and Media I/O")
|
||||
ocv_add_module(highgui opencv_imgproc opencv_imgcodecs opencv_videoio OPTIONAL opencv_androidcamera)
|
||||
|
||||
@@ -7,7 +11,8 @@ ocv_add_module(highgui opencv_imgproc opencv_imgcodecs opencv_videoio OPTIONAL o
|
||||
# Jose Luis Blanco, 2008
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
# Compilation with /ZW is not allowed for *.c files
|
||||
if(HAVE_WINRT_CX AND NOT WINRT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
if(WINRT)
|
||||
ocv_module_disable(imgcodecs)
|
||||
endif()
|
||||
|
||||
set(the_description "Image codecs")
|
||||
ocv_add_module(imgcodecs opencv_imgproc)
|
||||
|
||||
@@ -9,7 +13,7 @@ ocv_add_module(imgcodecs opencv_imgproc)
|
||||
|
||||
ocv_clear_vars(GRFMT_LIBS)
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
if(HAVE_WINRT_CX AND NOT WINRT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for java support
|
||||
# ----------------------------------------------------------------------------
|
||||
if(IOS OR NOT PYTHON_DEFAULT_AVAILABLE OR NOT ANT_EXECUTABLE OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7))
|
||||
if(IOS OR WINRT OR NOT PYTHON_DEFAULT_AVAILABLE OR NOT ANT_EXECUTABLE OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7))
|
||||
OR BUILD_opencv_world
|
||||
)
|
||||
ocv_module_disable(java)
|
||||
|
||||
@@ -9,7 +9,7 @@ if((WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
ocv_module_disable(python3)
|
||||
endif()
|
||||
|
||||
if(ANDROID OR IOS)
|
||||
if(ANDROID OR IOS OR WINRT)
|
||||
ocv_module_disable(python2)
|
||||
ocv_module_disable(python3)
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(IOS)
|
||||
if(IOS OR WINRT)
|
||||
ocv_module_disable(superres)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(the_description "The ts module")
|
||||
|
||||
if(IOS)
|
||||
if(IOS OR WINRT)
|
||||
ocv_module_disable(ts)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "cvconfig.h"
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
if(WINRT)
|
||||
ocv_module_disable(videoio)
|
||||
endif()
|
||||
|
||||
set(the_description "Media I/O")
|
||||
ocv_add_module(videoio opencv_imgproc opencv_imgcodecs OPTIONAL opencv_androidcamera)
|
||||
|
||||
@@ -7,7 +11,7 @@ ocv_add_module(videoio opencv_imgproc opencv_imgcodecs OPTIONAL opencv_androidca
|
||||
# Jose Luis Blanco, 2008
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
if(HAVE_WINRT_CX AND NOT WINRT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
icvInitFFMPEG()
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
# ifdef HAVE_WINRT
|
||||
# ifdef WINRT
|
||||
const wchar_t* module_name = L"opencv_ffmpeg"
|
||||
CVAUX_STRW(CV_MAJOR_VERSION) CVAUX_STRW(CV_MINOR_VERSION) CVAUX_STRW(CV_SUBMINOR_VERSION)
|
||||
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
#include <mferror.h>
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
// for ComPtr usage
|
||||
#include <wrl/client.h>
|
||||
#ifdef __cplusplus_winrt
|
||||
@@ -266,7 +266,7 @@ public:
|
||||
#endif
|
||||
|
||||
struct IMFMediaType;
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
struct IMFActivate;
|
||||
struct IMFMediaSource;
|
||||
#endif
|
||||
@@ -406,7 +406,7 @@ private:
|
||||
ImageGrabberCallback& operator=(const ImageGrabberCallback&); // Declared to fix compilation warning.
|
||||
};
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
extern const __declspec(selectany) WCHAR RuntimeClass_CV_ImageGrabberWinRT[] = L"cv.ImageGrabberWinRT";
|
||||
|
||||
class ImageGrabberWinRT :
|
||||
@@ -547,7 +547,7 @@ public:
|
||||
CamParametrs getParametrs();
|
||||
void setParametrs(CamParametrs parametrs);
|
||||
void setEmergencyStopEvent(void *userData, void(*func)(int, void *));
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
long readInfoOfDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice, unsigned int Num);
|
||||
void waitForDevice()
|
||||
{
|
||||
@@ -593,7 +593,7 @@ private:
|
||||
std::map<UINT64, FrameRateMap> vd_CaptureFormats;
|
||||
std::vector<MediaType> vd_CurrentFormats;
|
||||
IMFMediaSource *vd_pSource;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
MAKE_WRL_AGILE_REF(_MediaCapture) vd_pMedCap;
|
||||
EventRegistrationToken vd_cookie;
|
||||
ImageGrabberWinRT *vd_pImGr;
|
||||
@@ -608,7 +608,7 @@ private:
|
||||
long setDeviceFormat(IMFMediaSource *pSource, unsigned long dwFormatIndex);
|
||||
void buildLibraryofTypes();
|
||||
int findType(unsigned int size, unsigned int frameRate = 0);
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
HRESULT enumerateCaptureFormats(MAKE_WRL_REF(_MediaCapture) pSource);
|
||||
long setDeviceFormat(MAKE_WRL_REF(_MediaCapture) pSource, unsigned long dwFormatIndex, MAKE_WRL_REF(_AsyncAction)* pAction);
|
||||
long resetDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice);
|
||||
@@ -627,7 +627,7 @@ class videoDevices
|
||||
{
|
||||
public:
|
||||
~videoDevices(void);
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
long initDevices(_DeviceClass devClass);
|
||||
void waitInit() {
|
||||
if (vds_enumTask) {
|
||||
@@ -646,7 +646,7 @@ public:
|
||||
void clearDevices();
|
||||
private:
|
||||
UINT32 count;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
MAKE_WRL_REF(_AsyncAction) vds_enumTask;
|
||||
#endif
|
||||
std::vector<videoDevice *> vds_Devices;
|
||||
@@ -715,7 +715,7 @@ public:
|
||||
bool setupDevice(int deviceID, unsigned int w, unsigned int h, unsigned int idealFramerate = 30);
|
||||
// Checking of recivig of new frame from video device with deviceID
|
||||
bool isFrameNew(int deviceID);
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
void waitForDevice(int deviceID);
|
||||
#endif
|
||||
// Writing of Raw Data pixels from video device with deviceID with correction of RedAndBlue flipping flipRedAndBlue and vertical flipping flipImage
|
||||
@@ -1237,7 +1237,7 @@ ImageGrabber::~ImageGrabber(void)
|
||||
DebugPrintOut(L"IMAGEGRABBER VIDEODEVICE %i: Destroying instance of the ImageGrabber class\n", ig_DeviceID);
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
|
||||
ImageGrabberWinRT::ImageGrabberWinRT(bool synchronous):
|
||||
ImageGrabberCallback(synchronous),
|
||||
@@ -1899,7 +1899,7 @@ Media_Foundation::~Media_Foundation(void)
|
||||
bool Media_Foundation::buildListOfDevices()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
videoDevices *vDs = &videoDevices::getInstance();
|
||||
hr = vDs->initDevices(WRL_ENUM_GET(_DeviceClass, DeviceClass, VideoCapture));
|
||||
#else
|
||||
@@ -1987,7 +1987,7 @@ unsigned char * RawImage::getpPixels()
|
||||
videoDevice::videoDevice(void): vd_IsSetuped(false), vd_LockOut(OpenLock), vd_pFriendlyName(NULL),
|
||||
vd_Width(0), vd_Height(0), vd_FrameRate(0), vd_pSource(NULL), vd_pImGrTh(NULL), vd_func(NULL), vd_userData(NULL)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
vd_pMedCap = nullptr;
|
||||
vd_cookie.value = 0;
|
||||
vd_pImGr = NULL;
|
||||
@@ -2075,7 +2075,7 @@ CamParametrs videoDevice::getParametrs()
|
||||
return out;
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
long videoDevice::resetDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice)
|
||||
#else
|
||||
long videoDevice::resetDevice(IMFActivate *pActivate)
|
||||
@@ -2086,7 +2086,7 @@ long videoDevice::resetDevice(IMFActivate *pActivate)
|
||||
if(vd_pFriendlyName)
|
||||
CoTaskMemFree(vd_pFriendlyName);
|
||||
vd_pFriendlyName = NULL;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
if (pDevice)
|
||||
{
|
||||
ACTIVATE_OBJ(RuntimeClass_Windows_Media_Capture_MediaCapture, _MediaCapture, pIMedCap, hr)
|
||||
@@ -2157,7 +2157,7 @@ long videoDevice::resetDevice(IMFActivate *pActivate)
|
||||
return hr;
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
long videoDevice::readInfoOfDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice, unsigned int Num)
|
||||
{
|
||||
HRESULT hr = -1;
|
||||
@@ -2173,7 +2173,7 @@ long videoDevice::readInfoOfDevice(IMFActivate *pActivate, unsigned int Num)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
long videoDevice::checkDevice(_DeviceClass devClass, DEFINE_TASK<void>* pTask, MAKE_WRL_REF(_IDeviceInformation)* ppDevice)
|
||||
{
|
||||
@@ -2273,7 +2273,7 @@ long videoDevice::initDevice()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
CoInitialize(NULL);
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
Concurrency::critical_section::scoped_lock _LockHolder(vd_lock);
|
||||
MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction;
|
||||
@@ -2381,7 +2381,7 @@ void videoDevice::closeDevice()
|
||||
{
|
||||
vd_IsSetuped = false;
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
if (DEREF_AGILE_WRL_OBJ(vd_pMedCap)) {
|
||||
MAKE_WRL_REF(_AsyncAction) action;
|
||||
@@ -2535,7 +2535,7 @@ void videoDevice::buildLibraryofTypes()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
long videoDevice::setDeviceFormat(MAKE_WRL_REF(_MediaCapture) pSource, unsigned long dwFormatIndex, MAKE_WRL_REF(_AsyncAction)* pAction)
|
||||
{
|
||||
HRESULT hr;
|
||||
@@ -2596,7 +2596,7 @@ bool videoDevice::isDeviceSetup()
|
||||
RawImage * videoDevice::getRawImageOut()
|
||||
{
|
||||
if(!vd_IsSetuped) return NULL;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
if(vd_pImGr) return vd_pImGr->getRawImage();
|
||||
#endif
|
||||
if(vd_pImGrTh)
|
||||
@@ -2618,7 +2618,7 @@ bool videoDevice::isFrameNew()
|
||||
vd_LockOut = RawDataLock;
|
||||
|
||||
//must already be closed
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
if (DEREF_AGILE_WRL_OBJ(vd_pMedCap)) {
|
||||
MAKE_WRL_REF(_AsyncAction) action;
|
||||
if (FAILED(ImageGrabberWinRT::CreateInstance(&vd_pImGr))) return false;
|
||||
@@ -2649,7 +2649,7 @@ bool videoDevice::isFrameNew()
|
||||
vd_pImGrTh->start();
|
||||
return true;
|
||||
}
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
if(vd_pImGr)
|
||||
return vd_pImGr->getRawImage()->isNew();
|
||||
#endif
|
||||
@@ -2678,7 +2678,7 @@ bool videoDevice::setupDevice(unsigned int id)
|
||||
HRESULT hr = initDevice();
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
Concurrency::critical_section::scoped_lock _LockHolder(vd_lock);
|
||||
MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction;
|
||||
@@ -2692,7 +2692,7 @@ bool videoDevice::setupDevice(unsigned int id)
|
||||
vd_Height = vd_CurrentFormats[id].height;
|
||||
vd_FrameRate = vd_CurrentFormats[id].MF_MT_FRAME_RATE_NUMERATOR /
|
||||
vd_CurrentFormats[id].MF_MT_FRAME_RATE_DENOMINATOR;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
if (DEREF_AGILE_WRL_OBJ(vd_pMedCap)) {
|
||||
DEFINE_TASK<void> _task;
|
||||
@@ -2710,7 +2710,7 @@ bool videoDevice::setupDevice(unsigned int id)
|
||||
if(vd_IsSetuped)
|
||||
DebugPrintOut(L"\n\nVIDEODEVICE %i: Device is setuped \n", vd_CurrentNumber);
|
||||
vd_PrevParametrs = getParametrs();
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
END_CREATE_ASYNC(hr));
|
||||
#endif
|
||||
@@ -2749,7 +2749,7 @@ wchar_t *videoDevice::getName()
|
||||
videoDevice::~videoDevice(void)
|
||||
{
|
||||
closeDevice();
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
RELEASE_WRL(vd_pMedCap)
|
||||
#endif
|
||||
SafeRelease(&vd_pSource);
|
||||
@@ -2757,7 +2757,7 @@ videoDevice::~videoDevice(void)
|
||||
CoTaskMemFree(vd_pFriendlyName);
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
HRESULT videoDevice::enumerateCaptureFormats(MAKE_WRL_REF(_MediaCapture) pSource)
|
||||
{
|
||||
HRESULT hr;
|
||||
@@ -2831,7 +2831,7 @@ done:
|
||||
|
||||
videoDevices::videoDevices(void): count(0)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
vds_enumTask = nullptr;
|
||||
#endif
|
||||
}
|
||||
@@ -2862,7 +2862,7 @@ videoDevice * videoDevices::getDevice(unsigned int i)
|
||||
return vds_Devices[i];
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
long videoDevices::initDevices(_DeviceClass devClass)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
@@ -3196,7 +3196,7 @@ bool videoInput::isFrameNew(int deviceID)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
void videoInput::waitForDevice(int deviceID)
|
||||
{
|
||||
if (deviceID < 0)
|
||||
@@ -3405,7 +3405,7 @@ unsigned int videoInput::listDevices(bool silent)
|
||||
if(accessToDevices)
|
||||
{
|
||||
videoDevices *VDS = &videoDevices::getInstance();
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
VDS->waitInit();
|
||||
#endif
|
||||
out = VDS->getCount();
|
||||
@@ -3595,7 +3595,7 @@ protected:
|
||||
int index, width, height, fourcc;
|
||||
IplImage* frame;
|
||||
videoInput VI;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
DEFINE_TASK<bool> openTask;
|
||||
Concurrency::critical_section lock;
|
||||
@@ -3643,7 +3643,7 @@ void CvCaptureCAM_MSMF::close()
|
||||
// Initialize camera input
|
||||
bool CvCaptureCAM_MSMF::open( int _index )
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
SAVE_CURRENT_CONTEXT(context);
|
||||
auto func = [_index, context, this](DEFINE_RET_VAL(bool)) -> DEFINE_RET_FORMAL(bool) {
|
||||
@@ -3656,14 +3656,14 @@ bool CvCaptureCAM_MSMF::open( int _index )
|
||||
if (devices == 0)
|
||||
return false;
|
||||
try_index = try_index < 0 ? 0 : (try_index > devices-1 ? devices-1 : try_index);
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
HRESULT hr;
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
BEGIN_CALL_IN_CONTEXT(hr, context, this, try_index)
|
||||
#endif
|
||||
#endif
|
||||
VI.setupDevice(try_index, 0, 0, 0); // With maximum frame size.
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
END_CALL_IN_CONTEXT_BASE
|
||||
VI.waitForDevice(try_index);
|
||||
@@ -3672,13 +3672,13 @@ bool CvCaptureCAM_MSMF::open( int _index )
|
||||
#endif
|
||||
#endif
|
||||
if( !VI.isFrameNew(try_index) )
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
hr = E_FAIL;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
index = try_index;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
END_CALL_IN_CONTEXT_BASE
|
||||
RET_VAL(true)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#define ICustomStreamSink StreamSink
|
||||
#ifndef __cplusplus_winrt
|
||||
|
||||
@@ -380,7 +380,7 @@ MAKE_ENUM(MFSTREAMSINK_MARKER_TYPE) StreamSinkMarkerTypePairs[] = {
|
||||
};
|
||||
MAKE_MAP(MFSTREAMSINK_MARKER_TYPE) StreamSinkMarkerTypeMap(StreamSinkMarkerTypePairs, StreamSinkMarkerTypePairs + sizeof(StreamSinkMarkerTypePairs) / sizeof(StreamSinkMarkerTypePairs[0]));
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
|
||||
#ifdef __cplusplus_winrt
|
||||
#define _ContextCallback Concurrency::details::_ContextCallback
|
||||
@@ -1070,7 +1070,7 @@ protected:
|
||||
};
|
||||
|
||||
class StreamSink :
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
public Microsoft::WRL::RuntimeClass<
|
||||
Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::ClassicCom>,
|
||||
IMFStreamSink,
|
||||
@@ -1100,7 +1100,7 @@ public:
|
||||
if (riid == IID_IMarshal) {
|
||||
return MarshalQI(riid, ppv);
|
||||
} else {
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
hr = RuntimeClassT::QueryInterface(riid, ppv);
|
||||
#else
|
||||
if (riid == IID_IUnknown || riid == IID_IMFStreamSink) {
|
||||
@@ -1126,7 +1126,7 @@ public:
|
||||
return hr;
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
STDMETHOD(RuntimeClassInitialize)() { return S_OK; }
|
||||
#else
|
||||
ULONG STDMETHODCALLTYPE AddRef()
|
||||
@@ -1177,7 +1177,7 @@ public:
|
||||
m_StartTime(0), m_fGetStartTimeFromSample(false), m_fWaitingForFirstSample(false),
|
||||
m_state(State_TypeNotSet), m_pParent(nullptr),
|
||||
m_imageWidthInPixels(0), m_imageHeightInPixels(0) {
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
m_token.value = 0;
|
||||
#else
|
||||
m_bConnected = false;
|
||||
@@ -1856,7 +1856,7 @@ public:
|
||||
return hr;
|
||||
}
|
||||
private:
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
EventRegistrationToken m_token;
|
||||
#else
|
||||
bool m_bConnected;
|
||||
@@ -1864,7 +1864,7 @@ private:
|
||||
|
||||
bool m_IsShutdown; // Flag to indicate if Shutdown() method was called.
|
||||
CRITICAL_SECTION m_critSec;
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
long m_cRef;
|
||||
#endif
|
||||
IMFAttributes* m_pParent;
|
||||
@@ -2408,7 +2408,7 @@ protected:
|
||||
extern const __declspec(selectany) WCHAR RuntimeClass_CV_MediaSink[] = L"cv.MediaSink";
|
||||
|
||||
class MediaSink :
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
public Microsoft::WRL::RuntimeClass<
|
||||
Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >,
|
||||
Microsoft::WRL::Implements<ABI::Windows::Media::IMediaExtension>,
|
||||
@@ -2420,7 +2420,7 @@ class MediaSink :
|
||||
public IMFMediaSink, public IMFClockStateSink, public CBaseAttributes<>
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
InspectableClass(RuntimeClass_CV_MediaSink, BaseTrust)
|
||||
public:
|
||||
#else
|
||||
@@ -2488,7 +2488,7 @@ public:
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
STDMETHODIMP SetProperties(ABI::Windows::Foundation::Collections::IPropertySet *pConfiguration)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
@@ -2828,7 +2828,7 @@ public:
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
pStream = Microsoft::WRL::Make<StreamSink>();
|
||||
if (pStream == nullptr) {
|
||||
hr = E_OUTOFMEMORY;
|
||||
@@ -2940,7 +2940,7 @@ public:
|
||||
{
|
||||
hr = m_streams.Remove(pos, nullptr);
|
||||
_ComPtr<ICustomStreamSink> spCustomSink;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
spCustomSink = static_cast<StreamSink*>(spStream.Get());
|
||||
hr = S_OK;
|
||||
#else
|
||||
@@ -3164,7 +3164,7 @@ public:
|
||||
{
|
||||
_ComPtr<ICustomStreamSink> spCustomSink;
|
||||
HRESULT hr;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
spCustomSink = static_cast<StreamSink*>(pStream);
|
||||
#else
|
||||
hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf()));
|
||||
@@ -3187,7 +3187,7 @@ public:
|
||||
{
|
||||
_ComPtr<ICustomStreamSink> spCustomSink;
|
||||
HRESULT hr;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
spCustomSink = static_cast<StreamSink*>(pStream);
|
||||
#else
|
||||
hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf()));
|
||||
@@ -3207,7 +3207,7 @@ public:
|
||||
{
|
||||
_ComPtr<ICustomStreamSink> spCustomSink;
|
||||
HRESULT hr;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
spCustomSink = static_cast<StreamSink*>(pStream);
|
||||
#else
|
||||
hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf()));
|
||||
@@ -3317,7 +3317,7 @@ public:
|
||||
return hr;
|
||||
}
|
||||
private:
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
long m_cRef;
|
||||
#endif
|
||||
CRITICAL_SECTION m_critSec;
|
||||
@@ -3327,6 +3327,6 @@ private:
|
||||
LONGLONG m_llStartTime;
|
||||
};
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
ActivatableClass(MediaSink);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user