node-native-win-utils 1.4.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -82
- package/binding.gyp +2 -0
- package/dist/dirnameLocal.cjs +4 -0
- package/dist/dirnameLocal.d.cts +1 -0
- package/dist/dirnameLocal.d.mts +1 -0
- package/dist/dirnameLocal.mjs +2 -0
- package/dist/{index.js → index.cjs} +83 -16
- package/dist/{index.d.ts → index.d.cts} +68 -17
- package/dist/index.d.mts +230 -0
- package/dist/index.mjs +212 -0
- package/dist/keyCodes.d.mts +101 -0
- package/dist/keyCodes.mjs +201 -0
- package/node22.json +16 -0
- package/package.json +19 -9
- package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
- package/src/cpp/keyboard.cpp +141 -140
- package/src/cpp/main.cpp +9 -3
- package/src/cpp/{capturewindow.cpp → screenshot.cpp} +174 -2
- package/src/dirnameLocal.mts +3 -0
- package/src/index.mts +455 -0
- package/src/keyCodes.mts +203 -0
- package/dllCopy.js +0 -14
- package/include/opencv2/core/affine.hpp +0 -678
- package/include/opencv2/core/async.hpp +0 -105
- package/include/opencv2/core/base.hpp +0 -664
- package/include/opencv2/core/bindings_utils.hpp +0 -325
- package/include/opencv2/core/bufferpool.hpp +0 -40
- package/include/opencv2/core/check.hpp +0 -170
- package/include/opencv2/core/core.hpp +0 -48
- package/include/opencv2/core/core_c.h +0 -3128
- package/include/opencv2/core/cuda/block.hpp +0 -211
- package/include/opencv2/core/cuda/border_interpolate.hpp +0 -722
- package/include/opencv2/core/cuda/color.hpp +0 -309
- package/include/opencv2/core/cuda/common.hpp +0 -131
- package/include/opencv2/core/cuda/datamov_utils.hpp +0 -113
- package/include/opencv2/core/cuda/detail/color_detail.hpp +0 -2018
- package/include/opencv2/core/cuda/detail/reduce.hpp +0 -365
- package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +0 -502
- package/include/opencv2/core/cuda/detail/transform_detail.hpp +0 -392
- package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +0 -191
- package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +0 -121
- package/include/opencv2/core/cuda/dynamic_smem.hpp +0 -88
- package/include/opencv2/core/cuda/emulation.hpp +0 -269
- package/include/opencv2/core/cuda/filters.hpp +0 -293
- package/include/opencv2/core/cuda/funcattrib.hpp +0 -79
- package/include/opencv2/core/cuda/functional.hpp +0 -805
- package/include/opencv2/core/cuda/limits.hpp +0 -128
- package/include/opencv2/core/cuda/reduce.hpp +0 -209
- package/include/opencv2/core/cuda/saturate_cast.hpp +0 -292
- package/include/opencv2/core/cuda/scan.hpp +0 -258
- package/include/opencv2/core/cuda/simd_functions.hpp +0 -869
- package/include/opencv2/core/cuda/transform.hpp +0 -75
- package/include/opencv2/core/cuda/type_traits.hpp +0 -90
- package/include/opencv2/core/cuda/utility.hpp +0 -230
- package/include/opencv2/core/cuda/vec_distance.hpp +0 -232
- package/include/opencv2/core/cuda/vec_math.hpp +0 -923
- package/include/opencv2/core/cuda/vec_traits.hpp +0 -288
- package/include/opencv2/core/cuda/warp.hpp +0 -139
- package/include/opencv2/core/cuda/warp_reduce.hpp +0 -76
- package/include/opencv2/core/cuda/warp_shuffle.hpp +0 -162
- package/include/opencv2/core/cuda.hpp +0 -1279
- package/include/opencv2/core/cuda.inl.hpp +0 -763
- package/include/opencv2/core/cuda_stream_accessor.hpp +0 -86
- package/include/opencv2/core/cuda_types.hpp +0 -144
- package/include/opencv2/core/cv_cpu_dispatch.h +0 -381
- package/include/opencv2/core/cv_cpu_helper.h +0 -550
- package/include/opencv2/core/cvdef.h +0 -973
- package/include/opencv2/core/cvstd.hpp +0 -190
- package/include/opencv2/core/cvstd.inl.hpp +0 -197
- package/include/opencv2/core/cvstd_wrapper.hpp +0 -154
- package/include/opencv2/core/detail/async_promise.hpp +0 -71
- package/include/opencv2/core/detail/dispatch_helper.impl.hpp +0 -49
- package/include/opencv2/core/detail/exception_ptr.hpp +0 -27
- package/include/opencv2/core/directx.hpp +0 -184
- package/include/opencv2/core/dualquaternion.hpp +0 -979
- package/include/opencv2/core/dualquaternion.inl.hpp +0 -487
- package/include/opencv2/core/eigen.hpp +0 -402
- package/include/opencv2/core/fast_math.hpp +0 -433
- package/include/opencv2/core/hal/hal.hpp +0 -256
- package/include/opencv2/core/hal/interface.h +0 -190
- package/include/opencv2/core/hal/intrin.hpp +0 -939
- package/include/opencv2/core/hal/intrin_avx.hpp +0 -3177
- package/include/opencv2/core/hal/intrin_avx512.hpp +0 -3090
- package/include/opencv2/core/hal/intrin_cpp.hpp +0 -3321
- package/include/opencv2/core/hal/intrin_forward.hpp +0 -191
- package/include/opencv2/core/hal/intrin_lasx.hpp +0 -3236
- package/include/opencv2/core/hal/intrin_msa.hpp +0 -1887
- package/include/opencv2/core/hal/intrin_neon.hpp +0 -2610
- package/include/opencv2/core/hal/intrin_rvv.hpp +0 -3320
- package/include/opencv2/core/hal/intrin_rvv071.hpp +0 -2545
- package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +0 -2080
- package/include/opencv2/core/hal/intrin_sse.hpp +0 -3467
- package/include/opencv2/core/hal/intrin_sse_em.hpp +0 -180
- package/include/opencv2/core/hal/intrin_vsx.hpp +0 -1608
- package/include/opencv2/core/hal/intrin_wasm.hpp +0 -2782
- package/include/opencv2/core/hal/msa_macros.h +0 -1558
- package/include/opencv2/core/hal/simd_utils.impl.hpp +0 -186
- package/include/opencv2/core/llapi/llapi.h +0 -102
- package/include/opencv2/core/mat.hpp +0 -3775
- package/include/opencv2/core/mat.inl.hpp +0 -3422
- package/include/opencv2/core/matx.hpp +0 -1536
- package/include/opencv2/core/neon_utils.hpp +0 -128
- package/include/opencv2/core/ocl.hpp +0 -917
- package/include/opencv2/core/ocl_genbase.hpp +0 -69
- package/include/opencv2/core/opencl/ocl_defs.hpp +0 -82
- package/include/opencv2/core/opencl/opencl_info.hpp +0 -212
- package/include/opencv2/core/opencl/opencl_svm.hpp +0 -81
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +0 -602
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +0 -146
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +0 -371
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +0 -272
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +0 -62
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +0 -42
- package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +0 -53
- package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +0 -53
- package/include/opencv2/core/opencl/runtime/opencl_core.hpp +0 -84
- package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +0 -47
- package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +0 -53
- package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +0 -47
- package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +0 -48
- package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +0 -42
- package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +0 -166
- package/include/opencv2/core/opengl.hpp +0 -733
- package/include/opencv2/core/openvx/ovx_defs.hpp +0 -48
- package/include/opencv2/core/operations.hpp +0 -610
- package/include/opencv2/core/optim.hpp +0 -302
- package/include/opencv2/core/ovx.hpp +0 -28
- package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +0 -72
- package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +0 -153
- package/include/opencv2/core/parallel/parallel_backend.hpp +0 -90
- package/include/opencv2/core/persistence.hpp +0 -1350
- package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +0 -30
- package/include/opencv2/core/private.cuda.hpp +0 -169
- package/include/opencv2/core/private.hpp +0 -896
- package/include/opencv2/core/quaternion.hpp +0 -1696
- package/include/opencv2/core/quaternion.inl.hpp +0 -1063
- package/include/opencv2/core/saturate.hpp +0 -180
- package/include/opencv2/core/simd_intrinsics.hpp +0 -87
- package/include/opencv2/core/softfloat.hpp +0 -514
- package/include/opencv2/core/sse_utils.hpp +0 -652
- package/include/opencv2/core/traits.hpp +0 -417
- package/include/opencv2/core/types.hpp +0 -2457
- package/include/opencv2/core/types_c.h +0 -2126
- package/include/opencv2/core/utility.hpp +0 -1229
- package/include/opencv2/core/utils/allocator_stats.hpp +0 -29
- package/include/opencv2/core/utils/allocator_stats.impl.hpp +0 -158
- package/include/opencv2/core/utils/buffer_area.private.hpp +0 -136
- package/include/opencv2/core/utils/configuration.private.hpp +0 -22
- package/include/opencv2/core/utils/filesystem.hpp +0 -82
- package/include/opencv2/core/utils/filesystem.private.hpp +0 -66
- package/include/opencv2/core/utils/fp_control.private.hpp +0 -29
- package/include/opencv2/core/utils/fp_control_utils.hpp +0 -69
- package/include/opencv2/core/utils/instrumentation.hpp +0 -125
- package/include/opencv2/core/utils/lock.private.hpp +0 -119
- package/include/opencv2/core/utils/logger.defines.hpp +0 -42
- package/include/opencv2/core/utils/logger.hpp +0 -218
- package/include/opencv2/core/utils/logtag.hpp +0 -28
- package/include/opencv2/core/utils/plugin_loader.private.hpp +0 -165
- package/include/opencv2/core/utils/tls.hpp +0 -235
- package/include/opencv2/core/utils/trace.hpp +0 -252
- package/include/opencv2/core/utils/trace.private.hpp +0 -421
- package/include/opencv2/core/va_intel.hpp +0 -75
- package/include/opencv2/core/version.hpp +0 -26
- package/include/opencv2/core/vsx_utils.hpp +0 -1047
- package/include/opencv2/core.hpp +0 -3365
- package/include/opencv2/imgcodecs/imgcodecs.hpp +0 -48
- package/include/opencv2/imgcodecs/imgcodecs_c.h +0 -1
- package/include/opencv2/imgcodecs/ios.h +0 -59
- package/include/opencv2/imgcodecs/legacy/constants_c.h +0 -54
- package/include/opencv2/imgcodecs/macosx.h +0 -20
- package/include/opencv2/imgcodecs.hpp +0 -407
- package/include/opencv2/imgproc/bindings.hpp +0 -34
- package/include/opencv2/imgproc/detail/gcgraph.hpp +0 -395
- package/include/opencv2/imgproc/hal/hal.hpp +0 -246
- package/include/opencv2/imgproc/hal/interface.h +0 -46
- package/include/opencv2/imgproc/imgproc.hpp +0 -48
- package/include/opencv2/imgproc/imgproc_c.h +0 -1177
- package/include/opencv2/imgproc/segmentation.hpp +0 -141
- package/include/opencv2/imgproc/types_c.h +0 -659
- package/include/opencv2/imgproc.hpp +0 -5035
- package/include/opencv2/opencv_modules.hpp +0 -17
- package/include/tesseract/baseapi.h +0 -820
- package/include/tesseract/capi.h +0 -485
- package/include/tesseract/export.h +0 -37
- package/include/tesseract/ltrresultiterator.h +0 -235
- package/include/tesseract/ocrclass.h +0 -158
- package/include/tesseract/osdetect.h +0 -139
- package/include/tesseract/pageiterator.h +0 -364
- package/include/tesseract/publictypes.h +0 -281
- package/include/tesseract/renderer.h +0 -334
- package/include/tesseract/resultiterator.h +0 -250
- package/include/tesseract/tesseract.h +0 -40
- package/include/tesseract/unichar.h +0 -174
- package/include/tesseract/version.h +0 -34
- package/include/tesseract/version.h.in +0 -34
- package/libs/libjpeg-turbo.lib +0 -0
- package/libs/libpng.lib +0 -0
- package/libs/opencv_core470.lib +0 -0
- package/libs/opencv_imgcodecs470.lib +0 -0
- package/libs/opencv_imgproc470.lib +0 -0
- package/libs/tesseract.lib +0 -0
- package/libs/zlib.lib +0 -0
- /package/dist/{keyCodes.js → keyCodes.cjs} +0 -0
- /package/dist/{keyCodes.d.ts → keyCodes.d.cts} +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// This file is part of OpenCV project.
|
|
2
|
-
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
-
// of this distribution and at http://opencv.org/license.html.
|
|
4
|
-
|
|
5
|
-
// Copyright (C) 2016, Intel Corporation, all rights reserved.
|
|
6
|
-
// Third party copyrights are property of their respective owners.
|
|
7
|
-
|
|
8
|
-
// OpenVX related definitions and declarations
|
|
9
|
-
|
|
10
|
-
#pragma once
|
|
11
|
-
#ifndef OPENCV_OVX_DEFS_HPP
|
|
12
|
-
#define OPENCV_OVX_DEFS_HPP
|
|
13
|
-
|
|
14
|
-
#include "cvconfig.h"
|
|
15
|
-
|
|
16
|
-
// utility macro for running OpenVX-based implementations
|
|
17
|
-
#ifdef HAVE_OPENVX
|
|
18
|
-
|
|
19
|
-
#define IVX_HIDE_INFO_WARNINGS
|
|
20
|
-
#define IVX_USE_OPENCV
|
|
21
|
-
#include "ivx.hpp"
|
|
22
|
-
|
|
23
|
-
namespace cv{
|
|
24
|
-
namespace ovx{
|
|
25
|
-
// Get common thread local OpenVX context
|
|
26
|
-
CV_EXPORTS_W ivx::Context& getOpenVXContext();
|
|
27
|
-
|
|
28
|
-
template <int kernel_id> inline bool skipSmallImages(int w, int h) { return w*h < 3840 * 2160; }
|
|
29
|
-
}}
|
|
30
|
-
|
|
31
|
-
#define CV_OVX_RUN(condition, func, ...) \
|
|
32
|
-
if (cv::useOpenVX() && (condition) && func) \
|
|
33
|
-
{ \
|
|
34
|
-
return __VA_ARGS__; \
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
#else
|
|
38
|
-
#define CV_OVX_RUN(condition, func, ...)
|
|
39
|
-
#endif // HAVE_OPENVX
|
|
40
|
-
|
|
41
|
-
// Throw an error in debug mode or try another implementation in release
|
|
42
|
-
#ifdef _DEBUG
|
|
43
|
-
#define VX_DbgThrow(s) CV_Error(cv::Error::StsInternal, (s))
|
|
44
|
-
#else
|
|
45
|
-
#define VX_DbgThrow(s) return false
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
#endif // OPENCV_OVX_DEFS_HPP
|
|
@@ -1,610 +0,0 @@
|
|
|
1
|
-
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
//
|
|
3
|
-
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
4
|
-
//
|
|
5
|
-
// By downloading, copying, installing or using the software you agree to this license.
|
|
6
|
-
// If you do not agree to this license, do not download, install,
|
|
7
|
-
// copy or use the software.
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// License Agreement
|
|
11
|
-
// For Open Source Computer Vision Library
|
|
12
|
-
//
|
|
13
|
-
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
|
14
|
-
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
|
15
|
-
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
|
16
|
-
// Copyright (C) 2015, Itseez Inc., all rights reserved.
|
|
17
|
-
// Third party copyrights are property of their respective owners.
|
|
18
|
-
//
|
|
19
|
-
// Redistribution and use in source and binary forms, with or without modification,
|
|
20
|
-
// are permitted provided that the following conditions are met:
|
|
21
|
-
//
|
|
22
|
-
// * Redistribution's of source code must retain the above copyright notice,
|
|
23
|
-
// this list of conditions and the following disclaimer.
|
|
24
|
-
//
|
|
25
|
-
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
26
|
-
// this list of conditions and the following disclaimer in the documentation
|
|
27
|
-
// and/or other materials provided with the distribution.
|
|
28
|
-
//
|
|
29
|
-
// * The name of the copyright holders may not be used to endorse or promote products
|
|
30
|
-
// derived from this software without specific prior written permission.
|
|
31
|
-
//
|
|
32
|
-
// This software is provided by the copyright holders and contributors "as is" and
|
|
33
|
-
// any express or implied warranties, including, but not limited to, the implied
|
|
34
|
-
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
35
|
-
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
36
|
-
// indirect, incidental, special, exemplary, or consequential damages
|
|
37
|
-
// (including, but not limited to, procurement of substitute goods or services;
|
|
38
|
-
// loss of use, data, or profits; or business interruption) however caused
|
|
39
|
-
// and on any theory of liability, whether in contract, strict liability,
|
|
40
|
-
// or tort (including negligence or otherwise) arising in any way out of
|
|
41
|
-
// the use of this software, even if advised of the possibility of such damage.
|
|
42
|
-
//
|
|
43
|
-
//M*/
|
|
44
|
-
|
|
45
|
-
#ifndef OPENCV_CORE_OPERATIONS_HPP
|
|
46
|
-
#define OPENCV_CORE_OPERATIONS_HPP
|
|
47
|
-
|
|
48
|
-
#ifndef __cplusplus
|
|
49
|
-
# error operations.hpp header must be compiled as C++
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#include <cstdio>
|
|
53
|
-
|
|
54
|
-
#if defined(__GNUC__) || defined(__clang__) // at least GCC 3.1+, clang 3.5+
|
|
55
|
-
# if defined(__MINGW_PRINTF_FORMAT) // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
|
|
56
|
-
# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (__MINGW_PRINTF_FORMAT, string_idx, first_to_check)))
|
|
57
|
-
# else
|
|
58
|
-
# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (printf, string_idx, first_to_check)))
|
|
59
|
-
# endif
|
|
60
|
-
#else
|
|
61
|
-
# define CV_FORMAT_PRINTF(A, B)
|
|
62
|
-
#endif
|
|
63
|
-
|
|
64
|
-
//! @cond IGNORED
|
|
65
|
-
|
|
66
|
-
namespace cv
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
////////////////////////////// Matx methods depending on core API /////////////////////////////
|
|
70
|
-
|
|
71
|
-
namespace internal
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
template<typename _Tp, int m, int n> struct Matx_FastInvOp
|
|
75
|
-
{
|
|
76
|
-
bool operator()(const Matx<_Tp, m, n>& a, Matx<_Tp, n, m>& b, int method) const
|
|
77
|
-
{
|
|
78
|
-
return invert(a, b, method) != 0;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
template<typename _Tp, int m> struct Matx_FastInvOp<_Tp, m, m>
|
|
83
|
-
{
|
|
84
|
-
bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const
|
|
85
|
-
{
|
|
86
|
-
if (method == DECOMP_LU || method == DECOMP_CHOLESKY)
|
|
87
|
-
{
|
|
88
|
-
Matx<_Tp, m, m> temp = a;
|
|
89
|
-
|
|
90
|
-
// assume that b is all 0's on input => make it a unity matrix
|
|
91
|
-
for (int i = 0; i < m; i++)
|
|
92
|
-
b(i, i) = (_Tp)1;
|
|
93
|
-
|
|
94
|
-
if (method == DECOMP_CHOLESKY)
|
|
95
|
-
return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m);
|
|
96
|
-
|
|
97
|
-
return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0;
|
|
98
|
-
}
|
|
99
|
-
else
|
|
100
|
-
{
|
|
101
|
-
return invert(a, b, method) != 0;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
template<typename _Tp> struct Matx_FastInvOp<_Tp, 2, 2>
|
|
107
|
-
{
|
|
108
|
-
bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int /*method*/) const
|
|
109
|
-
{
|
|
110
|
-
_Tp d = (_Tp)determinant(a);
|
|
111
|
-
if (d == 0)
|
|
112
|
-
return false;
|
|
113
|
-
d = 1/d;
|
|
114
|
-
b(1,1) = a(0,0)*d;
|
|
115
|
-
b(0,0) = a(1,1)*d;
|
|
116
|
-
b(0,1) = -a(0,1)*d;
|
|
117
|
-
b(1,0) = -a(1,0)*d;
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
template<typename _Tp> struct Matx_FastInvOp<_Tp, 3, 3>
|
|
123
|
-
{
|
|
124
|
-
bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int /*method*/) const
|
|
125
|
-
{
|
|
126
|
-
_Tp d = (_Tp)determinant(a);
|
|
127
|
-
if (d == 0)
|
|
128
|
-
return false;
|
|
129
|
-
d = 1/d;
|
|
130
|
-
b(0,0) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) * d;
|
|
131
|
-
b(0,1) = (a(0,2) * a(2,1) - a(0,1) * a(2,2)) * d;
|
|
132
|
-
b(0,2) = (a(0,1) * a(1,2) - a(0,2) * a(1,1)) * d;
|
|
133
|
-
|
|
134
|
-
b(1,0) = (a(1,2) * a(2,0) - a(1,0) * a(2,2)) * d;
|
|
135
|
-
b(1,1) = (a(0,0) * a(2,2) - a(0,2) * a(2,0)) * d;
|
|
136
|
-
b(1,2) = (a(0,2) * a(1,0) - a(0,0) * a(1,2)) * d;
|
|
137
|
-
|
|
138
|
-
b(2,0) = (a(1,0) * a(2,1) - a(1,1) * a(2,0)) * d;
|
|
139
|
-
b(2,1) = (a(0,1) * a(2,0) - a(0,0) * a(2,1)) * d;
|
|
140
|
-
b(2,2) = (a(0,0) * a(1,1) - a(0,1) * a(1,0)) * d;
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
template<typename _Tp, int m, int l, int n> struct Matx_FastSolveOp
|
|
147
|
-
{
|
|
148
|
-
bool operator()(const Matx<_Tp, m, l>& a, const Matx<_Tp, m, n>& b,
|
|
149
|
-
Matx<_Tp, l, n>& x, int method) const
|
|
150
|
-
{
|
|
151
|
-
return cv::solve(a, b, x, method);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
template<typename _Tp, int m, int n> struct Matx_FastSolveOp<_Tp, m, m, n>
|
|
156
|
-
{
|
|
157
|
-
bool operator()(const Matx<_Tp, m, m>& a, const Matx<_Tp, m, n>& b,
|
|
158
|
-
Matx<_Tp, m, n>& x, int method) const
|
|
159
|
-
{
|
|
160
|
-
if (method == DECOMP_LU || method == DECOMP_CHOLESKY)
|
|
161
|
-
{
|
|
162
|
-
Matx<_Tp, m, m> temp = a;
|
|
163
|
-
x = b;
|
|
164
|
-
if( method == DECOMP_CHOLESKY )
|
|
165
|
-
return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n);
|
|
166
|
-
|
|
167
|
-
return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0;
|
|
168
|
-
}
|
|
169
|
-
else
|
|
170
|
-
{
|
|
171
|
-
return cv::solve(a, b, x, method);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 2, 1>
|
|
177
|
-
{
|
|
178
|
-
bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b,
|
|
179
|
-
Matx<_Tp, 2, 1>& x, int) const
|
|
180
|
-
{
|
|
181
|
-
_Tp d = (_Tp)determinant(a);
|
|
182
|
-
if (d == 0)
|
|
183
|
-
return false;
|
|
184
|
-
d = 1/d;
|
|
185
|
-
x(0) = (b(0)*a(1,1) - b(1)*a(0,1))*d;
|
|
186
|
-
x(1) = (b(1)*a(0,0) - b(0)*a(1,0))*d;
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
template<typename _Tp> struct Matx_FastSolveOp<_Tp, 3, 3, 1>
|
|
192
|
-
{
|
|
193
|
-
bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b,
|
|
194
|
-
Matx<_Tp, 3, 1>& x, int) const
|
|
195
|
-
{
|
|
196
|
-
_Tp d = (_Tp)determinant(a);
|
|
197
|
-
if (d == 0)
|
|
198
|
-
return false;
|
|
199
|
-
d = 1/d;
|
|
200
|
-
x(0) = d*(b(0)*(a(1,1)*a(2,2) - a(1,2)*a(2,1)) -
|
|
201
|
-
a(0,1)*(b(1)*a(2,2) - a(1,2)*b(2)) +
|
|
202
|
-
a(0,2)*(b(1)*a(2,1) - a(1,1)*b(2)));
|
|
203
|
-
|
|
204
|
-
x(1) = d*(a(0,0)*(b(1)*a(2,2) - a(1,2)*b(2)) -
|
|
205
|
-
b(0)*(a(1,0)*a(2,2) - a(1,2)*a(2,0)) +
|
|
206
|
-
a(0,2)*(a(1,0)*b(2) - b(1)*a(2,0)));
|
|
207
|
-
|
|
208
|
-
x(2) = d*(a(0,0)*(a(1,1)*b(2) - b(1)*a(2,1)) -
|
|
209
|
-
a(0,1)*(a(1,0)*b(2) - b(1)*a(2,0)) +
|
|
210
|
-
b(0)*(a(1,0)*a(2,1) - a(1,1)*a(2,0)));
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
} // internal
|
|
216
|
-
|
|
217
|
-
template<typename _Tp, int m, int n> inline
|
|
218
|
-
Matx<_Tp,m,n> Matx<_Tp,m,n>::randu(_Tp a, _Tp b)
|
|
219
|
-
{
|
|
220
|
-
Matx<_Tp,m,n> M;
|
|
221
|
-
cv::randu(M, Scalar(a), Scalar(b));
|
|
222
|
-
return M;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
template<typename _Tp, int m, int n> inline
|
|
226
|
-
Matx<_Tp,m,n> Matx<_Tp,m,n>::randn(_Tp a, _Tp b)
|
|
227
|
-
{
|
|
228
|
-
Matx<_Tp,m,n> M;
|
|
229
|
-
cv::randn(M, Scalar(a), Scalar(b));
|
|
230
|
-
return M;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
template<typename _Tp, int cn> inline
|
|
234
|
-
Vec<_Tp, cn> Vec<_Tp, cn>::randu(_Tp a, _Tp b)
|
|
235
|
-
{
|
|
236
|
-
Vec<_Tp,cn> V;
|
|
237
|
-
cv::randu(V, Scalar(a), Scalar(b));
|
|
238
|
-
return V;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
template<typename _Tp, int cn> inline
|
|
242
|
-
Vec<_Tp, cn> Vec<_Tp, cn>::randn(_Tp a, _Tp b)
|
|
243
|
-
{
|
|
244
|
-
Vec<_Tp,cn> V;
|
|
245
|
-
cv::randn(V, Scalar(a), Scalar(b));
|
|
246
|
-
return V;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
template<typename _Tp, int m, int n> inline
|
|
250
|
-
Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const
|
|
251
|
-
{
|
|
252
|
-
Matx<_Tp, n, m> b;
|
|
253
|
-
bool ok = cv::internal::Matx_FastInvOp<_Tp, m, n>()(*this, b, method);
|
|
254
|
-
if (p_is_ok) *p_is_ok = ok;
|
|
255
|
-
return ok ? b : Matx<_Tp, n, m>::zeros();
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
template<typename _Tp, int m, int n> template<int l> inline
|
|
259
|
-
Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) const
|
|
260
|
-
{
|
|
261
|
-
Matx<_Tp, n, l> x;
|
|
262
|
-
bool ok = cv::internal::Matx_FastSolveOp<_Tp, m, n, l>()(*this, rhs, x, method);
|
|
263
|
-
return ok ? x : Matx<_Tp, n, l>::zeros();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
////////////////////////// Augmenting algebraic & logical operations //////////////////////////
|
|
269
|
-
|
|
270
|
-
#define CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
|
|
271
|
-
static inline A& operator op (A& a, const B& b) { cvop; return a; }
|
|
272
|
-
|
|
273
|
-
#define CV_MAT_AUG_OPERATOR(op, cvop, A, B) \
|
|
274
|
-
CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
|
|
275
|
-
CV_MAT_AUG_OPERATOR1(op, cvop, const A, B)
|
|
276
|
-
|
|
277
|
-
#define CV_MAT_AUG_OPERATOR_T(op, cvop, A, B) \
|
|
278
|
-
template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
|
|
279
|
-
template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, const A, B)
|
|
280
|
-
|
|
281
|
-
#define CV_MAT_AUG_OPERATOR_TN(op, cvop, A) \
|
|
282
|
-
template<typename _Tp, int m, int n> static inline A& operator op (A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } \
|
|
283
|
-
template<typename _Tp, int m, int n> static inline const A& operator op (const A& a, const Matx<_Tp,m,n>& b) { cvop; return a; }
|
|
284
|
-
|
|
285
|
-
CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Mat)
|
|
286
|
-
CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Scalar)
|
|
287
|
-
CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
|
|
288
|
-
CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
|
|
289
|
-
CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
|
|
290
|
-
CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat)
|
|
291
|
-
CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
|
|
292
|
-
|
|
293
|
-
CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Mat)
|
|
294
|
-
CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Scalar)
|
|
295
|
-
CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
|
|
296
|
-
CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
|
|
297
|
-
CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
|
|
298
|
-
CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat)
|
|
299
|
-
CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
|
|
300
|
-
|
|
301
|
-
CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat)
|
|
302
|
-
CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat)
|
|
303
|
-
CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>)
|
|
304
|
-
CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, -1, b), Mat, double)
|
|
305
|
-
CV_MAT_AUG_OPERATOR_T(*=, a.convertTo(a, -1, b), Mat_<_Tp>, double)
|
|
306
|
-
CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat)
|
|
307
|
-
CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat_<_Tp>)
|
|
308
|
-
|
|
309
|
-
CV_MAT_AUG_OPERATOR (/=, cv::divide(a, b, (const Mat&)a), Mat, Mat)
|
|
310
|
-
CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
|
|
311
|
-
CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
|
|
312
|
-
CV_MAT_AUG_OPERATOR (/=, a.convertTo((Mat&)a, -1, 1./b), Mat, double)
|
|
313
|
-
CV_MAT_AUG_OPERATOR_T(/=, a.convertTo((Mat&)a, -1, 1./b), Mat_<_Tp>, double)
|
|
314
|
-
CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat)
|
|
315
|
-
CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
|
|
316
|
-
|
|
317
|
-
CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Mat)
|
|
318
|
-
CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Scalar)
|
|
319
|
-
CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
|
|
320
|
-
CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
|
|
321
|
-
CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
|
|
322
|
-
CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat)
|
|
323
|
-
CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
|
|
324
|
-
|
|
325
|
-
CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Mat)
|
|
326
|
-
CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Scalar)
|
|
327
|
-
CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
|
|
328
|
-
CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
|
|
329
|
-
CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
|
|
330
|
-
CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat)
|
|
331
|
-
CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
|
|
332
|
-
|
|
333
|
-
CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Mat)
|
|
334
|
-
CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Scalar)
|
|
335
|
-
CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat)
|
|
336
|
-
CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Scalar)
|
|
337
|
-
CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>)
|
|
338
|
-
CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat)
|
|
339
|
-
CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat_<_Tp>)
|
|
340
|
-
|
|
341
|
-
#undef CV_MAT_AUG_OPERATOR_TN
|
|
342
|
-
#undef CV_MAT_AUG_OPERATOR_T
|
|
343
|
-
#undef CV_MAT_AUG_OPERATOR
|
|
344
|
-
#undef CV_MAT_AUG_OPERATOR1
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
///////////////////////////////////////////// SVD /////////////////////////////////////////////
|
|
349
|
-
|
|
350
|
-
inline SVD::SVD() {}
|
|
351
|
-
inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); }
|
|
352
|
-
inline void SVD::solveZ( InputArray m, OutputArray _dst )
|
|
353
|
-
{
|
|
354
|
-
Mat mtx = m.getMat();
|
|
355
|
-
SVD svd(mtx, (mtx.rows >= mtx.cols ? 0 : SVD::FULL_UV));
|
|
356
|
-
_dst.create(svd.vt.cols, 1, svd.vt.type());
|
|
357
|
-
Mat dst = _dst.getMat();
|
|
358
|
-
svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
template<typename _Tp, int m, int n, int nm> inline void
|
|
362
|
-
SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt )
|
|
363
|
-
{
|
|
364
|
-
CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector.");
|
|
365
|
-
Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false);
|
|
366
|
-
SVD::compute(_a, _w, _u, _vt);
|
|
367
|
-
CV_Assert(_w.data == (uchar*)&w.val[0] && _u.data == (uchar*)&u.val[0] && _vt.data == (uchar*)&vt.val[0]);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
template<typename _Tp, int m, int n, int nm> inline void
|
|
371
|
-
SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w )
|
|
372
|
-
{
|
|
373
|
-
CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector.");
|
|
374
|
-
Mat _a(a, false), _w(w, false);
|
|
375
|
-
SVD::compute(_a, _w);
|
|
376
|
-
CV_Assert(_w.data == (uchar*)&w.val[0]);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
template<typename _Tp, int m, int n, int nm, int nb> inline void
|
|
380
|
-
SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u,
|
|
381
|
-
const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs,
|
|
382
|
-
Matx<_Tp, n, nb>& dst )
|
|
383
|
-
{
|
|
384
|
-
CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector.");
|
|
385
|
-
Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false);
|
|
386
|
-
SVD::backSubst(_w, _u, _vt, _rhs, _dst);
|
|
387
|
-
CV_Assert(_dst.data == (uchar*)&dst.val[0]);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
/////////////////////////////////// Multiply-with-Carry RNG ///////////////////////////////////
|
|
393
|
-
|
|
394
|
-
inline RNG::RNG() { state = 0xffffffff; }
|
|
395
|
-
inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; }
|
|
396
|
-
|
|
397
|
-
inline RNG::operator uchar() { return (uchar)next(); }
|
|
398
|
-
inline RNG::operator schar() { return (schar)next(); }
|
|
399
|
-
inline RNG::operator ushort() { return (ushort)next(); }
|
|
400
|
-
inline RNG::operator short() { return (short)next(); }
|
|
401
|
-
inline RNG::operator int() { return (int)next(); }
|
|
402
|
-
inline RNG::operator unsigned() { return next(); }
|
|
403
|
-
inline RNG::operator float() { return next()*2.3283064365386962890625e-10f; }
|
|
404
|
-
inline RNG::operator double() { unsigned t = next(); return (((uint64)t << 32) | next()) * 5.4210108624275221700372640043497e-20; }
|
|
405
|
-
|
|
406
|
-
inline unsigned RNG::operator ()(unsigned N) { return (unsigned)uniform(0,N); }
|
|
407
|
-
inline unsigned RNG::operator ()() { return next(); }
|
|
408
|
-
|
|
409
|
-
inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next() % (b - a) + a); }
|
|
410
|
-
inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; }
|
|
411
|
-
inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; }
|
|
412
|
-
|
|
413
|
-
inline bool RNG::operator ==(const RNG& other) const { return state == other.state; }
|
|
414
|
-
|
|
415
|
-
inline unsigned RNG::next()
|
|
416
|
-
{
|
|
417
|
-
state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32);
|
|
418
|
-
return (unsigned)state;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
//! returns the next uniformly-distributed random number of the specified type
|
|
422
|
-
template<typename _Tp> static inline _Tp randu()
|
|
423
|
-
{
|
|
424
|
-
return (_Tp)theRNG();
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
///////////////////////////////// Formatted string generation /////////////////////////////////
|
|
428
|
-
|
|
429
|
-
/** @brief Returns a text string formatted using the printf-like expression.
|
|
430
|
-
|
|
431
|
-
The function acts like sprintf but forms and returns an STL string. It can be used to form an error
|
|
432
|
-
message in the Exception constructor.
|
|
433
|
-
@param fmt printf-compatible formatting specifiers.
|
|
434
|
-
|
|
435
|
-
**Note**:
|
|
436
|
-
|Type|Specifier|
|
|
437
|
-
|-|-|
|
|
438
|
-
|`const char*`|`%s`|
|
|
439
|
-
|`char`|`%c`|
|
|
440
|
-
|`float` / `double`|`%f`,`%g`|
|
|
441
|
-
|`int`, `long`, `long long`|`%d`, `%ld`, ``%lld`|
|
|
442
|
-
|`unsigned`, `unsigned long`, `unsigned long long`|`%u`, `%lu`, `%llu`|
|
|
443
|
-
|`uint64` -> `uintmax_t`, `int64` -> `intmax_t`|`%ju`, `%jd`|
|
|
444
|
-
|`size_t`|`%zu`|
|
|
445
|
-
*/
|
|
446
|
-
CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2);
|
|
447
|
-
|
|
448
|
-
///////////////////////////////// Formatted output of cv::Mat /////////////////////////////////
|
|
449
|
-
|
|
450
|
-
static inline
|
|
451
|
-
Ptr<Formatted> format(InputArray mtx, Formatter::FormatType fmt)
|
|
452
|
-
{
|
|
453
|
-
return Formatter::get(fmt)->format(mtx.getMat());
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
static inline
|
|
457
|
-
int print(Ptr<Formatted> fmtd, FILE* stream = stdout)
|
|
458
|
-
{
|
|
459
|
-
int written = 0;
|
|
460
|
-
fmtd->reset();
|
|
461
|
-
for(const char* str = fmtd->next(); str; str = fmtd->next())
|
|
462
|
-
written += fputs(str, stream);
|
|
463
|
-
|
|
464
|
-
return written;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
static inline
|
|
468
|
-
int print(const Mat& mtx, FILE* stream = stdout)
|
|
469
|
-
{
|
|
470
|
-
return print(Formatter::get()->format(mtx), stream);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
static inline
|
|
474
|
-
int print(const UMat& mtx, FILE* stream = stdout)
|
|
475
|
-
{
|
|
476
|
-
return print(Formatter::get()->format(mtx.getMat(ACCESS_READ)), stream);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
template<typename _Tp> static inline
|
|
480
|
-
int print(const std::vector<Point_<_Tp> >& vec, FILE* stream = stdout)
|
|
481
|
-
{
|
|
482
|
-
return print(Formatter::get()->format(Mat(vec)), stream);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
template<typename _Tp> static inline
|
|
486
|
-
int print(const std::vector<Point3_<_Tp> >& vec, FILE* stream = stdout)
|
|
487
|
-
{
|
|
488
|
-
return print(Formatter::get()->format(Mat(vec)), stream);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
template<typename _Tp, int m, int n> static inline
|
|
492
|
-
int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout)
|
|
493
|
-
{
|
|
494
|
-
return print(Formatter::get()->format(cv::Mat(matx)), stream);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
//! @endcond
|
|
498
|
-
|
|
499
|
-
/****************************************************************************************\
|
|
500
|
-
* Auxiliary algorithms *
|
|
501
|
-
\****************************************************************************************/
|
|
502
|
-
|
|
503
|
-
/** @brief Splits an element set into equivalency classes.
|
|
504
|
-
|
|
505
|
-
The generic function partition implements an \f$O(N^2)\f$ algorithm for splitting a set of \f$N\f$ elements
|
|
506
|
-
into one or more equivalency classes, as described in
|
|
507
|
-
<http://en.wikipedia.org/wiki/Disjoint-set_data_structure> . The function returns the number of
|
|
508
|
-
equivalency classes.
|
|
509
|
-
@param _vec Set of elements stored as a vector.
|
|
510
|
-
@param labels Output vector of labels. It contains as many elements as vec. Each label labels[i] is
|
|
511
|
-
a 0-based cluster index of `vec[i]`.
|
|
512
|
-
@param predicate Equivalence predicate (pointer to a boolean function of two arguments or an
|
|
513
|
-
instance of the class that has the method bool operator()(const _Tp& a, const _Tp& b) ). The
|
|
514
|
-
predicate returns true when the elements are certainly in the same class, and returns false if they
|
|
515
|
-
may or may not be in the same class.
|
|
516
|
-
@ingroup core_cluster
|
|
517
|
-
*/
|
|
518
|
-
template<typename _Tp, class _EqPredicate> int
|
|
519
|
-
partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
|
|
520
|
-
_EqPredicate predicate=_EqPredicate())
|
|
521
|
-
{
|
|
522
|
-
int i, j, N = (int)_vec.size();
|
|
523
|
-
const _Tp* vec = &_vec[0];
|
|
524
|
-
|
|
525
|
-
const int PARENT=0;
|
|
526
|
-
const int RANK=1;
|
|
527
|
-
|
|
528
|
-
std::vector<int> _nodes(N*2);
|
|
529
|
-
int (*nodes)[2] = (int(*)[2])&_nodes[0];
|
|
530
|
-
|
|
531
|
-
// The first O(N) pass: create N single-vertex trees
|
|
532
|
-
for(i = 0; i < N; i++)
|
|
533
|
-
{
|
|
534
|
-
nodes[i][PARENT]=-1;
|
|
535
|
-
nodes[i][RANK] = 0;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// The main O(N^2) pass: merge connected components
|
|
539
|
-
for( i = 0; i < N; i++ )
|
|
540
|
-
{
|
|
541
|
-
int root = i;
|
|
542
|
-
|
|
543
|
-
// find root
|
|
544
|
-
while( nodes[root][PARENT] >= 0 )
|
|
545
|
-
root = nodes[root][PARENT];
|
|
546
|
-
|
|
547
|
-
for( j = 0; j < N; j++ )
|
|
548
|
-
{
|
|
549
|
-
if( i == j || !predicate(vec[i], vec[j]))
|
|
550
|
-
continue;
|
|
551
|
-
int root2 = j;
|
|
552
|
-
|
|
553
|
-
while( nodes[root2][PARENT] >= 0 )
|
|
554
|
-
root2 = nodes[root2][PARENT];
|
|
555
|
-
|
|
556
|
-
if( root2 != root )
|
|
557
|
-
{
|
|
558
|
-
// unite both trees
|
|
559
|
-
int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
|
|
560
|
-
if( rank > rank2 )
|
|
561
|
-
nodes[root2][PARENT] = root;
|
|
562
|
-
else
|
|
563
|
-
{
|
|
564
|
-
nodes[root][PARENT] = root2;
|
|
565
|
-
nodes[root2][RANK] += rank == rank2;
|
|
566
|
-
root = root2;
|
|
567
|
-
}
|
|
568
|
-
CV_Assert( nodes[root][PARENT] < 0 );
|
|
569
|
-
|
|
570
|
-
int k = j, parent;
|
|
571
|
-
|
|
572
|
-
// compress the path from node2 to root
|
|
573
|
-
while( (parent = nodes[k][PARENT]) >= 0 )
|
|
574
|
-
{
|
|
575
|
-
nodes[k][PARENT] = root;
|
|
576
|
-
k = parent;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// compress the path from node to root
|
|
580
|
-
k = i;
|
|
581
|
-
while( (parent = nodes[k][PARENT]) >= 0 )
|
|
582
|
-
{
|
|
583
|
-
nodes[k][PARENT] = root;
|
|
584
|
-
k = parent;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// Final O(N) pass: enumerate classes
|
|
591
|
-
labels.resize(N);
|
|
592
|
-
int nclasses = 0;
|
|
593
|
-
|
|
594
|
-
for( i = 0; i < N; i++ )
|
|
595
|
-
{
|
|
596
|
-
int root = i;
|
|
597
|
-
while( nodes[root][PARENT] >= 0 )
|
|
598
|
-
root = nodes[root][PARENT];
|
|
599
|
-
// re-use the rank as the class label
|
|
600
|
-
if( nodes[root][RANK] >= 0 )
|
|
601
|
-
nodes[root][RANK] = ~nclasses++;
|
|
602
|
-
labels[i] = ~nodes[root][RANK];
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
return nclasses;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
} // cv
|
|
609
|
-
|
|
610
|
-
#endif
|