From 8d4d3087143b068b745746699407e67bfbae993e Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 5 Feb 2018 17:45:10 -0800 Subject: [PATCH] [opencv] Fix UWP and ARM --- ports/opencv/CONTROL | 2 +- ports/opencv/filesystem-uwp.patch | 41 +++++++++++++++++++++++++++++++ ports/opencv/portfile.cmake | 16 ++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 ports/opencv/filesystem-uwp.patch diff --git a/ports/opencv/CONTROL b/ports/opencv/CONTROL index e71ad109da..13a24f0b4f 100644 --- a/ports/opencv/CONTROL +++ b/ports/opencv/CONTROL @@ -1,5 +1,5 @@ Source: opencv -Version: 3.4.0 +Version: 3.4.0-1 Build-Depends: zlib, libpng, libjpeg-turbo, tiff, protobuf (windows) Description: computer vision library diff --git a/ports/opencv/filesystem-uwp.patch b/ports/opencv/filesystem-uwp.patch new file mode 100644 index 0000000000..c4ddb6b783 --- /dev/null +++ b/ports/opencv/filesystem-uwp.patch @@ -0,0 +1,41 @@ +diff --git a/modules/core/src/utils/filesystem.cpp b/modules/core/src/utils/filesystem.cpp +index 266a92f..1d5a302 100644 +--- a/modules/core/src/utils/filesystem.cpp ++++ b/modules/core/src/utils/filesystem.cpp +@@ -186,7 +186,7 @@ bool createDirectory(const cv::String& path) + wchar_t wpath[MAX_PATH]; + size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); +- int result = CreateDirectoryA(wpath, NULL) ? 0 : -1; ++ int result = CreateDirectoryW(wpath, NULL) ? 0 : -1; + #else + int result = _mkdir(path.c_str()); + #endif +@@ -248,8 +248,16 @@ struct FileLock::Impl + int numRetries = 5; + do + { ++#ifdef WINRT ++ wchar_t wpath[MAX_PATH]; ++ size_t copied = mbstowcs(wpath, fname, MAX_PATH); ++ CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); ++ handle = ::CreateFile2(wpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, ++ OPEN_EXISTING, NULL); ++#else + handle = ::CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ++#endif + if (INVALID_HANDLE_VALUE == handle) + { + if (ERROR_SHARING_VIOLATION == GetLastError()) +@@ -399,7 +407,9 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu + if (cache_path.empty()) + { + cv::String default_cache_path; +-#ifdef _WIN32 ++#if WINRT ++ // no defaults ++#elif defined _WIN32 + char tmp_path_buf[MAX_PATH+1] = {0}; + DWORD res = GetTempPath(MAX_PATH, tmp_path_buf); + if (res > 0 && res <= MAX_PATH) diff --git a/ports/opencv/portfile.cmake b/ports/opencv/portfile.cmake index a91020f245..10bea9db2b 100644 --- a/ports/opencv/portfile.cmake +++ b/ports/opencv/portfile.cmake @@ -68,6 +68,15 @@ if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set(WITH_MSMF OFF) endif() +set(BUILD_opencv_line_descriptor ON) +set(BUILD_opencv_saliency ON) +set(BUILD_opencv_bgsegm ON) +if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm") + set(BUILD_opencv_line_descriptor OFF) + set(BUILD_opencv_saliency OFF) + set(BUILD_opencv_bgsegm OFF) +endif() + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} OPTIONS @@ -94,6 +103,9 @@ vcpkg_configure_cmake( -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_opencv_sfm=${BUILD_opencv_sfm} + -DBUILD_opencv_line_descriptor=${BUILD_opencv_line_descriptor} + -DBUILD_opencv_saliency=${BUILD_opencv_saliency} + -DBUILD_opencv_bgsegm=${BUILD_opencv_bgsegm} # CMAKE -DCMAKE_DISABLE_FIND_PACKAGE_JNI=ON # ENABLE @@ -137,6 +149,10 @@ else() endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") set(OpenCV_ARCH x64) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") + set(OpenCV_ARCH ARM) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(OpenCV_ARCH ARM64) else() set(OpenCV_ARCH x86) endif()