From cdd23440c9d7ac94d3b4ca1fdd5a11996a74d9ff Mon Sep 17 00:00:00 2001 From: Maxim Kostin Date: Fri, 20 Feb 2015 19:47:45 +0300 Subject: [PATCH] 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 --- .gitignore | 9 +++ 3rdparty/libpng/CMakeLists.txt | 4 -- 3rdparty/libpng/opencv-libpng.patch | 4 +- 3rdparty/libpng/pngpriv.h | 4 +- 3rdparty/libtiff/CMakeLists.txt | 4 +- CMakeLists.txt | 94 +++++++++++++++------------ cmake/OpenCVCRTLinkage.cmake | 60 +++++++---------- cmake/OpenCVConfig.cmake | 3 + cmake/OpenCVDetectCXXCompiler.cmake | 3 + cmake/templates/cvconfig.h.in | 3 - modules/core/CMakeLists.txt | 11 ++-- modules/core/src/glob.cpp | 10 +-- modules/core/src/ocl.cpp | 16 ++++- modules/core/src/parallel.cpp | 4 +- modules/core/src/system.cpp | 16 ++--- modules/cudaarithm/CMakeLists.txt | 2 +- modules/cudacodec/CMakeLists.txt | 2 +- modules/cudafeatures2d/CMakeLists.txt | 2 +- modules/cudafilters/CMakeLists.txt | 2 +- modules/cudaimgproc/CMakeLists.txt | 2 +- modules/cudaoptflow/CMakeLists.txt | 2 +- modules/cudastereo/CMakeLists.txt | 2 +- modules/cudawarping/CMakeLists.txt | 2 +- modules/highgui/CMakeLists.txt | 7 +- modules/imgcodecs/CMakeLists.txt | 6 +- modules/java/CMakeLists.txt | 2 +- modules/python/CMakeLists.txt | 2 +- modules/superres/CMakeLists.txt | 2 +- modules/ts/CMakeLists.txt | 2 +- modules/ts/include/opencv2/ts.hpp | 2 +- modules/videoio/CMakeLists.txt | 6 +- modules/videoio/src/cap_ffmpeg.cpp | 2 +- modules/videoio/src/cap_msmf.cpp | 74 ++++++++++----------- modules/videoio/src/cap_msmf.hpp | 36 +++++----- 34 files changed, 217 insertions(+), 185 deletions(-) diff --git a/.gitignore b/.gitignore index 741704db83..228365d9eb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,12 @@ Thumbs.db tags tegra/ +bin/ +CMakeFiles/ +*.sdf +*.opensdf +*.obj +*.stamp +*.depend +*.rule +*.tmp diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt index 7e0243c456..c5a93ea8b6 100644 --- a/3rdparty/libpng/CMakeLists.txt +++ b/3rdparty/libpng/CMakeLists.txt @@ -29,10 +29,6 @@ if(MSVC) add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif(MSVC) -if (HAVE_WINRT) - add_definitions(-DHAVE_WINRT) -endif() - add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs}) target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES}) diff --git a/3rdparty/libpng/opencv-libpng.patch b/3rdparty/libpng/opencv-libpng.patch index 6ca96392a0..9bc0b69037 100644 --- a/3rdparty/libpng/opencv-libpng.patch +++ b/3rdparty/libpng/opencv-libpng.patch @@ -7,7 +7,7 @@ index 07b2b0b..e7824b8 100644 /* Memory model/platform independent fns */ #ifndef PNG_ABORT -# ifdef _WINDOWS_ -+# if defined(_WINDOWS_) && !defined(HAVE_WINRT) ++# if defined(_WINDOWS_) && !defined(WINRT) # define PNG_ABORT() ExitProcess(0) # else # define PNG_ABORT() abort() @@ -16,7 +16,7 @@ index 07b2b0b..e7824b8 100644 # define png_memset _fmemset #else -# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */ -+# if defined(_WINDOWS_) && !defined(HAVE_WINRT) /* Favor Windows over C runtime fns */ ++# if defined(_WINDOWS_) && !defined(WINRT) /* Favor Windows over C runtime fns */ # define CVT_PTR(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr) # define png_strlen lstrlenA diff --git a/3rdparty/libpng/pngpriv.h b/3rdparty/libpng/pngpriv.h index e7824b839e..880d2996f3 100644 --- a/3rdparty/libpng/pngpriv.h +++ b/3rdparty/libpng/pngpriv.h @@ -360,7 +360,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; /* Memory model/platform independent fns */ #ifndef PNG_ABORT -# if defined(_WINDOWS_) && !defined(HAVE_WINRT) +# if defined(_WINDOWS_) && !defined(WINRT) # define PNG_ABORT() ExitProcess(0) # else # define PNG_ABORT() abort() @@ -378,7 +378,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; # define png_memcpy _fmemcpy # define png_memset _fmemset #else -# if defined(_WINDOWS_) && !defined(HAVE_WINRT) /* Favor Windows over C runtime fns */ +# if defined(_WINDOWS_) && !defined(WINRT) /* Favor Windows over C runtime fns */ # define CVT_PTR(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr) # define png_strlen lstrlenA diff --git a/3rdparty/libtiff/CMakeLists.txt b/3rdparty/libtiff/CMakeLists.txt index 7a974dbbce..ad8a466188 100644 --- a/3rdparty/libtiff/CMakeLists.txt +++ b/3rdparty/libtiff/CMakeLists.txt @@ -17,7 +17,7 @@ check_include_file(string.h HAVE_STRING_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(unistd.h HAVE_UNISTD_H) -if(WIN32 AND NOT HAVE_WINRT) +if(WIN32) set(USE_WIN32_FILEIO 1) endif() @@ -79,7 +79,7 @@ set(lib_srcs "${CMAKE_CURRENT_BINARY_DIR}/tif_config.h" ) -if(WIN32 AND NOT HAVE_WINRT) +if(WIN32) list(APPEND lib_srcs tif_win32.c) else() list(APPEND lib_srcs tif_unix.c) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e158e5692..02863f8a63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,12 @@ include(cmake/OpenCVMinDepVersions.cmake) if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3) cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +elseif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) + cmake_minimum_required(VERSION 3.1 FATAL_ERROR) + #Required to resolve linker error issues due to incompatibility with CMake v3.0+ policies. + #CMake fails to find _fseeko() which leads to subsequent linker error. + #See details here: http://www.cmake.org/Wiki/CMake/Policies + cmake_policy(VERSION 2.8) else() cmake_minimum_required(VERSION "${MIN_VER_CMAKE}" FATAL_ERROR) endif() @@ -33,6 +39,13 @@ else(NOT CMAKE_TOOLCHAIN_FILE) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory") endif(NOT CMAKE_TOOLCHAIN_FILE) +if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) + set(WINRT TRUE) +endif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) + +if(WINRT) + add_definitions(-DWINRT -DNO_GETENV) +endif() if(POLICY CMP0022) cmake_policy(SET CMP0022 OLD) @@ -120,66 +133,66 @@ endif() # Optional 3rd party components # =================================================== -OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (NOT ANDROID AND NOT IOS) ) +OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O" ON IF IOS) OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE ) -OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" ON IF (NOT ANDROID AND NOT IOS) ) -OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (NOT IOS) ) -OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (NOT IOS) ) -OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (NOT IOS) ) +OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" OFF IF (NOT IOS AND NOT APPLE) ) -OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON) +OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON IF (NOT WINRT) ) OCV_OPTION(WITH_VFW "Include Video for Windows support" ON IF WIN32 ) -OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS)) +OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT ANDROID) ) OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF ) OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) ) -OCV_OPTION(WITH_IPP "Include Intel IPP support" ON IF (X86_64 OR X86) ) +OCV_OPTION(WITH_IPP "Include Intel IPP support" ON IF (X86_64 OR X86) AND NOT WINRT) OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) ) OCV_OPTION(WITH_JPEG "Include JPEG support" ON) -OCV_OPTION(WITH_WEBP "Include WebP support" ON IF (NOT IOS) ) -OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) ) -OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID) ) -OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) ) -OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS) ) +OCV_OPTION(WITH_WEBP "Include WebP support" ON IF (NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT WINRT) ) +OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_PNG "Include PNG support" ON) -OCV_OPTION(WITH_PVAPI "Include Prosilica 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_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 ) +OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 AND NOT WINRT) 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 AND NOT WINRT) ) OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF) -OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 ) +OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF (WIN32 AND NOT WINRT) ) OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) ) OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) ) OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) ) -OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM) ) +OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM AND NOT WINRT) ) OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" OFF IF WIN32 ) -OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID) ) +OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT WINRT) ) OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF) -OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" NOT ANDROID IF (NOT IOS) ) +OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" NOT ANDROID IF (NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_OPENCL_SVM "Include OpenCL Shared Virtual Memory support" OFF ) # experimental -OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON IF (NOT ANDROID AND NOT IOS) ) -OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON IF (NOT ANDROID AND NOT IOS) ) -OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON IF WIN32 ) -OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF WIN32 ) +OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) +OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON IF (WIN32 AND NOT WINRT) ) +OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF (WIN32 AND NOT WINRT) ) OCV_OPTION(WITH_IPP_A "Include Intel IPP_A support" OFF IF (MSVC OR X86 OR X86_64) ) -OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS) ) +OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) # OpenCV build components # =================================================== OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) ) -OCV_OPTION(BUILD_opencv_apps "Build utility applications (used for example to train classifiers)" (NOT ANDROID) IF (NOT IOS) ) +OCV_OPTION(BUILD_opencv_apps "Build utility applications (used for example to train classifiers)" (NOT ANDROID AND NOT WINRT) IF (NOT IOS) ) OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID ) -OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON ) +OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON IF NOT WINRT) OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF ) -OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON ) -OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS) ) -OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) ) +OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON IF NOT WINRT) +OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS AND NOT WINRT) ) +OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS AND NOT WINRT) ) OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON ) OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC ) OCV_OPTION(BUILD_WITH_DYNAMIC_IPP "Enables dynamic linking of IPP (only for standalone IPP)" OFF ) @@ -194,7 +207,7 @@ OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 O OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR ANDROID OR APPLE ) OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR ANDROID OR APPLE ) OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE ) -OCV_OPTION(BUILD_OPENEXR "Build openexr from source" WIN32 OR ANDROID OR APPLE ) +OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (WIN32 OR ANDROID OR APPLE) AND NOT WINRT) OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID ) # OpenCV installation options @@ -229,8 +242,6 @@ OCV_OPTION(ENABLE_NEON "Enable NEON instructions" OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) ) OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF ) OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF ) -OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 ) -OCV_OPTION(ENABLE_WINRT_MODE_NATIVE "Build with Windows Runtime native C++ support" OFF IF WIN32 ) OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with native libraries" OFF IF ANDROID ) OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function call" OFF ) @@ -759,11 +770,12 @@ endif() # ================== Windows RT features ================== if(WIN32) status("") - status(" Windows RT support:" HAVE_WINRT THEN YES ELSE NO) - if (ENABLE_WINRT_MODE OR ENABLE_WINRT_MODE_NATIVE) - status(" Windows SDK v8.0:" ${WINDOWS_SDK_PATH}) - status(" Visual Studio 2012:" ${VISUAL_STUDIO_PATH}) - endif() +status(" Windows RT support:" WINRT THEN YES ELSE NO) + if(WINRT) + status(" Building for Microsoft platform: " ${CMAKE_SYSTEM_NAME}) + status(" Building for architectures: " ${CMAKE_VS_EFFECTIVE_PLATFORMS}) + status(" Building for version: " ${CMAKE_SYSTEM_VERSION}) + endif() endif(WIN32) # ========================== GUI ========================== @@ -913,7 +925,7 @@ endif(DEFINED WITH_OPENNI) if(DEFINED WITH_OPENNI2) status(" OpenNI2:" HAVE_OPENNI2 THEN "YES (ver ${OPENNI2_VERSION_STRING}, build ${OPENNI2_VERSION_BUILD})" - ELSE NO) + ELSE NO) endif(DEFINED WITH_OPENNI2) if(DEFINED WITH_PVAPI) diff --git a/cmake/OpenCVCRTLinkage.cmake b/cmake/OpenCVCRTLinkage.cmake index 7b7fcad7ec..2168c72e65 100644 --- a/cmake/OpenCVCRTLinkage.cmake +++ b/cmake/OpenCVCRTLinkage.cmake @@ -2,47 +2,37 @@ if(NOT MSVC) message(FATAL_ERROR "CRT options are available only for MSVC") endif() -#INCLUDE (CheckIncludeFiles) +#if (${CMAKE_SYSTEM_NAME} MATCHES "WindowsStore" OR ${CMAKE_SYSTEM_NAME} MATCHES "WindowsPhone") +# set(WINRT TRUE) -set(HAVE_WINRT FALSE) - -# search Windows Platform SDK -message(STATUS "Checking for Windows Platform SDK") -GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE) -if(WINDOWS_SDK_PATH STREQUAL "") - set(HAVE_MSPDK FALSE) - message(STATUS "Windows Platform SDK 8.0 was not found") -else() - set(HAVE_MSPDK TRUE) +if (WINRT) + add_definitions(/DWINVER=_WIN32_WINNT_WIN8 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=_WIN32_WINNT_WIN8) endif() -#search for Visual Studio 11.0 install directory -message(STATUS "Checking for Visual Studio 2012") -GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE) -if(VISUAL_STUDIO_PATH STREQUAL "") - set(HAVE_MSVC2012 FALSE) - message(STATUS "Visual Studio 2012 was not found") -else() - set(HAVE_MSVC2012 TRUE) -endif() +# Removing LNK4075 warnings for debug WinRT builds +# "LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification" +# "LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" +if(MSVC AND WINRT) + # Optional verification checks since we don't know existing contents of variables below + string(REPLACE "/OPT:ICF " "/OPT:NOICF " CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + string(REPLACE "/OPT:REF " "/OPT:NOREF " CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + string(REPLACE "/INCREMENTAL:YES " "/INCREMENTAL:NO " CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") -try_compile(HAVE_WINRT_SDK - "${OpenCV_BINARY_DIR}" - "${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp") + string(REPLACE "/OPT:ICF " "/OPT:NOICF " CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}") + string(REPLACE "/OPT:REF " "/OPT:NORE F" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}") + string(REPLACE "/INCREMENTAL:YES " "/INCREMENTAL:NO " CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}") + string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}") -if(ENABLE_WINRT_MODE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK) - set(HAVE_WINRT TRUE) - set(HAVE_WINRT_CX TRUE) -elseif(ENABLE_WINRT_MODE_NATIVE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK) - set(HAVE_WINRT TRUE) - set(HAVE_WINRT_CX FALSE) -endif() + string(REPLACE "/OPT:ICF " "/OPT:NOICF " CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") + string(REPLACE "/OPT:REF " "/OPT:NOREF " CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") + string(REPLACE "/INCREMENTAL:YES " "/INCREMENTAL:NO " CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") + string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") -if(HAVE_WINRT) - add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /appcontainer") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /appcontainer") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /appcontainer") + # Mandatory + set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF") + set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF") endif() if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) diff --git a/cmake/OpenCVConfig.cmake b/cmake/OpenCVConfig.cmake index 38117248af..dfd7e8f268 100644 --- a/cmake/OpenCVConfig.cmake +++ b/cmake/OpenCVConfig.cmake @@ -65,6 +65,9 @@ if(MSVC) if(CMAKE_CL_64) set(OpenCV_ARCH x64) set(OpenCV_TBB_ARCH intel64) + elseif((CMAKE_GENERATOR MATCHES "ARM") OR ("${arch_hint}" STREQUAL "ARM") OR (CMAKE_VS_EFFECTIVE_PLATFORMS MATCHES "ARM|arm")) + # see Modules/CmakeGenericSystem.cmake + set(OpenCV_ARCH ARM) else() set(OpenCV_ARCH x86) set(OpenCV_TBB_ARCH ia32) diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake index 55156ddf88..72d939917a 100644 --- a/cmake/OpenCVDetectCXXCompiler.cmake +++ b/cmake/OpenCVDetectCXXCompiler.cmake @@ -127,6 +127,9 @@ endif() if(MSVC) if(CMAKE_CL_64) set(OpenCV_ARCH x64) + elseif((CMAKE_GENERATOR MATCHES "ARM") OR ("${arch_hint}" STREQUAL "ARM") OR (CMAKE_VS_EFFECTIVE_PLATFORMS MATCHES "ARM|arm")) + # see Modules/CmakeGenericSystem.cmake + set(OpenCV_ARCH ARM) else() set(OpenCV_ARCH x86) endif() diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index f8c1c40357..9900eaeaf6 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -169,9 +169,6 @@ /* Win32 UI */ #cmakedefine HAVE_WIN32UI -/* Windows Runtime support */ -#cmakedefine HAVE_WINRT - /* XIMEA camera support */ #cmakedefine HAVE_XIMEA diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 5158dec5f4..f3ef9a7c4c 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -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() diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp index 93dc72ff81..e0c7f66a3a 100644 --- a/modules/core/src/glob.cpp +++ b/modules/core/src/glob.cpp @@ -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)); diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index f7117d8a71..094d87a40c 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -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 &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; diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 1fb980d922..4dde2adeae 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -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 ); diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 8008746f5d..f1080912ed 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -109,7 +109,7 @@ #endif #endif -#ifdef HAVE_WINRT +#ifdef WINRT #include #ifndef __cplusplus_winrt #include @@ -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 diff --git a/modules/cudaarithm/CMakeLists.txt b/modules/cudaarithm/CMakeLists.txt index e13bb7b72b..29155560ef 100644 --- a/modules/cudaarithm/CMakeLists.txt +++ b/modules/cudaarithm/CMakeLists.txt @@ -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() diff --git a/modules/cudacodec/CMakeLists.txt b/modules/cudacodec/CMakeLists.txt index 31877e864f..f2e955b6cd 100644 --- a/modules/cudacodec/CMakeLists.txt +++ b/modules/cudacodec/CMakeLists.txt @@ -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() diff --git a/modules/cudafeatures2d/CMakeLists.txt b/modules/cudafeatures2d/CMakeLists.txt index 861d22f279..af1945a250 100644 --- a/modules/cudafeatures2d/CMakeLists.txt +++ b/modules/cudafeatures2d/CMakeLists.txt @@ -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() diff --git a/modules/cudafilters/CMakeLists.txt b/modules/cudafilters/CMakeLists.txt index 93e821293d..04f2d19212 100644 --- a/modules/cudafilters/CMakeLists.txt +++ b/modules/cudafilters/CMakeLists.txt @@ -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() diff --git a/modules/cudaimgproc/CMakeLists.txt b/modules/cudaimgproc/CMakeLists.txt index 409ca6a232..84ee2f91ba 100644 --- a/modules/cudaimgproc/CMakeLists.txt +++ b/modules/cudaimgproc/CMakeLists.txt @@ -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() diff --git a/modules/cudaoptflow/CMakeLists.txt b/modules/cudaoptflow/CMakeLists.txt index 0469935500..5db2b096c2 100644 --- a/modules/cudaoptflow/CMakeLists.txt +++ b/modules/cudaoptflow/CMakeLists.txt @@ -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() diff --git a/modules/cudastereo/CMakeLists.txt b/modules/cudastereo/CMakeLists.txt index a00fa15ed1..982609b82f 100644 --- a/modules/cudastereo/CMakeLists.txt +++ b/modules/cudastereo/CMakeLists.txt @@ -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() diff --git a/modules/cudawarping/CMakeLists.txt b/modules/cudawarping/CMakeLists.txt index fa99e9d04b..5d0fa4ad93 100644 --- a/modules/cudawarping/CMakeLists.txt +++ b/modules/cudawarping/CMakeLists.txt @@ -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() diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 174a620020..006e764533 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -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() diff --git a/modules/imgcodecs/CMakeLists.txt b/modules/imgcodecs/CMakeLists.txt index 3d0110ef48..149cbcf9e8 100644 --- a/modules/imgcodecs/CMakeLists.txt +++ b/modules/imgcodecs/CMakeLists.txt @@ -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() diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index 1d7a467869..8bbc9a863e 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -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) diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index 5339efecf0..37673da345 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -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() diff --git a/modules/superres/CMakeLists.txt b/modules/superres/CMakeLists.txt index f85cf20736..9b731ef6cb 100644 --- a/modules/superres/CMakeLists.txt +++ b/modules/superres/CMakeLists.txt @@ -1,4 +1,4 @@ -if(IOS) +if(IOS OR WINRT) ocv_module_disable(superres) endif() diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index 9727c9a8c5..9d1e40c9c3 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -1,6 +1,6 @@ set(the_description "The ts module") -if(IOS) +if(IOS OR WINRT) ocv_module_disable(ts) endif() diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index c1b68a0c0f..8d1c2c0fd5 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -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 diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt index 1635e2022f..9f9f51e505 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -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() diff --git a/modules/videoio/src/cap_ffmpeg.cpp b/modules/videoio/src/cap_ffmpeg.cpp index f448ed8b88..b4348eaa05 100644 --- a/modules/videoio/src/cap_ffmpeg.cpp +++ b/modules/videoio/src/cap_ffmpeg.cpp @@ -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__) diff --git a/modules/videoio/src/cap_msmf.cpp b/modules/videoio/src/cap_msmf.cpp index 3d62eef287..7f4179a816 100644 --- a/modules/videoio/src/cap_msmf.cpp +++ b/modules/videoio/src/cap_msmf.cpp @@ -86,7 +86,7 @@ #include -#ifdef HAVE_WINRT +#ifdef WINRT // for ComPtr usage #include #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 vd_CaptureFormats; std::vector 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 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* 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 _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 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) diff --git a/modules/videoio/src/cap_msmf.hpp b/modules/videoio/src/cap_msmf.hpp index 352a491837..4fdf41fb31 100644 --- a/modules/videoio/src/cap_msmf.hpp +++ b/modules/videoio/src/cap_msmf.hpp @@ -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, @@ -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(); if (pStream == nullptr) { hr = E_OUTOFMEMORY; @@ -2940,7 +2940,7 @@ public: { hr = m_streams.Remove(pos, nullptr); _ComPtr spCustomSink; -#ifdef HAVE_WINRT +#ifdef WINRT spCustomSink = static_cast(spStream.Get()); hr = S_OK; #else @@ -3164,7 +3164,7 @@ public: { _ComPtr spCustomSink; HRESULT hr; -#ifdef HAVE_WINRT +#ifdef WINRT spCustomSink = static_cast(pStream); #else hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf())); @@ -3187,7 +3187,7 @@ public: { _ComPtr spCustomSink; HRESULT hr; -#ifdef HAVE_WINRT +#ifdef WINRT spCustomSink = static_cast(pStream); #else hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf())); @@ -3207,7 +3207,7 @@ public: { _ComPtr spCustomSink; HRESULT hr; -#ifdef HAVE_WINRT +#ifdef WINRT spCustomSink = static_cast(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