diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index c2fda8fad6..3f7dfdc6d6 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -850,7 +850,7 @@ macro(ocv_create_module) set(the_module_target ${the_module}) endif() - if(WINRT) + if(WINRT AND BUILD_TESTS) # removing APPCONTAINER from modules to run from console # in case of usual starting of WinRT test apps output is missing # so starting of console version w/o APPCONTAINER is required to get test results diff --git a/doc/js_tutorials/js_setup/js_setup/js_setup.markdown b/doc/js_tutorials/js_setup/js_setup/js_setup.markdown index 5f6b43b167..5036fd1d97 100644 --- a/doc/js_tutorials/js_setup/js_setup/js_setup.markdown +++ b/doc/js_tutorials/js_setup/js_setup/js_setup.markdown @@ -7,6 +7,9 @@ Installing Emscripten [Emscripten](https://github.com/kripken/emscripten) is an LLVM-to-JavaScript compiler. We will use Emscripten to build OpenCV.js. +@note +While this describes installation of required tools from scratch, there's a section below also describing an alternative procedure to perform the same build using docker containers which is often easier. + To Install Emscripten, follow instructions of [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). For example: @@ -103,3 +106,25 @@ Building OpenCV.js from Source @note It requires `node` installed in your development environment. + +Building OpenCV.js with Docker +--------------------------------------- + +Alternatively, the same build can be can be accomplished using [docker](https://www.docker.com/) containers which is often easier and more reliable, particularly in non linux systems. You only need to install [docker](https://www.docker.com/) on your system and use a popular container that provides a clean well tested environment for emscripten builds like this, that already has latest versions of all the necessary tools installed. + +So, make sure [docker](https://www.docker.com/) is installed in your system and running. The following shell script should work in linux and MacOS: + +@code{.bash} +git clone https://github.com/opencv/opencv.git +cd opencv +docker run --rm --workdir /code -v "$PWD":/code "trzeci/emscripten:latest" python ./platforms/js/build_js.py build_js +@endcode + +In Windows use the following PowerShell command: + +@code{.bash} +docker run --rm --workdir /code -v "$(get-location):/code" "trzeci/emscripten:latest" python ./platforms/js/build_js.py build_js +@endcode + +@note +The example uses latest version of [trzeci/emscripten](https://hub.docker.com/r/trzeci/emscripten) docker container. At this time, the latest version works fine and is `trzeci/emscripten:sdk-tag-1.38.32-64bit` diff --git a/modules/core/src/utils/datafile.cpp b/modules/core/src/utils/datafile.cpp index 257d27b738..088ad1ce79 100644 --- a/modules/core/src/utils/datafile.cpp +++ b/modules/core/src/utils/datafile.cpp @@ -108,7 +108,7 @@ static cv::String getModuleLocation(const void* addr) CV_UNUSED(addr); #ifdef _WIN32 HMODULE m = 0; -#if _WIN32_WINNT >= 0x0501 +#if _WIN32_WINNT >= 0x0501 && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) ::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(addr), &m); diff --git a/modules/flann/include/opencv2/flann/dist.h b/modules/flann/include/opencv2/flann/dist.h index 0670122c16..4246a3dffc 100644 --- a/modules/flann/include/opencv2/flann/dist.h +++ b/modules/flann/include/opencv2/flann/dist.h @@ -441,7 +441,7 @@ struct Hamming result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0); result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2); } -#elif __GNUC__ +#elif defined(__GNUC__) { //for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll) typedef unsigned long long pop_t; diff --git a/modules/highgui/src/roiSelector.cpp b/modules/highgui/src/roiSelector.cpp index d8ca58047e..4fba07eacb 100644 --- a/modules/highgui/src/roiSelector.cpp +++ b/modules/highgui/src/roiSelector.cpp @@ -106,10 +106,10 @@ class ROISelector bool isDrawing; Rect2d box; Mat image; + Point2f startPos; // parameters for drawing from the center bool drawFromCenter; - Point2f center; // initializer list handlerT() : isDrawing(false), drawFromCenter(true){}; @@ -136,19 +136,31 @@ class ROISelector { if (selectorParams.drawFromCenter) { - selectorParams.box.width = 2 * (x - selectorParams.center.x); - selectorParams.box.height = 2 * (y - selectorParams.center.y); - selectorParams.box.x = std::min( - std::max(selectorParams.center.x - selectorParams.box.width / 2.0, 0.), (double)imageSize.width); - selectorParams.box.y = std::min( - std::max(selectorParams.center.y - selectorParams.box.height / 2.0, 0.), (double)imageSize.height); + // limit half extends to imageSize + float halfWidth = std::min(std::min( + std::abs(x - selectorParams.startPos.x), + selectorParams.startPos.x), + imageSize.width - selectorParams.startPos.x); + float halfHeight = std::min(std::min( + std::abs(y - selectorParams.startPos.y), + selectorParams.startPos.y), + imageSize.height - selectorParams.startPos.y); + + selectorParams.box.width = halfWidth * 2; + selectorParams.box.height = halfHeight * 2; + selectorParams.box.x = selectorParams.startPos.x - halfWidth; + selectorParams.box.y = selectorParams.startPos.y - halfHeight; + } else { - selectorParams.box.width = std::max( - std::min(x - selectorParams.box.x, (double)imageSize.width - selectorParams.box.x), - selectorParams.box.x); - selectorParams.box.height = std::max( - std::min(y - selectorParams.box.y, (double)imageSize.height - selectorParams.box.y), - selectorParams.box.y); + // limit x and y to imageSize + int lx = std::min(std::max(x, 0), imageSize.width); + int by = std::min(std::max(y, 0), imageSize.height); + selectorParams.box.width = std::abs(lx - selectorParams.startPos.x); + selectorParams.box.height = std::abs(by - selectorParams.startPos.y); + selectorParams.box.x = std::min((float)lx, selectorParams.startPos.x); + selectorParams.box.y = std::min((float)by, selectorParams.startPos.y); } } break; @@ -157,7 +169,7 @@ class ROISelector case EVENT_LBUTTONDOWN: selectorParams.isDrawing = true; selectorParams.box = Rect2d(x, y, 0, 0); - selectorParams.center = Point2f((float)x, (float)y); + selectorParams.startPos = Point2f((float)x, (float)y); break; // cleaning up the selected bounding box diff --git a/modules/videoio/src/cap_ffmpeg.cpp b/modules/videoio/src/cap_ffmpeg.cpp index df7e44647b..67ee2e636d 100644 --- a/modules/videoio/src/cap_ffmpeg.cpp +++ b/modules/videoio/src/cap_ffmpeg.cpp @@ -80,7 +80,7 @@ static cv::Mutex _icvInitFFMPEG_mutex; static const HMODULE cv_GetCurrentModule() { HMODULE h = 0; -#if _WIN32_WINNT >= 0x0501 +#if _WIN32_WINNT >= 0x0501 && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) ::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(cv_GetCurrentModule), &h); diff --git a/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp b/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp index 236e22766e..eccf97e979 100644 --- a/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp +++ b/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp @@ -94,7 +94,7 @@ Media::CaptureFrameGrabber::~CaptureFrameGrabber() void Media::CaptureFrameGrabber::ShowCameraSettings() { -#if WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP +#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) && (WINAPI_FAMILY != WINAPI_FAMILY_PC_APP) if (_state == State::Started) { CameraOptionsUI::Show(_capture.Get());