mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
Merge pull request #15234 from alalek:backport
This commit is contained in:
commit
365323afec
@ -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
|
||||
|
@ -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`
|
||||
|
@ -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<LPCTSTR>(addr),
|
||||
&m);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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<LPCTSTR>(cv_GetCurrentModule),
|
||||
&h);
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user