node-native-win-utils 1.1.0 → 1.3.0
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 +144 -27
- package/binding.gyp +18 -5
- package/dist/index.d.ts +146 -4
- package/dist/index.js +107 -3
- package/include/opencv2/core/affine.hpp +678 -0
- package/include/opencv2/core/async.hpp +105 -0
- package/include/opencv2/core/base.hpp +664 -0
- package/include/opencv2/core/bindings_utils.hpp +325 -0
- package/include/opencv2/core/bufferpool.hpp +40 -0
- package/include/opencv2/core/check.hpp +170 -0
- package/include/opencv2/core/core.hpp +48 -0
- package/include/opencv2/core/core_c.h +3128 -0
- package/include/opencv2/core/cuda/block.hpp +211 -0
- package/include/opencv2/core/cuda/border_interpolate.hpp +722 -0
- package/include/opencv2/core/cuda/color.hpp +309 -0
- package/include/opencv2/core/cuda/common.hpp +131 -0
- package/include/opencv2/core/cuda/datamov_utils.hpp +113 -0
- package/include/opencv2/core/cuda/detail/color_detail.hpp +2018 -0
- package/include/opencv2/core/cuda/detail/reduce.hpp +365 -0
- package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +502 -0
- package/include/opencv2/core/cuda/detail/transform_detail.hpp +392 -0
- package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +191 -0
- package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +121 -0
- package/include/opencv2/core/cuda/dynamic_smem.hpp +88 -0
- package/include/opencv2/core/cuda/emulation.hpp +269 -0
- package/include/opencv2/core/cuda/filters.hpp +293 -0
- package/include/opencv2/core/cuda/funcattrib.hpp +79 -0
- package/include/opencv2/core/cuda/functional.hpp +805 -0
- package/include/opencv2/core/cuda/limits.hpp +128 -0
- package/include/opencv2/core/cuda/reduce.hpp +209 -0
- package/include/opencv2/core/cuda/saturate_cast.hpp +292 -0
- package/include/opencv2/core/cuda/scan.hpp +258 -0
- package/include/opencv2/core/cuda/simd_functions.hpp +869 -0
- package/include/opencv2/core/cuda/transform.hpp +75 -0
- package/include/opencv2/core/cuda/type_traits.hpp +90 -0
- package/include/opencv2/core/cuda/utility.hpp +230 -0
- package/include/opencv2/core/cuda/vec_distance.hpp +232 -0
- package/include/opencv2/core/cuda/vec_math.hpp +923 -0
- package/include/opencv2/core/cuda/vec_traits.hpp +288 -0
- package/include/opencv2/core/cuda/warp.hpp +139 -0
- package/include/opencv2/core/cuda/warp_reduce.hpp +76 -0
- package/include/opencv2/core/cuda/warp_shuffle.hpp +162 -0
- package/include/opencv2/core/cuda.hpp +1279 -0
- package/include/opencv2/core/cuda.inl.hpp +763 -0
- package/include/opencv2/core/cuda_stream_accessor.hpp +86 -0
- package/include/opencv2/core/cuda_types.hpp +144 -0
- package/include/opencv2/core/cv_cpu_dispatch.h +381 -0
- package/include/opencv2/core/cv_cpu_helper.h +550 -0
- package/include/opencv2/core/cvdef.h +973 -0
- package/include/opencv2/core/cvstd.hpp +190 -0
- package/include/opencv2/core/cvstd.inl.hpp +197 -0
- package/include/opencv2/core/cvstd_wrapper.hpp +154 -0
- package/include/opencv2/core/detail/async_promise.hpp +71 -0
- package/include/opencv2/core/detail/dispatch_helper.impl.hpp +49 -0
- package/include/opencv2/core/detail/exception_ptr.hpp +27 -0
- package/include/opencv2/core/directx.hpp +184 -0
- package/include/opencv2/core/dualquaternion.hpp +979 -0
- package/include/opencv2/core/dualquaternion.inl.hpp +487 -0
- package/include/opencv2/core/eigen.hpp +402 -0
- package/include/opencv2/core/fast_math.hpp +433 -0
- package/include/opencv2/core/hal/hal.hpp +256 -0
- package/include/opencv2/core/hal/interface.h +190 -0
- package/include/opencv2/core/hal/intrin.hpp +939 -0
- package/include/opencv2/core/hal/intrin_avx.hpp +3177 -0
- package/include/opencv2/core/hal/intrin_avx512.hpp +3090 -0
- package/include/opencv2/core/hal/intrin_cpp.hpp +3321 -0
- package/include/opencv2/core/hal/intrin_forward.hpp +191 -0
- package/include/opencv2/core/hal/intrin_lasx.hpp +3236 -0
- package/include/opencv2/core/hal/intrin_msa.hpp +1887 -0
- package/include/opencv2/core/hal/intrin_neon.hpp +2610 -0
- package/include/opencv2/core/hal/intrin_rvv.hpp +3320 -0
- package/include/opencv2/core/hal/intrin_rvv071.hpp +2545 -0
- package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2080 -0
- package/include/opencv2/core/hal/intrin_sse.hpp +3467 -0
- package/include/opencv2/core/hal/intrin_sse_em.hpp +180 -0
- package/include/opencv2/core/hal/intrin_vsx.hpp +1608 -0
- package/include/opencv2/core/hal/intrin_wasm.hpp +2782 -0
- package/include/opencv2/core/hal/msa_macros.h +1558 -0
- package/include/opencv2/core/hal/simd_utils.impl.hpp +186 -0
- package/include/opencv2/core/llapi/llapi.h +102 -0
- package/include/opencv2/core/mat.hpp +3775 -0
- package/include/opencv2/core/mat.inl.hpp +3422 -0
- package/include/opencv2/core/matx.hpp +1536 -0
- package/include/opencv2/core/neon_utils.hpp +128 -0
- package/include/opencv2/core/ocl.hpp +917 -0
- package/include/opencv2/core/ocl_genbase.hpp +69 -0
- package/include/opencv2/core/opencl/ocl_defs.hpp +82 -0
- package/include/opencv2/core/opencl/opencl_info.hpp +212 -0
- package/include/opencv2/core/opencl/opencl_svm.hpp +81 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +602 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +146 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +371 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +272 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +62 -0
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +42 -0
- package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +53 -0
- package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +53 -0
- package/include/opencv2/core/opencl/runtime/opencl_core.hpp +84 -0
- package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +47 -0
- package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +53 -0
- package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +47 -0
- package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +48 -0
- package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +42 -0
- package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +166 -0
- package/include/opencv2/core/opengl.hpp +733 -0
- package/include/opencv2/core/openvx/ovx_defs.hpp +48 -0
- package/include/opencv2/core/operations.hpp +610 -0
- package/include/opencv2/core/optim.hpp +302 -0
- package/include/opencv2/core/ovx.hpp +28 -0
- package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +72 -0
- package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +153 -0
- package/include/opencv2/core/parallel/parallel_backend.hpp +90 -0
- package/include/opencv2/core/persistence.hpp +1350 -0
- package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +30 -0
- package/include/opencv2/core/private.cuda.hpp +169 -0
- package/include/opencv2/core/private.hpp +896 -0
- package/include/opencv2/core/quaternion.hpp +1696 -0
- package/include/opencv2/core/quaternion.inl.hpp +1063 -0
- package/include/opencv2/core/saturate.hpp +180 -0
- package/include/opencv2/core/simd_intrinsics.hpp +87 -0
- package/include/opencv2/core/softfloat.hpp +514 -0
- package/include/opencv2/core/sse_utils.hpp +652 -0
- package/include/opencv2/core/traits.hpp +417 -0
- package/include/opencv2/core/types.hpp +2457 -0
- package/include/opencv2/core/types_c.h +2126 -0
- package/include/opencv2/core/utility.hpp +1229 -0
- package/include/opencv2/core/utils/allocator_stats.hpp +29 -0
- package/include/opencv2/core/utils/allocator_stats.impl.hpp +158 -0
- package/include/opencv2/core/utils/buffer_area.private.hpp +136 -0
- package/include/opencv2/core/utils/configuration.private.hpp +22 -0
- package/include/opencv2/core/utils/filesystem.hpp +82 -0
- package/include/opencv2/core/utils/filesystem.private.hpp +66 -0
- package/include/opencv2/core/utils/fp_control.private.hpp +29 -0
- package/include/opencv2/core/utils/fp_control_utils.hpp +69 -0
- package/include/opencv2/core/utils/instrumentation.hpp +125 -0
- package/include/opencv2/core/utils/lock.private.hpp +119 -0
- package/include/opencv2/core/utils/logger.defines.hpp +42 -0
- package/include/opencv2/core/utils/logger.hpp +218 -0
- package/include/opencv2/core/utils/logtag.hpp +28 -0
- package/include/opencv2/core/utils/plugin_loader.private.hpp +165 -0
- package/include/opencv2/core/utils/tls.hpp +235 -0
- package/include/opencv2/core/utils/trace.hpp +252 -0
- package/include/opencv2/core/utils/trace.private.hpp +421 -0
- package/include/opencv2/core/va_intel.hpp +75 -0
- package/include/opencv2/core/version.hpp +26 -0
- package/include/opencv2/core/vsx_utils.hpp +1047 -0
- package/include/opencv2/core.hpp +3365 -0
- package/include/opencv2/imgcodecs/imgcodecs.hpp +48 -0
- package/include/opencv2/imgcodecs/imgcodecs_c.h +1 -0
- package/include/opencv2/imgcodecs/ios.h +59 -0
- package/include/opencv2/imgcodecs/legacy/constants_c.h +54 -0
- package/include/opencv2/imgcodecs/macosx.h +20 -0
- package/include/opencv2/imgcodecs.hpp +407 -0
- package/include/opencv2/imgproc/bindings.hpp +34 -0
- package/include/opencv2/imgproc/detail/gcgraph.hpp +395 -0
- package/include/opencv2/imgproc/hal/hal.hpp +246 -0
- package/include/opencv2/imgproc/hal/interface.h +46 -0
- package/include/opencv2/imgproc/imgproc.hpp +48 -0
- package/include/opencv2/imgproc/imgproc_c.h +1177 -0
- package/include/opencv2/imgproc/segmentation.hpp +141 -0
- package/include/opencv2/imgproc/types_c.h +659 -0
- package/include/opencv2/imgproc.hpp +5035 -0
- package/include/opencv2/opencv_modules.hpp +17 -0
- 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/zlib.lib +0 -0
- package/package.json +14 -3
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/cpp/capturewindow.cpp +36 -46
- package/src/cpp/main.cpp +10 -2
- package/src/cpp/opencv.cpp +425 -0
|
@@ -0,0 +1,1536 @@
|
|
|
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
|
+
// Third party copyrights are property of their respective owners.
|
|
17
|
+
//
|
|
18
|
+
// Redistribution and use in source and binary forms, with or without modification,
|
|
19
|
+
// are permitted provided that the following conditions are met:
|
|
20
|
+
//
|
|
21
|
+
// * Redistribution's of source code must retain the above copyright notice,
|
|
22
|
+
// this list of conditions and the following disclaimer.
|
|
23
|
+
//
|
|
24
|
+
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
25
|
+
// this list of conditions and the following disclaimer in the documentation
|
|
26
|
+
// and/or other materials provided with the distribution.
|
|
27
|
+
//
|
|
28
|
+
// * The name of the copyright holders may not be used to endorse or promote products
|
|
29
|
+
// derived from this software without specific prior written permission.
|
|
30
|
+
//
|
|
31
|
+
// This software is provided by the copyright holders and contributors "as is" and
|
|
32
|
+
// any express or implied warranties, including, but not limited to, the implied
|
|
33
|
+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
34
|
+
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
35
|
+
// indirect, incidental, special, exemplary, or consequential damages
|
|
36
|
+
// (including, but not limited to, procurement of substitute goods or services;
|
|
37
|
+
// loss of use, data, or profits; or business interruption) however caused
|
|
38
|
+
// and on any theory of liability, whether in contract, strict liability,
|
|
39
|
+
// or tort (including negligence or otherwise) arising in any way out of
|
|
40
|
+
// the use of this software, even if advised of the possibility of such damage.
|
|
41
|
+
//
|
|
42
|
+
//M*/
|
|
43
|
+
|
|
44
|
+
#ifndef OPENCV_CORE_MATX_HPP
|
|
45
|
+
#define OPENCV_CORE_MATX_HPP
|
|
46
|
+
|
|
47
|
+
#ifndef __cplusplus
|
|
48
|
+
# error matx.hpp header must be compiled as C++
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
#include "opencv2/core/cvdef.h"
|
|
52
|
+
#include "opencv2/core/base.hpp"
|
|
53
|
+
#include "opencv2/core/traits.hpp"
|
|
54
|
+
#include "opencv2/core/saturate.hpp"
|
|
55
|
+
|
|
56
|
+
#include <initializer_list>
|
|
57
|
+
|
|
58
|
+
namespace cv
|
|
59
|
+
{
|
|
60
|
+
|
|
61
|
+
//! @addtogroup core_basic
|
|
62
|
+
//! @{
|
|
63
|
+
|
|
64
|
+
////////////////////////////// Small Matrix ///////////////////////////
|
|
65
|
+
|
|
66
|
+
//! @cond IGNORED
|
|
67
|
+
// FIXIT Remove this (especially CV_EXPORTS modifier)
|
|
68
|
+
struct CV_EXPORTS Matx_AddOp { Matx_AddOp() {} Matx_AddOp(const Matx_AddOp&) {} };
|
|
69
|
+
struct CV_EXPORTS Matx_SubOp { Matx_SubOp() {} Matx_SubOp(const Matx_SubOp&) {} };
|
|
70
|
+
struct CV_EXPORTS Matx_ScaleOp { Matx_ScaleOp() {} Matx_ScaleOp(const Matx_ScaleOp&) {} };
|
|
71
|
+
struct CV_EXPORTS Matx_MulOp { Matx_MulOp() {} Matx_MulOp(const Matx_MulOp&) {} };
|
|
72
|
+
struct CV_EXPORTS Matx_DivOp { Matx_DivOp() {} Matx_DivOp(const Matx_DivOp&) {} };
|
|
73
|
+
struct CV_EXPORTS Matx_MatMulOp { Matx_MatMulOp() {} Matx_MatMulOp(const Matx_MatMulOp&) {} };
|
|
74
|
+
struct CV_EXPORTS Matx_TOp { Matx_TOp() {} Matx_TOp(const Matx_TOp&) {} };
|
|
75
|
+
//! @endcond
|
|
76
|
+
|
|
77
|
+
/** @brief Template class for small matrices whose type and size are known at compilation time
|
|
78
|
+
|
|
79
|
+
If you need a more flexible type, use Mat . The elements of the matrix M are accessible using the
|
|
80
|
+
M(i,j) notation. Most of the common matrix operations (see also @ref MatrixExpressions ) are
|
|
81
|
+
available. To do an operation on Matx that is not implemented, you can easily convert the matrix to
|
|
82
|
+
Mat and backwards:
|
|
83
|
+
@code{.cpp}
|
|
84
|
+
Matx33f m(1, 2, 3,
|
|
85
|
+
4, 5, 6,
|
|
86
|
+
7, 8, 9);
|
|
87
|
+
cout << sum(Mat(m*m.t())) << endl;
|
|
88
|
+
@endcode
|
|
89
|
+
Except of the plain constructor which takes a list of elements, Matx can be initialized from a C-array:
|
|
90
|
+
@code{.cpp}
|
|
91
|
+
float values[] = { 1, 2, 3};
|
|
92
|
+
Matx31f m(values);
|
|
93
|
+
@endcode
|
|
94
|
+
In case if C++11 features are available, std::initializer_list can be also used to initialize Matx:
|
|
95
|
+
@code{.cpp}
|
|
96
|
+
Matx31f m = { 1, 2, 3};
|
|
97
|
+
@endcode
|
|
98
|
+
*/
|
|
99
|
+
template<typename _Tp, int m, int n> class Matx
|
|
100
|
+
{
|
|
101
|
+
public:
|
|
102
|
+
enum {
|
|
103
|
+
rows = m,
|
|
104
|
+
cols = n,
|
|
105
|
+
channels = rows*cols,
|
|
106
|
+
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
|
107
|
+
depth = traits::Type<_Tp>::value,
|
|
108
|
+
type = CV_MAKETYPE(depth, channels),
|
|
109
|
+
#endif
|
|
110
|
+
shortdim = (m < n ? m : n)
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
typedef _Tp value_type;
|
|
114
|
+
typedef Matx<_Tp, m, n> mat_type;
|
|
115
|
+
typedef Matx<_Tp, shortdim, 1> diag_type;
|
|
116
|
+
|
|
117
|
+
//! default constructor
|
|
118
|
+
Matx();
|
|
119
|
+
|
|
120
|
+
explicit Matx(_Tp v0); //!< 1x1 matrix
|
|
121
|
+
Matx(_Tp v0, _Tp v1); //!< 1x2 or 2x1 matrix
|
|
122
|
+
Matx(_Tp v0, _Tp v1, _Tp v2); //!< 1x3 or 3x1 matrix
|
|
123
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 1x4, 2x2 or 4x1 matrix
|
|
124
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 1x5 or 5x1 matrix
|
|
125
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 1x6, 2x3, 3x2 or 6x1 matrix
|
|
126
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 1x7 or 7x1 matrix
|
|
127
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 1x8, 2x4, 4x2 or 8x1 matrix
|
|
128
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 1x9, 3x3 or 9x1 matrix
|
|
129
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 1x10, 2x5 or 5x2 or 10x1 matrix
|
|
130
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
|
|
131
|
+
_Tp v4, _Tp v5, _Tp v6, _Tp v7,
|
|
132
|
+
_Tp v8, _Tp v9, _Tp v10, _Tp v11); //!< 1x12, 2x6, 3x4, 4x3, 6x2 or 12x1 matrix
|
|
133
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
|
|
134
|
+
_Tp v4, _Tp v5, _Tp v6, _Tp v7,
|
|
135
|
+
_Tp v8, _Tp v9, _Tp v10, _Tp v11,
|
|
136
|
+
_Tp v12, _Tp v13); //!< 1x14, 2x7, 7x2 or 14x1 matrix
|
|
137
|
+
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
|
|
138
|
+
_Tp v4, _Tp v5, _Tp v6, _Tp v7,
|
|
139
|
+
_Tp v8, _Tp v9, _Tp v10, _Tp v11,
|
|
140
|
+
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
|
141
|
+
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
|
142
|
+
|
|
143
|
+
Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
|
|
144
|
+
|
|
145
|
+
CV_NODISCARD_STD static Matx all(_Tp alpha);
|
|
146
|
+
CV_NODISCARD_STD static Matx zeros();
|
|
147
|
+
CV_NODISCARD_STD static Matx ones();
|
|
148
|
+
CV_NODISCARD_STD static Matx eye();
|
|
149
|
+
CV_NODISCARD_STD static Matx diag(const diag_type& d);
|
|
150
|
+
/** @brief Generates uniformly distributed random numbers
|
|
151
|
+
@param a Range boundary.
|
|
152
|
+
@param b The other range boundary (boundaries don't have to be ordered, the lower boundary is inclusive,
|
|
153
|
+
the upper one is exclusive).
|
|
154
|
+
*/
|
|
155
|
+
CV_NODISCARD_STD static Matx randu(_Tp a, _Tp b);
|
|
156
|
+
/** @brief Generates normally distributed random numbers
|
|
157
|
+
@param a Mean value.
|
|
158
|
+
@param b Standard deviation.
|
|
159
|
+
*/
|
|
160
|
+
CV_NODISCARD_STD static Matx randn(_Tp a, _Tp b);
|
|
161
|
+
|
|
162
|
+
//! dot product computed with the default precision
|
|
163
|
+
_Tp dot(const Matx<_Tp, m, n>& v) const;
|
|
164
|
+
|
|
165
|
+
//! dot product computed in double-precision arithmetics
|
|
166
|
+
double ddot(const Matx<_Tp, m, n>& v) const;
|
|
167
|
+
|
|
168
|
+
//! conversion to another data type
|
|
169
|
+
template<typename T2> operator Matx<T2, m, n>() const;
|
|
170
|
+
|
|
171
|
+
//! change the matrix shape
|
|
172
|
+
template<int m1, int n1> Matx<_Tp, m1, n1> reshape() const;
|
|
173
|
+
|
|
174
|
+
//! extract part of the matrix
|
|
175
|
+
template<int m1, int n1> Matx<_Tp, m1, n1> get_minor(int base_row, int base_col) const;
|
|
176
|
+
|
|
177
|
+
//! extract the matrix row
|
|
178
|
+
Matx<_Tp, 1, n> row(int i) const;
|
|
179
|
+
|
|
180
|
+
//! extract the matrix column
|
|
181
|
+
Matx<_Tp, m, 1> col(int i) const;
|
|
182
|
+
|
|
183
|
+
//! extract the matrix diagonal
|
|
184
|
+
diag_type diag() const;
|
|
185
|
+
|
|
186
|
+
//! transpose the matrix
|
|
187
|
+
Matx<_Tp, n, m> t() const;
|
|
188
|
+
|
|
189
|
+
//! invert the matrix
|
|
190
|
+
Matx<_Tp, n, m> inv(int method=DECOMP_LU, bool *p_is_ok = NULL) const;
|
|
191
|
+
|
|
192
|
+
//! solve linear system
|
|
193
|
+
template<int l> Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const;
|
|
194
|
+
Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const;
|
|
195
|
+
|
|
196
|
+
//! multiply two matrices element-wise
|
|
197
|
+
Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const;
|
|
198
|
+
|
|
199
|
+
//! divide two matrices element-wise
|
|
200
|
+
Matx<_Tp, m, n> div(const Matx<_Tp, m, n>& a) const;
|
|
201
|
+
|
|
202
|
+
//! element access
|
|
203
|
+
const _Tp& operator ()(int row, int col) const;
|
|
204
|
+
_Tp& operator ()(int row, int col);
|
|
205
|
+
|
|
206
|
+
//! 1D element access
|
|
207
|
+
const _Tp& operator ()(int i) const;
|
|
208
|
+
_Tp& operator ()(int i);
|
|
209
|
+
|
|
210
|
+
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp);
|
|
211
|
+
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp);
|
|
212
|
+
template<typename _T2> Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp);
|
|
213
|
+
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp);
|
|
214
|
+
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp);
|
|
215
|
+
template<int l> Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp);
|
|
216
|
+
Matx(const Matx<_Tp, n, m>& a, Matx_TOp);
|
|
217
|
+
|
|
218
|
+
_Tp val[m*n]; //< matrix elements
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
typedef Matx<float, 1, 2> Matx12f;
|
|
222
|
+
typedef Matx<double, 1, 2> Matx12d;
|
|
223
|
+
typedef Matx<float, 1, 3> Matx13f;
|
|
224
|
+
typedef Matx<double, 1, 3> Matx13d;
|
|
225
|
+
typedef Matx<float, 1, 4> Matx14f;
|
|
226
|
+
typedef Matx<double, 1, 4> Matx14d;
|
|
227
|
+
typedef Matx<float, 1, 6> Matx16f;
|
|
228
|
+
typedef Matx<double, 1, 6> Matx16d;
|
|
229
|
+
|
|
230
|
+
typedef Matx<float, 2, 1> Matx21f;
|
|
231
|
+
typedef Matx<double, 2, 1> Matx21d;
|
|
232
|
+
typedef Matx<float, 3, 1> Matx31f;
|
|
233
|
+
typedef Matx<double, 3, 1> Matx31d;
|
|
234
|
+
typedef Matx<float, 4, 1> Matx41f;
|
|
235
|
+
typedef Matx<double, 4, 1> Matx41d;
|
|
236
|
+
typedef Matx<float, 6, 1> Matx61f;
|
|
237
|
+
typedef Matx<double, 6, 1> Matx61d;
|
|
238
|
+
|
|
239
|
+
typedef Matx<float, 2, 2> Matx22f;
|
|
240
|
+
typedef Matx<double, 2, 2> Matx22d;
|
|
241
|
+
typedef Matx<float, 2, 3> Matx23f;
|
|
242
|
+
typedef Matx<double, 2, 3> Matx23d;
|
|
243
|
+
typedef Matx<float, 3, 2> Matx32f;
|
|
244
|
+
typedef Matx<double, 3, 2> Matx32d;
|
|
245
|
+
|
|
246
|
+
typedef Matx<float, 3, 3> Matx33f;
|
|
247
|
+
typedef Matx<double, 3, 3> Matx33d;
|
|
248
|
+
|
|
249
|
+
typedef Matx<float, 3, 4> Matx34f;
|
|
250
|
+
typedef Matx<double, 3, 4> Matx34d;
|
|
251
|
+
typedef Matx<float, 4, 3> Matx43f;
|
|
252
|
+
typedef Matx<double, 4, 3> Matx43d;
|
|
253
|
+
|
|
254
|
+
typedef Matx<float, 4, 4> Matx44f;
|
|
255
|
+
typedef Matx<double, 4, 4> Matx44d;
|
|
256
|
+
typedef Matx<float, 6, 6> Matx66f;
|
|
257
|
+
typedef Matx<double, 6, 6> Matx66d;
|
|
258
|
+
|
|
259
|
+
/*!
|
|
260
|
+
traits
|
|
261
|
+
*/
|
|
262
|
+
template<typename _Tp, int m, int n> class DataType< Matx<_Tp, m, n> >
|
|
263
|
+
{
|
|
264
|
+
public:
|
|
265
|
+
typedef Matx<_Tp, m, n> value_type;
|
|
266
|
+
typedef Matx<typename DataType<_Tp>::work_type, m, n> work_type;
|
|
267
|
+
typedef _Tp channel_type;
|
|
268
|
+
typedef value_type vec_type;
|
|
269
|
+
|
|
270
|
+
enum { generic_type = 0,
|
|
271
|
+
channels = m * n,
|
|
272
|
+
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
|
273
|
+
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
|
274
|
+
,depth = DataType<channel_type>::depth
|
|
275
|
+
,type = CV_MAKETYPE(depth, channels)
|
|
276
|
+
#endif
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
namespace traits {
|
|
281
|
+
template<typename _Tp, int m, int n>
|
|
282
|
+
struct Depth< Matx<_Tp, m, n> > { enum { value = Depth<_Tp>::value }; };
|
|
283
|
+
template<typename _Tp, int m, int n>
|
|
284
|
+
struct Type< Matx<_Tp, m, n> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, n*m) }; };
|
|
285
|
+
} // namespace
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
/** @brief Comma-separated Matrix Initializer
|
|
289
|
+
*/
|
|
290
|
+
template<typename _Tp, int m, int n> class MatxCommaInitializer
|
|
291
|
+
{
|
|
292
|
+
public:
|
|
293
|
+
MatxCommaInitializer(Matx<_Tp, m, n>* _mtx);
|
|
294
|
+
template<typename T2> MatxCommaInitializer<_Tp, m, n>& operator , (T2 val);
|
|
295
|
+
Matx<_Tp, m, n> operator *() const;
|
|
296
|
+
|
|
297
|
+
Matx<_Tp, m, n>* dst;
|
|
298
|
+
int idx;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
Utility methods
|
|
303
|
+
*/
|
|
304
|
+
template<typename _Tp, int m> static double determinant(const Matx<_Tp, m, m>& a);
|
|
305
|
+
template<typename _Tp, int m, int n> static double trace(const Matx<_Tp, m, n>& a);
|
|
306
|
+
template<typename _Tp, int m, int n> static double norm(const Matx<_Tp, m, n>& M);
|
|
307
|
+
template<typename _Tp, int m, int n> static double norm(const Matx<_Tp, m, n>& M, int normType);
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
/////////////////////// Vec (used as element of multi-channel images /////////////////////
|
|
312
|
+
|
|
313
|
+
/** @brief Template class for short numerical vectors, a partial case of Matx
|
|
314
|
+
|
|
315
|
+
This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) on which you
|
|
316
|
+
can perform basic arithmetical operations, access individual elements using [] operator etc. The
|
|
317
|
+
vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., which
|
|
318
|
+
elements are dynamically allocated in the heap.
|
|
319
|
+
|
|
320
|
+
The template takes 2 parameters:
|
|
321
|
+
@tparam _Tp element type
|
|
322
|
+
@tparam cn the number of elements
|
|
323
|
+
|
|
324
|
+
In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
|
|
325
|
+
for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
|
|
326
|
+
|
|
327
|
+
It is possible to convert Vec\<T,2\> to/from Point_, Vec\<T,3\> to/from Point3_ , and Vec\<T,4\>
|
|
328
|
+
to CvScalar or Scalar_. Use operator[] to access the elements of Vec.
|
|
329
|
+
|
|
330
|
+
All the expected vector operations are also implemented:
|
|
331
|
+
- v1 = v2 + v3
|
|
332
|
+
- v1 = v2 - v3
|
|
333
|
+
- v1 = v2 \* scale
|
|
334
|
+
- v1 = scale \* v2
|
|
335
|
+
- v1 = -v2
|
|
336
|
+
- v1 += v2 and other augmenting operations
|
|
337
|
+
- v1 == v2, v1 != v2
|
|
338
|
+
- norm(v1) (euclidean norm)
|
|
339
|
+
The Vec class is commonly used to describe pixel types of multi-channel arrays. See Mat for details.
|
|
340
|
+
*/
|
|
341
|
+
template<typename _Tp, int cn> class Vec : public Matx<_Tp, cn, 1>
|
|
342
|
+
{
|
|
343
|
+
public:
|
|
344
|
+
typedef _Tp value_type;
|
|
345
|
+
enum {
|
|
346
|
+
channels = cn,
|
|
347
|
+
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
|
348
|
+
depth = Matx<_Tp, cn, 1>::depth,
|
|
349
|
+
type = CV_MAKETYPE(depth, channels),
|
|
350
|
+
#endif
|
|
351
|
+
_dummy_enum_finalizer = 0
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
//! default constructor
|
|
355
|
+
Vec();
|
|
356
|
+
|
|
357
|
+
Vec(_Tp v0); //!< 1-element vector constructor
|
|
358
|
+
Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
|
|
359
|
+
Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor
|
|
360
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor
|
|
361
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor
|
|
362
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor
|
|
363
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor
|
|
364
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor
|
|
365
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor
|
|
366
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor
|
|
367
|
+
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor
|
|
368
|
+
explicit Vec(const _Tp* values);
|
|
369
|
+
|
|
370
|
+
Vec(std::initializer_list<_Tp>);
|
|
371
|
+
|
|
372
|
+
Vec(const Vec<_Tp, cn>& v);
|
|
373
|
+
|
|
374
|
+
static Vec all(_Tp alpha);
|
|
375
|
+
static Vec ones();
|
|
376
|
+
static Vec randn(_Tp a, _Tp b);
|
|
377
|
+
static Vec randu(_Tp a, _Tp b);
|
|
378
|
+
static Vec zeros();
|
|
379
|
+
#ifdef CV_CXX11
|
|
380
|
+
static Vec diag(_Tp alpha) = delete;
|
|
381
|
+
static Vec eye() = delete;
|
|
382
|
+
#endif
|
|
383
|
+
|
|
384
|
+
//! per-element multiplication
|
|
385
|
+
Vec mul(const Vec<_Tp, cn>& v) const;
|
|
386
|
+
|
|
387
|
+
//! conjugation (makes sense for complex numbers and quaternions)
|
|
388
|
+
Vec conj() const;
|
|
389
|
+
|
|
390
|
+
/*!
|
|
391
|
+
cross product of the two 3D vectors.
|
|
392
|
+
|
|
393
|
+
For other dimensionalities the exception is raised
|
|
394
|
+
*/
|
|
395
|
+
Vec cross(const Vec& v) const;
|
|
396
|
+
//! conversion to another data type
|
|
397
|
+
template<typename T2> operator Vec<T2, cn>() const;
|
|
398
|
+
|
|
399
|
+
/*! element access */
|
|
400
|
+
const _Tp& operator [](int i) const;
|
|
401
|
+
_Tp& operator[](int i);
|
|
402
|
+
const _Tp& operator ()(int i) const;
|
|
403
|
+
_Tp& operator ()(int i);
|
|
404
|
+
|
|
405
|
+
#ifdef CV_CXX11
|
|
406
|
+
Vec<_Tp, cn>& operator=(const Vec<_Tp, cn>& rhs) = default;
|
|
407
|
+
#endif
|
|
408
|
+
|
|
409
|
+
Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp);
|
|
410
|
+
Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp);
|
|
411
|
+
template<typename _T2> Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
/** @name Shorter aliases for the most popular specializations of Vec<T,n>
|
|
415
|
+
@{
|
|
416
|
+
*/
|
|
417
|
+
typedef Vec<uchar, 2> Vec2b;
|
|
418
|
+
typedef Vec<uchar, 3> Vec3b;
|
|
419
|
+
typedef Vec<uchar, 4> Vec4b;
|
|
420
|
+
|
|
421
|
+
typedef Vec<short, 2> Vec2s;
|
|
422
|
+
typedef Vec<short, 3> Vec3s;
|
|
423
|
+
typedef Vec<short, 4> Vec4s;
|
|
424
|
+
|
|
425
|
+
typedef Vec<ushort, 2> Vec2w;
|
|
426
|
+
typedef Vec<ushort, 3> Vec3w;
|
|
427
|
+
typedef Vec<ushort, 4> Vec4w;
|
|
428
|
+
|
|
429
|
+
typedef Vec<int, 2> Vec2i;
|
|
430
|
+
typedef Vec<int, 3> Vec3i;
|
|
431
|
+
typedef Vec<int, 4> Vec4i;
|
|
432
|
+
typedef Vec<int, 6> Vec6i;
|
|
433
|
+
typedef Vec<int, 8> Vec8i;
|
|
434
|
+
|
|
435
|
+
typedef Vec<float, 2> Vec2f;
|
|
436
|
+
typedef Vec<float, 3> Vec3f;
|
|
437
|
+
typedef Vec<float, 4> Vec4f;
|
|
438
|
+
typedef Vec<float, 6> Vec6f;
|
|
439
|
+
|
|
440
|
+
typedef Vec<double, 2> Vec2d;
|
|
441
|
+
typedef Vec<double, 3> Vec3d;
|
|
442
|
+
typedef Vec<double, 4> Vec4d;
|
|
443
|
+
typedef Vec<double, 6> Vec6d;
|
|
444
|
+
/** @} */
|
|
445
|
+
|
|
446
|
+
/*!
|
|
447
|
+
traits
|
|
448
|
+
*/
|
|
449
|
+
template<typename _Tp, int cn> class DataType< Vec<_Tp, cn> >
|
|
450
|
+
{
|
|
451
|
+
public:
|
|
452
|
+
typedef Vec<_Tp, cn> value_type;
|
|
453
|
+
typedef Vec<typename DataType<_Tp>::work_type, cn> work_type;
|
|
454
|
+
typedef _Tp channel_type;
|
|
455
|
+
typedef value_type vec_type;
|
|
456
|
+
|
|
457
|
+
enum { generic_type = 0,
|
|
458
|
+
channels = cn,
|
|
459
|
+
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
|
460
|
+
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
|
461
|
+
depth = DataType<channel_type>::depth,
|
|
462
|
+
type = CV_MAKETYPE(depth, channels),
|
|
463
|
+
#endif
|
|
464
|
+
_dummy_enum_finalizer = 0
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
namespace traits {
|
|
469
|
+
template<typename _Tp, int cn>
|
|
470
|
+
struct Depth< Vec<_Tp, cn> > { enum { value = Depth<_Tp>::value }; };
|
|
471
|
+
template<typename _Tp, int cn>
|
|
472
|
+
struct Type< Vec<_Tp, cn> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, cn) }; };
|
|
473
|
+
} // namespace
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
/** @brief Comma-separated Vec Initializer
|
|
477
|
+
*/
|
|
478
|
+
template<typename _Tp, int m> class VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1>
|
|
479
|
+
{
|
|
480
|
+
public:
|
|
481
|
+
VecCommaInitializer(Vec<_Tp, m>* _vec);
|
|
482
|
+
template<typename T2> VecCommaInitializer<_Tp, m>& operator , (T2 val);
|
|
483
|
+
Vec<_Tp, m> operator *() const;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
template<typename _Tp, int cn> static Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v);
|
|
487
|
+
|
|
488
|
+
//! @} core_basic
|
|
489
|
+
|
|
490
|
+
//! @cond IGNORED
|
|
491
|
+
|
|
492
|
+
///////////////////////////////////// helper classes /////////////////////////////////////
|
|
493
|
+
namespace internal
|
|
494
|
+
{
|
|
495
|
+
|
|
496
|
+
template<typename _Tp, int m> struct Matx_DetOp
|
|
497
|
+
{
|
|
498
|
+
double operator ()(const Matx<_Tp, m, m>& a) const
|
|
499
|
+
{
|
|
500
|
+
Matx<_Tp, m, m> temp = a;
|
|
501
|
+
double p = LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0);
|
|
502
|
+
if( p == 0 )
|
|
503
|
+
return p;
|
|
504
|
+
for( int i = 0; i < m; i++ )
|
|
505
|
+
p *= temp(i, i);
|
|
506
|
+
return p;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
template<typename _Tp> struct Matx_DetOp<_Tp, 1>
|
|
511
|
+
{
|
|
512
|
+
double operator ()(const Matx<_Tp, 1, 1>& a) const
|
|
513
|
+
{
|
|
514
|
+
return a(0,0);
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
template<typename _Tp> struct Matx_DetOp<_Tp, 2>
|
|
519
|
+
{
|
|
520
|
+
double operator ()(const Matx<_Tp, 2, 2>& a) const
|
|
521
|
+
{
|
|
522
|
+
return a(0,0)*a(1,1) - a(0,1)*a(1,0);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
template<typename _Tp> struct Matx_DetOp<_Tp, 3>
|
|
527
|
+
{
|
|
528
|
+
double operator ()(const Matx<_Tp, 3, 3>& a) const
|
|
529
|
+
{
|
|
530
|
+
return a(0,0)*(a(1,1)*a(2,2) - a(2,1)*a(1,2)) -
|
|
531
|
+
a(0,1)*(a(1,0)*a(2,2) - a(2,0)*a(1,2)) +
|
|
532
|
+
a(0,2)*(a(1,0)*a(2,1) - a(2,0)*a(1,1));
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
template<typename _Tp> Vec<_Tp, 2> inline conjugate(const Vec<_Tp, 2>& v)
|
|
537
|
+
{
|
|
538
|
+
return Vec<_Tp, 2>(v[0], -v[1]);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
template<typename _Tp> Vec<_Tp, 4> inline conjugate(const Vec<_Tp, 4>& v)
|
|
542
|
+
{
|
|
543
|
+
return Vec<_Tp, 4>(v[0], -v[1], -v[2], -v[3]);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
} // internal
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
////////////////////////////////// Matx Implementation ///////////////////////////////////
|
|
551
|
+
|
|
552
|
+
template<typename _Tp, int m, int n> inline
|
|
553
|
+
Matx<_Tp, m, n>::Matx()
|
|
554
|
+
{
|
|
555
|
+
for(int i = 0; i < channels; i++) val[i] = _Tp(0);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
template<typename _Tp, int m, int n> inline
|
|
559
|
+
Matx<_Tp, m, n>::Matx(_Tp v0)
|
|
560
|
+
{
|
|
561
|
+
val[0] = v0;
|
|
562
|
+
for(int i = 1; i < channels; i++) val[i] = _Tp(0);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
template<typename _Tp, int m, int n> inline
|
|
566
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1)
|
|
567
|
+
{
|
|
568
|
+
CV_StaticAssert(channels >= 2, "Matx should have at least 2 elements.");
|
|
569
|
+
val[0] = v0; val[1] = v1;
|
|
570
|
+
for(int i = 2; i < channels; i++) val[i] = _Tp(0);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
template<typename _Tp, int m, int n> inline
|
|
574
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2)
|
|
575
|
+
{
|
|
576
|
+
CV_StaticAssert(channels >= 3, "Matx should have at least 3 elements.");
|
|
577
|
+
val[0] = v0; val[1] = v1; val[2] = v2;
|
|
578
|
+
for(int i = 3; i < channels; i++) val[i] = _Tp(0);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
template<typename _Tp, int m, int n> inline
|
|
582
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3)
|
|
583
|
+
{
|
|
584
|
+
CV_StaticAssert(channels >= 4, "Matx should have at least 4 elements.");
|
|
585
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
586
|
+
for(int i = 4; i < channels; i++) val[i] = _Tp(0);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
template<typename _Tp, int m, int n> inline
|
|
590
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4)
|
|
591
|
+
{
|
|
592
|
+
CV_StaticAssert(channels >= 5, "Matx should have at least 5 elements.");
|
|
593
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; val[4] = v4;
|
|
594
|
+
for(int i = 5; i < channels; i++) val[i] = _Tp(0);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
template<typename _Tp, int m, int n> inline
|
|
598
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5)
|
|
599
|
+
{
|
|
600
|
+
CV_StaticAssert(channels >= 6, "Matx should have at least 6 elements.");
|
|
601
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
602
|
+
val[4] = v4; val[5] = v5;
|
|
603
|
+
for(int i = 6; i < channels; i++) val[i] = _Tp(0);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
template<typename _Tp, int m, int n> inline
|
|
607
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6)
|
|
608
|
+
{
|
|
609
|
+
CV_StaticAssert(channels >= 7, "Matx should have at least 7 elements.");
|
|
610
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
611
|
+
val[4] = v4; val[5] = v5; val[6] = v6;
|
|
612
|
+
for(int i = 7; i < channels; i++) val[i] = _Tp(0);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
template<typename _Tp, int m, int n> inline
|
|
616
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7)
|
|
617
|
+
{
|
|
618
|
+
CV_StaticAssert(channels >= 8, "Matx should have at least 8 elements.");
|
|
619
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
620
|
+
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
|
621
|
+
for(int i = 8; i < channels; i++) val[i] = _Tp(0);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
template<typename _Tp, int m, int n> inline
|
|
625
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8)
|
|
626
|
+
{
|
|
627
|
+
CV_StaticAssert(channels >= 9, "Matx should have at least 9 elements.");
|
|
628
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
629
|
+
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
|
630
|
+
val[8] = v8;
|
|
631
|
+
for(int i = 9; i < channels; i++) val[i] = _Tp(0);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
template<typename _Tp, int m, int n> inline
|
|
635
|
+
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9)
|
|
636
|
+
{
|
|
637
|
+
CV_StaticAssert(channels >= 10, "Matx should have at least 10 elements.");
|
|
638
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
639
|
+
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
|
640
|
+
val[8] = v8; val[9] = v9;
|
|
641
|
+
for(int i = 10; i < channels; i++) val[i] = _Tp(0);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
template<typename _Tp, int m, int n> inline
|
|
646
|
+
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11)
|
|
647
|
+
{
|
|
648
|
+
CV_StaticAssert(channels >= 12, "Matx should have at least 12 elements.");
|
|
649
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
650
|
+
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
|
651
|
+
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
|
|
652
|
+
for(int i = 12; i < channels; i++) val[i] = _Tp(0);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
template<typename _Tp, int m, int n> inline
|
|
656
|
+
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13)
|
|
657
|
+
{
|
|
658
|
+
CV_StaticAssert(channels >= 14, "Matx should have at least 14 elements.");
|
|
659
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
660
|
+
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
|
661
|
+
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
|
|
662
|
+
val[12] = v12; val[13] = v13;
|
|
663
|
+
for (int i = 14; i < channels; i++) val[i] = _Tp(0);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
template<typename _Tp, int m, int n> inline
|
|
668
|
+
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13, _Tp v14, _Tp v15)
|
|
669
|
+
{
|
|
670
|
+
CV_StaticAssert(channels >= 16, "Matx should have at least 16 elements.");
|
|
671
|
+
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
|
672
|
+
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
|
673
|
+
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
|
|
674
|
+
val[12] = v12; val[13] = v13; val[14] = v14; val[15] = v15;
|
|
675
|
+
for(int i = 16; i < channels; i++) val[i] = _Tp(0);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// WARNING: unreachable code using Ninja
|
|
679
|
+
#if defined _MSC_VER && _MSC_VER >= 1920
|
|
680
|
+
#pragma warning(push)
|
|
681
|
+
#pragma warning(disable: 4702)
|
|
682
|
+
#endif
|
|
683
|
+
template<typename _Tp, int m, int n> inline
|
|
684
|
+
Matx<_Tp, m, n>::Matx(const _Tp* values)
|
|
685
|
+
{
|
|
686
|
+
for( int i = 0; i < channels; i++ ) val[i] = values[i];
|
|
687
|
+
}
|
|
688
|
+
#if defined _MSC_VER && _MSC_VER >= 1920
|
|
689
|
+
#pragma warning(pop)
|
|
690
|
+
#endif
|
|
691
|
+
|
|
692
|
+
template<typename _Tp, int m, int n> inline
|
|
693
|
+
Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list)
|
|
694
|
+
{
|
|
695
|
+
CV_DbgAssert(list.size() == channels);
|
|
696
|
+
int i = 0;
|
|
697
|
+
for(const auto& elem : list)
|
|
698
|
+
{
|
|
699
|
+
val[i++] = elem;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
template<typename _Tp, int m, int n> inline
|
|
704
|
+
Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha)
|
|
705
|
+
{
|
|
706
|
+
Matx<_Tp, m, n> M;
|
|
707
|
+
for( int i = 0; i < m*n; i++ ) M.val[i] = alpha;
|
|
708
|
+
return M;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
template<typename _Tp, int m, int n> inline
|
|
712
|
+
Matx<_Tp,m,n> Matx<_Tp,m,n>::zeros()
|
|
713
|
+
{
|
|
714
|
+
return all(0);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
template<typename _Tp, int m, int n> inline
|
|
718
|
+
Matx<_Tp,m,n> Matx<_Tp,m,n>::ones()
|
|
719
|
+
{
|
|
720
|
+
return all(1);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
template<typename _Tp, int m, int n> inline
|
|
724
|
+
Matx<_Tp,m,n> Matx<_Tp,m,n>::eye()
|
|
725
|
+
{
|
|
726
|
+
Matx<_Tp,m,n> M;
|
|
727
|
+
for(int i = 0; i < shortdim; i++)
|
|
728
|
+
M(i,i) = 1;
|
|
729
|
+
return M;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
template<typename _Tp, int m, int n> inline
|
|
733
|
+
_Tp Matx<_Tp, m, n>::dot(const Matx<_Tp, m, n>& M) const
|
|
734
|
+
{
|
|
735
|
+
_Tp s = 0;
|
|
736
|
+
for( int i = 0; i < channels; i++ ) s += val[i]*M.val[i];
|
|
737
|
+
return s;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
template<typename _Tp, int m, int n> inline
|
|
741
|
+
double Matx<_Tp, m, n>::ddot(const Matx<_Tp, m, n>& M) const
|
|
742
|
+
{
|
|
743
|
+
double s = 0;
|
|
744
|
+
for( int i = 0; i < channels; i++ ) s += (double)val[i]*M.val[i];
|
|
745
|
+
return s;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
template<typename _Tp, int m, int n> inline
|
|
749
|
+
Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const typename Matx<_Tp,m,n>::diag_type& d)
|
|
750
|
+
{
|
|
751
|
+
Matx<_Tp,m,n> M;
|
|
752
|
+
for(int i = 0; i < shortdim; i++)
|
|
753
|
+
M(i,i) = d(i, 0);
|
|
754
|
+
return M;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
template<typename _Tp, int m, int n> template<typename T2>
|
|
758
|
+
inline Matx<_Tp, m, n>::operator Matx<T2, m, n>() const
|
|
759
|
+
{
|
|
760
|
+
Matx<T2, m, n> M;
|
|
761
|
+
for( int i = 0; i < m*n; i++ ) M.val[i] = saturate_cast<T2>(val[i]);
|
|
762
|
+
return M;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
template<typename _Tp, int m, int n> template<int m1, int n1> inline
|
|
766
|
+
Matx<_Tp, m1, n1> Matx<_Tp, m, n>::reshape() const
|
|
767
|
+
{
|
|
768
|
+
CV_StaticAssert(m1*n1 == m*n, "Input and destnarion matrices must have the same number of elements");
|
|
769
|
+
return (const Matx<_Tp, m1, n1>&)*this;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
template<typename _Tp, int m, int n>
|
|
773
|
+
template<int m1, int n1> inline
|
|
774
|
+
Matx<_Tp, m1, n1> Matx<_Tp, m, n>::get_minor(int base_row, int base_col) const
|
|
775
|
+
{
|
|
776
|
+
CV_DbgAssert(0 <= base_row && base_row+m1 <= m && 0 <= base_col && base_col+n1 <= n);
|
|
777
|
+
Matx<_Tp, m1, n1> s;
|
|
778
|
+
for( int di = 0; di < m1; di++ )
|
|
779
|
+
for( int dj = 0; dj < n1; dj++ )
|
|
780
|
+
s(di, dj) = (*this)(base_row+di, base_col+dj);
|
|
781
|
+
return s;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
template<typename _Tp, int m, int n> inline
|
|
785
|
+
Matx<_Tp, 1, n> Matx<_Tp, m, n>::row(int i) const
|
|
786
|
+
{
|
|
787
|
+
CV_DbgAssert((unsigned)i < (unsigned)m);
|
|
788
|
+
return Matx<_Tp, 1, n>(&val[i*n]);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
template<typename _Tp, int m, int n> inline
|
|
792
|
+
Matx<_Tp, m, 1> Matx<_Tp, m, n>::col(int j) const
|
|
793
|
+
{
|
|
794
|
+
CV_DbgAssert((unsigned)j < (unsigned)n);
|
|
795
|
+
Matx<_Tp, m, 1> v;
|
|
796
|
+
for( int i = 0; i < m; i++ )
|
|
797
|
+
v.val[i] = val[i*n + j];
|
|
798
|
+
return v;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
template<typename _Tp, int m, int n> inline
|
|
802
|
+
typename Matx<_Tp, m, n>::diag_type Matx<_Tp, m, n>::diag() const
|
|
803
|
+
{
|
|
804
|
+
diag_type d;
|
|
805
|
+
for( int i = 0; i < shortdim; i++ )
|
|
806
|
+
d.val[i] = val[i*n + i];
|
|
807
|
+
return d;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
template<typename _Tp, int m, int n> inline
|
|
811
|
+
const _Tp& Matx<_Tp, m, n>::operator()(int row_idx, int col_idx) const
|
|
812
|
+
{
|
|
813
|
+
CV_DbgAssert( (unsigned)row_idx < (unsigned)m && (unsigned)col_idx < (unsigned)n );
|
|
814
|
+
return this->val[row_idx*n + col_idx];
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
template<typename _Tp, int m, int n> inline
|
|
818
|
+
_Tp& Matx<_Tp, m, n>::operator ()(int row_idx, int col_idx)
|
|
819
|
+
{
|
|
820
|
+
CV_DbgAssert( (unsigned)row_idx < (unsigned)m && (unsigned)col_idx < (unsigned)n );
|
|
821
|
+
return val[row_idx*n + col_idx];
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
template<typename _Tp, int m, int n> inline
|
|
825
|
+
const _Tp& Matx<_Tp, m, n>::operator ()(int i) const
|
|
826
|
+
{
|
|
827
|
+
CV_StaticAssert(m == 1 || n == 1, "Single index indexation requires matrix to be a column or a row");
|
|
828
|
+
CV_DbgAssert( (unsigned)i < (unsigned)(m+n-1) );
|
|
829
|
+
return val[i];
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
template<typename _Tp, int m, int n> inline
|
|
833
|
+
_Tp& Matx<_Tp, m, n>::operator ()(int i)
|
|
834
|
+
{
|
|
835
|
+
CV_StaticAssert(m == 1 || n == 1, "Single index indexation requires matrix to be a column or a row");
|
|
836
|
+
CV_DbgAssert( (unsigned)i < (unsigned)(m+n-1) );
|
|
837
|
+
return val[i];
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
template<typename _Tp, int m, int n> inline
|
|
841
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp)
|
|
842
|
+
{
|
|
843
|
+
for( int i = 0; i < channels; i++ )
|
|
844
|
+
val[i] = saturate_cast<_Tp>(a.val[i] + b.val[i]);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
template<typename _Tp, int m, int n> inline
|
|
848
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp)
|
|
849
|
+
{
|
|
850
|
+
for( int i = 0; i < channels; i++ )
|
|
851
|
+
val[i] = saturate_cast<_Tp>(a.val[i] - b.val[i]);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
template<typename _Tp, int m, int n> template<typename _T2> inline
|
|
855
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp)
|
|
856
|
+
{
|
|
857
|
+
for( int i = 0; i < channels; i++ )
|
|
858
|
+
val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
template<typename _Tp, int m, int n> inline
|
|
862
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp)
|
|
863
|
+
{
|
|
864
|
+
for( int i = 0; i < channels; i++ )
|
|
865
|
+
val[i] = saturate_cast<_Tp>(a.val[i] * b.val[i]);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
template<typename _Tp, int m, int n> inline
|
|
869
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp)
|
|
870
|
+
{
|
|
871
|
+
for( int i = 0; i < channels; i++ )
|
|
872
|
+
val[i] = saturate_cast<_Tp>(a.val[i] / b.val[i]);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
template<typename _Tp, int m, int n> template<int l> inline
|
|
876
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp)
|
|
877
|
+
{
|
|
878
|
+
for( int i = 0; i < m; i++ )
|
|
879
|
+
for( int j = 0; j < n; j++ )
|
|
880
|
+
{
|
|
881
|
+
_Tp s = 0;
|
|
882
|
+
for( int k = 0; k < l; k++ )
|
|
883
|
+
s += a(i, k) * b(k, j);
|
|
884
|
+
val[i*n + j] = s;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
template<typename _Tp, int m, int n> inline
|
|
889
|
+
Matx<_Tp,m,n>::Matx(const Matx<_Tp, n, m>& a, Matx_TOp)
|
|
890
|
+
{
|
|
891
|
+
for( int i = 0; i < m; i++ )
|
|
892
|
+
for( int j = 0; j < n; j++ )
|
|
893
|
+
val[i*n + j] = a(j, i);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
template<typename _Tp, int m, int n> inline
|
|
897
|
+
Matx<_Tp, m, n> Matx<_Tp, m, n>::mul(const Matx<_Tp, m, n>& a) const
|
|
898
|
+
{
|
|
899
|
+
return Matx<_Tp, m, n>(*this, a, Matx_MulOp());
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
template<typename _Tp, int m, int n> inline
|
|
903
|
+
Matx<_Tp, m, n> Matx<_Tp, m, n>::div(const Matx<_Tp, m, n>& a) const
|
|
904
|
+
{
|
|
905
|
+
return Matx<_Tp, m, n>(*this, a, Matx_DivOp());
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
template<typename _Tp, int m, int n> inline
|
|
909
|
+
Matx<_Tp, n, m> Matx<_Tp, m, n>::t() const
|
|
910
|
+
{
|
|
911
|
+
return Matx<_Tp, n, m>(*this, Matx_TOp());
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
template<typename _Tp, int m, int n> inline
|
|
915
|
+
Vec<_Tp, n> Matx<_Tp, m, n>::solve(const Vec<_Tp, m>& rhs, int method) const
|
|
916
|
+
{
|
|
917
|
+
Matx<_Tp, n, 1> x = solve((const Matx<_Tp, m, 1>&)(rhs), method);
|
|
918
|
+
return (Vec<_Tp, n>&)(x);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
template<typename _Tp, int m> static inline
|
|
922
|
+
double determinant(const Matx<_Tp, m, m>& a)
|
|
923
|
+
{
|
|
924
|
+
return cv::internal::Matx_DetOp<_Tp, m>()(a);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
template<typename _Tp, int m, int n> static inline
|
|
928
|
+
double trace(const Matx<_Tp, m, n>& a)
|
|
929
|
+
{
|
|
930
|
+
_Tp s = 0;
|
|
931
|
+
for( int i = 0; i < std::min(m, n); i++ )
|
|
932
|
+
s += a(i,i);
|
|
933
|
+
return s;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
template<typename _Tp, int m, int n> static inline
|
|
937
|
+
double norm(const Matx<_Tp, m, n>& M)
|
|
938
|
+
{
|
|
939
|
+
return std::sqrt(normL2Sqr<_Tp, double>(M.val, m*n));
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
template<typename _Tp, int m, int n> static inline
|
|
943
|
+
double norm(const Matx<_Tp, m, n>& M, int normType)
|
|
944
|
+
{
|
|
945
|
+
switch(normType) {
|
|
946
|
+
case NORM_INF:
|
|
947
|
+
return (double)normInf<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n);
|
|
948
|
+
case NORM_L1:
|
|
949
|
+
return (double)normL1<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n);
|
|
950
|
+
case NORM_L2SQR:
|
|
951
|
+
return (double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n);
|
|
952
|
+
default:
|
|
953
|
+
case NORM_L2:
|
|
954
|
+
return std::sqrt((double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n));
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
//////////////////////////////// matx comma initializer //////////////////////////////////
|
|
961
|
+
|
|
962
|
+
template<typename _Tp, typename _T2, int m, int n> static inline
|
|
963
|
+
MatxCommaInitializer<_Tp, m, n> operator << (const Matx<_Tp, m, n>& mtx, _T2 val)
|
|
964
|
+
{
|
|
965
|
+
MatxCommaInitializer<_Tp, m, n> commaInitializer((Matx<_Tp, m, n>*)&mtx);
|
|
966
|
+
return (commaInitializer, val);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
template<typename _Tp, int m, int n> inline
|
|
970
|
+
MatxCommaInitializer<_Tp, m, n>::MatxCommaInitializer(Matx<_Tp, m, n>* _mtx)
|
|
971
|
+
: dst(_mtx), idx(0)
|
|
972
|
+
{}
|
|
973
|
+
|
|
974
|
+
template<typename _Tp, int m, int n> template<typename _T2> inline
|
|
975
|
+
MatxCommaInitializer<_Tp, m, n>& MatxCommaInitializer<_Tp, m, n>::operator , (_T2 value)
|
|
976
|
+
{
|
|
977
|
+
CV_DbgAssert( idx < m*n );
|
|
978
|
+
dst->val[idx++] = saturate_cast<_Tp>(value);
|
|
979
|
+
return *this;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
template<typename _Tp, int m, int n> inline
|
|
983
|
+
Matx<_Tp, m, n> MatxCommaInitializer<_Tp, m, n>::operator *() const
|
|
984
|
+
{
|
|
985
|
+
CV_DbgAssert( idx == n*m );
|
|
986
|
+
return *dst;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
/////////////////////////////////// Vec Implementation ///////////////////////////////////
|
|
992
|
+
|
|
993
|
+
template<typename _Tp, int cn> inline
|
|
994
|
+
Vec<_Tp, cn>::Vec() {}
|
|
995
|
+
|
|
996
|
+
template<typename _Tp, int cn> inline
|
|
997
|
+
Vec<_Tp, cn>::Vec(_Tp v0)
|
|
998
|
+
: Matx<_Tp, cn, 1>(v0) {}
|
|
999
|
+
|
|
1000
|
+
template<typename _Tp, int cn> inline
|
|
1001
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1)
|
|
1002
|
+
: Matx<_Tp, cn, 1>(v0, v1) {}
|
|
1003
|
+
|
|
1004
|
+
template<typename _Tp, int cn> inline
|
|
1005
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2)
|
|
1006
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2) {}
|
|
1007
|
+
|
|
1008
|
+
template<typename _Tp, int cn> inline
|
|
1009
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3)
|
|
1010
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3) {}
|
|
1011
|
+
|
|
1012
|
+
template<typename _Tp, int cn> inline
|
|
1013
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4)
|
|
1014
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4) {}
|
|
1015
|
+
|
|
1016
|
+
template<typename _Tp, int cn> inline
|
|
1017
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5)
|
|
1018
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5) {}
|
|
1019
|
+
|
|
1020
|
+
template<typename _Tp, int cn> inline
|
|
1021
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6)
|
|
1022
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6) {}
|
|
1023
|
+
|
|
1024
|
+
template<typename _Tp, int cn> inline
|
|
1025
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7)
|
|
1026
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7) {}
|
|
1027
|
+
|
|
1028
|
+
template<typename _Tp, int cn> inline
|
|
1029
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8)
|
|
1030
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8) {}
|
|
1031
|
+
|
|
1032
|
+
template<typename _Tp, int cn> inline
|
|
1033
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9)
|
|
1034
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {}
|
|
1035
|
+
|
|
1036
|
+
template<typename _Tp, int cn> inline
|
|
1037
|
+
Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13)
|
|
1038
|
+
: Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) {}
|
|
1039
|
+
|
|
1040
|
+
template<typename _Tp, int cn> inline
|
|
1041
|
+
Vec<_Tp, cn>::Vec(const _Tp* values)
|
|
1042
|
+
: Matx<_Tp, cn, 1>(values) {}
|
|
1043
|
+
|
|
1044
|
+
template<typename _Tp, int cn> inline
|
|
1045
|
+
Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list)
|
|
1046
|
+
: Matx<_Tp, cn, 1>(list) {}
|
|
1047
|
+
|
|
1048
|
+
template<typename _Tp, int cn> inline
|
|
1049
|
+
Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m)
|
|
1050
|
+
: Matx<_Tp, cn, 1>(m.val) {}
|
|
1051
|
+
|
|
1052
|
+
template<typename _Tp, int cn> inline
|
|
1053
|
+
Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp op)
|
|
1054
|
+
: Matx<_Tp, cn, 1>(a, b, op) {}
|
|
1055
|
+
|
|
1056
|
+
template<typename _Tp, int cn> inline
|
|
1057
|
+
Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp op)
|
|
1058
|
+
: Matx<_Tp, cn, 1>(a, b, op) {}
|
|
1059
|
+
|
|
1060
|
+
template<typename _Tp, int cn> template<typename _T2> inline
|
|
1061
|
+
Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp op)
|
|
1062
|
+
: Matx<_Tp, cn, 1>(a, alpha, op) {}
|
|
1063
|
+
|
|
1064
|
+
template<typename _Tp, int cn> inline
|
|
1065
|
+
Vec<_Tp, cn> Vec<_Tp, cn>::all(_Tp alpha)
|
|
1066
|
+
{
|
|
1067
|
+
Vec v;
|
|
1068
|
+
for( int i = 0; i < cn; i++ ) v.val[i] = alpha;
|
|
1069
|
+
return v;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
template<typename _Tp, int cn> inline
|
|
1073
|
+
Vec<_Tp, cn> Vec<_Tp, cn>::ones()
|
|
1074
|
+
{
|
|
1075
|
+
return Vec::all(1);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
template<typename _Tp, int cn> inline
|
|
1079
|
+
Vec<_Tp, cn> Vec<_Tp, cn>::zeros()
|
|
1080
|
+
{
|
|
1081
|
+
return Vec::all(0);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
template<typename _Tp, int cn> inline
|
|
1085
|
+
Vec<_Tp, cn> Vec<_Tp, cn>::mul(const Vec<_Tp, cn>& v) const
|
|
1086
|
+
{
|
|
1087
|
+
Vec<_Tp, cn> w;
|
|
1088
|
+
for( int i = 0; i < cn; i++ ) w.val[i] = saturate_cast<_Tp>(this->val[i]*v.val[i]);
|
|
1089
|
+
return w;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
template<> inline
|
|
1093
|
+
Vec<float, 2> Vec<float, 2>::conj() const
|
|
1094
|
+
{
|
|
1095
|
+
return cv::internal::conjugate(*this);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
template<> inline
|
|
1099
|
+
Vec<double, 2> Vec<double, 2>::conj() const
|
|
1100
|
+
{
|
|
1101
|
+
return cv::internal::conjugate(*this);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
template<> inline
|
|
1105
|
+
Vec<float, 4> Vec<float, 4>::conj() const
|
|
1106
|
+
{
|
|
1107
|
+
return cv::internal::conjugate(*this);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
template<> inline
|
|
1111
|
+
Vec<double, 4> Vec<double, 4>::conj() const
|
|
1112
|
+
{
|
|
1113
|
+
return cv::internal::conjugate(*this);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
template<typename _Tp, int cn> inline
|
|
1117
|
+
Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>&) const
|
|
1118
|
+
{
|
|
1119
|
+
CV_StaticAssert(cn == 3, "for arbitrary-size vector there is no cross-product defined");
|
|
1120
|
+
return Vec<_Tp, cn>();
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
template<> inline
|
|
1124
|
+
Vec<float, 3> Vec<float, 3>::cross(const Vec<float, 3>& v) const
|
|
1125
|
+
{
|
|
1126
|
+
return Vec<float,3>(this->val[1]*v.val[2] - this->val[2]*v.val[1],
|
|
1127
|
+
this->val[2]*v.val[0] - this->val[0]*v.val[2],
|
|
1128
|
+
this->val[0]*v.val[1] - this->val[1]*v.val[0]);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
template<> inline
|
|
1132
|
+
Vec<double, 3> Vec<double, 3>::cross(const Vec<double, 3>& v) const
|
|
1133
|
+
{
|
|
1134
|
+
return Vec<double,3>(this->val[1]*v.val[2] - this->val[2]*v.val[1],
|
|
1135
|
+
this->val[2]*v.val[0] - this->val[0]*v.val[2],
|
|
1136
|
+
this->val[0]*v.val[1] - this->val[1]*v.val[0]);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
template<typename _Tp, int cn> template<typename T2> inline
|
|
1140
|
+
Vec<_Tp, cn>::operator Vec<T2, cn>() const
|
|
1141
|
+
{
|
|
1142
|
+
Vec<T2, cn> v;
|
|
1143
|
+
for( int i = 0; i < cn; i++ ) v.val[i] = saturate_cast<T2>(this->val[i]);
|
|
1144
|
+
return v;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
template<typename _Tp, int cn> inline
|
|
1148
|
+
const _Tp& Vec<_Tp, cn>::operator [](int i) const
|
|
1149
|
+
{
|
|
1150
|
+
CV_DbgAssert( (unsigned)i < (unsigned)cn );
|
|
1151
|
+
return this->val[i];
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
template<typename _Tp, int cn> inline
|
|
1155
|
+
_Tp& Vec<_Tp, cn>::operator [](int i)
|
|
1156
|
+
{
|
|
1157
|
+
CV_DbgAssert( (unsigned)i < (unsigned)cn );
|
|
1158
|
+
return this->val[i];
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
template<typename _Tp, int cn> inline
|
|
1162
|
+
const _Tp& Vec<_Tp, cn>::operator ()(int i) const
|
|
1163
|
+
{
|
|
1164
|
+
CV_DbgAssert( (unsigned)i < (unsigned)cn );
|
|
1165
|
+
return this->val[i];
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
template<typename _Tp, int cn> inline
|
|
1169
|
+
_Tp& Vec<_Tp, cn>::operator ()(int i)
|
|
1170
|
+
{
|
|
1171
|
+
CV_DbgAssert( (unsigned)i < (unsigned)cn );
|
|
1172
|
+
return this->val[i];
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
template<typename _Tp, int cn> inline
|
|
1176
|
+
Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v)
|
|
1177
|
+
{
|
|
1178
|
+
double nv = norm(v);
|
|
1179
|
+
return v * (nv ? 1./nv : 0.);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
//////////////////////////////// vec comma initializer //////////////////////////////////
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
template<typename _Tp, typename _T2, int cn> static inline
|
|
1188
|
+
VecCommaInitializer<_Tp, cn> operator << (const Vec<_Tp, cn>& vec, _T2 val)
|
|
1189
|
+
{
|
|
1190
|
+
VecCommaInitializer<_Tp, cn> commaInitializer((Vec<_Tp, cn>*)&vec);
|
|
1191
|
+
return (commaInitializer, val);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
template<typename _Tp, int cn> inline
|
|
1195
|
+
VecCommaInitializer<_Tp, cn>::VecCommaInitializer(Vec<_Tp, cn>* _vec)
|
|
1196
|
+
: MatxCommaInitializer<_Tp, cn, 1>(_vec)
|
|
1197
|
+
{}
|
|
1198
|
+
|
|
1199
|
+
template<typename _Tp, int cn> template<typename _T2> inline
|
|
1200
|
+
VecCommaInitializer<_Tp, cn>& VecCommaInitializer<_Tp, cn>::operator , (_T2 value)
|
|
1201
|
+
{
|
|
1202
|
+
CV_DbgAssert( this->idx < cn );
|
|
1203
|
+
this->dst->val[this->idx++] = saturate_cast<_Tp>(value);
|
|
1204
|
+
return *this;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
template<typename _Tp, int cn> inline
|
|
1208
|
+
Vec<_Tp, cn> VecCommaInitializer<_Tp, cn>::operator *() const
|
|
1209
|
+
{
|
|
1210
|
+
CV_DbgAssert( this->idx == cn );
|
|
1211
|
+
return *this->dst;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
//! @endcond
|
|
1215
|
+
|
|
1216
|
+
///////////////////////////// Matx out-of-class operators ////////////////////////////////
|
|
1217
|
+
|
|
1218
|
+
//! @relates cv::Matx
|
|
1219
|
+
//! @{
|
|
1220
|
+
|
|
1221
|
+
template<typename _Tp1, typename _Tp2, int m, int n> static inline
|
|
1222
|
+
Matx<_Tp1, m, n>& operator += (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b)
|
|
1223
|
+
{
|
|
1224
|
+
for( int i = 0; i < m*n; i++ )
|
|
1225
|
+
a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]);
|
|
1226
|
+
return a;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
template<typename _Tp1, typename _Tp2, int m, int n> static inline
|
|
1230
|
+
Matx<_Tp1, m, n>& operator -= (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b)
|
|
1231
|
+
{
|
|
1232
|
+
for( int i = 0; i < m*n; i++ )
|
|
1233
|
+
a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]);
|
|
1234
|
+
return a;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
template<typename _Tp, int m, int n> static inline
|
|
1238
|
+
Matx<_Tp, m, n> operator + (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b)
|
|
1239
|
+
{
|
|
1240
|
+
return Matx<_Tp, m, n>(a, b, Matx_AddOp());
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
template<typename _Tp, int m, int n> static inline
|
|
1244
|
+
Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b)
|
|
1245
|
+
{
|
|
1246
|
+
return Matx<_Tp, m, n>(a, b, Matx_SubOp());
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
template<typename _Tp, int m, int n> static inline
|
|
1250
|
+
Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, int alpha)
|
|
1251
|
+
{
|
|
1252
|
+
for( int i = 0; i < m*n; i++ )
|
|
1253
|
+
a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
|
|
1254
|
+
return a;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
template<typename _Tp, int m, int n> static inline
|
|
1258
|
+
Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, float alpha)
|
|
1259
|
+
{
|
|
1260
|
+
for( int i = 0; i < m*n; i++ )
|
|
1261
|
+
a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
|
|
1262
|
+
return a;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
template<typename _Tp, int m, int n> static inline
|
|
1266
|
+
Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, double alpha)
|
|
1267
|
+
{
|
|
1268
|
+
for( int i = 0; i < m*n; i++ )
|
|
1269
|
+
a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
|
|
1270
|
+
return a;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
template<typename _Tp, int m, int n> static inline
|
|
1274
|
+
Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, int alpha)
|
|
1275
|
+
{
|
|
1276
|
+
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
template<typename _Tp, int m, int n> static inline
|
|
1280
|
+
Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, float alpha)
|
|
1281
|
+
{
|
|
1282
|
+
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
template<typename _Tp, int m, int n> static inline
|
|
1286
|
+
Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, double alpha)
|
|
1287
|
+
{
|
|
1288
|
+
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
template<typename _Tp, int m, int n> static inline
|
|
1292
|
+
Matx<_Tp, m, n> operator * (int alpha, const Matx<_Tp, m, n>& a)
|
|
1293
|
+
{
|
|
1294
|
+
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
template<typename _Tp, int m, int n> static inline
|
|
1298
|
+
Matx<_Tp, m, n> operator * (float alpha, const Matx<_Tp, m, n>& a)
|
|
1299
|
+
{
|
|
1300
|
+
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
template<typename _Tp, int m, int n> static inline
|
|
1304
|
+
Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a)
|
|
1305
|
+
{
|
|
1306
|
+
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
template<typename _Tp, int m, int n> static inline
|
|
1310
|
+
Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, float alpha)
|
|
1311
|
+
{
|
|
1312
|
+
for( int i = 0; i < m*n; i++ )
|
|
1313
|
+
a.val[i] = a.val[i] / alpha;
|
|
1314
|
+
return a;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
template<typename _Tp, int m, int n> static inline
|
|
1318
|
+
Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, double alpha)
|
|
1319
|
+
{
|
|
1320
|
+
for( int i = 0; i < m*n; i++ )
|
|
1321
|
+
a.val[i] = a.val[i] / alpha;
|
|
1322
|
+
return a;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
template<typename _Tp, int m, int n> static inline
|
|
1326
|
+
Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha)
|
|
1327
|
+
{
|
|
1328
|
+
return Matx<_Tp, m, n>(a, 1.f/alpha, Matx_ScaleOp());
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
template<typename _Tp, int m, int n> static inline
|
|
1332
|
+
Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, double alpha)
|
|
1333
|
+
{
|
|
1334
|
+
return Matx<_Tp, m, n>(a, 1./alpha, Matx_ScaleOp());
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
template<typename _Tp, int m, int n> static inline
|
|
1338
|
+
Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a)
|
|
1339
|
+
{
|
|
1340
|
+
return Matx<_Tp, m, n>(a, -1, Matx_ScaleOp());
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
template<typename _Tp, int m, int n, int l> static inline
|
|
1344
|
+
Matx<_Tp, m, n> operator * (const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b)
|
|
1345
|
+
{
|
|
1346
|
+
return Matx<_Tp, m, n>(a, b, Matx_MatMulOp());
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
template<typename _Tp, int m, int n> static inline
|
|
1350
|
+
Vec<_Tp, m> operator * (const Matx<_Tp, m, n>& a, const Vec<_Tp, n>& b)
|
|
1351
|
+
{
|
|
1352
|
+
Matx<_Tp, m, 1> c(a, b, Matx_MatMulOp());
|
|
1353
|
+
return (const Vec<_Tp, m>&)(c);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
template<typename _Tp, int m, int n> static inline
|
|
1357
|
+
bool operator == (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b)
|
|
1358
|
+
{
|
|
1359
|
+
for( int i = 0; i < m*n; i++ )
|
|
1360
|
+
if( a.val[i] != b.val[i] ) return false;
|
|
1361
|
+
return true;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
template<typename _Tp, int m, int n> static inline
|
|
1365
|
+
bool operator != (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b)
|
|
1366
|
+
{
|
|
1367
|
+
return !(a == b);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
//! @}
|
|
1371
|
+
|
|
1372
|
+
////////////////////////////// Vec out-of-class operators ////////////////////////////////
|
|
1373
|
+
|
|
1374
|
+
//! @relates cv::Vec
|
|
1375
|
+
//! @{
|
|
1376
|
+
|
|
1377
|
+
template<typename _Tp1, typename _Tp2, int cn> static inline
|
|
1378
|
+
Vec<_Tp1, cn>& operator += (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b)
|
|
1379
|
+
{
|
|
1380
|
+
for( int i = 0; i < cn; i++ )
|
|
1381
|
+
a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]);
|
|
1382
|
+
return a;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
template<typename _Tp1, typename _Tp2, int cn> static inline
|
|
1386
|
+
Vec<_Tp1, cn>& operator -= (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b)
|
|
1387
|
+
{
|
|
1388
|
+
for( int i = 0; i < cn; i++ )
|
|
1389
|
+
a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]);
|
|
1390
|
+
return a;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
template<typename _Tp, int cn> static inline
|
|
1394
|
+
Vec<_Tp, cn> operator + (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b)
|
|
1395
|
+
{
|
|
1396
|
+
return Vec<_Tp, cn>(a, b, Matx_AddOp());
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
template<typename _Tp, int cn> static inline
|
|
1400
|
+
Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b)
|
|
1401
|
+
{
|
|
1402
|
+
return Vec<_Tp, cn>(a, b, Matx_SubOp());
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
template<typename _Tp, int cn> static inline
|
|
1406
|
+
Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, int alpha)
|
|
1407
|
+
{
|
|
1408
|
+
for( int i = 0; i < cn; i++ )
|
|
1409
|
+
a[i] = saturate_cast<_Tp>(a[i]*alpha);
|
|
1410
|
+
return a;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
template<typename _Tp, int cn> static inline
|
|
1414
|
+
Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, float alpha)
|
|
1415
|
+
{
|
|
1416
|
+
for( int i = 0; i < cn; i++ )
|
|
1417
|
+
a[i] = saturate_cast<_Tp>(a[i]*alpha);
|
|
1418
|
+
return a;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
template<typename _Tp, int cn> static inline
|
|
1422
|
+
Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, double alpha)
|
|
1423
|
+
{
|
|
1424
|
+
for( int i = 0; i < cn; i++ )
|
|
1425
|
+
a[i] = saturate_cast<_Tp>(a[i]*alpha);
|
|
1426
|
+
return a;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
template<typename _Tp, int cn> static inline
|
|
1430
|
+
Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, int alpha)
|
|
1431
|
+
{
|
|
1432
|
+
double ialpha = 1./alpha;
|
|
1433
|
+
for( int i = 0; i < cn; i++ )
|
|
1434
|
+
a[i] = saturate_cast<_Tp>(a[i]*ialpha);
|
|
1435
|
+
return a;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
template<typename _Tp, int cn> static inline
|
|
1439
|
+
Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, float alpha)
|
|
1440
|
+
{
|
|
1441
|
+
float ialpha = 1.f/alpha;
|
|
1442
|
+
for( int i = 0; i < cn; i++ )
|
|
1443
|
+
a[i] = saturate_cast<_Tp>(a[i]*ialpha);
|
|
1444
|
+
return a;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
template<typename _Tp, int cn> static inline
|
|
1448
|
+
Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, double alpha)
|
|
1449
|
+
{
|
|
1450
|
+
double ialpha = 1./alpha;
|
|
1451
|
+
for( int i = 0; i < cn; i++ )
|
|
1452
|
+
a[i] = saturate_cast<_Tp>(a[i]*ialpha);
|
|
1453
|
+
return a;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
template<typename _Tp, int cn> static inline
|
|
1457
|
+
Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, int alpha)
|
|
1458
|
+
{
|
|
1459
|
+
return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp());
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
template<typename _Tp, int cn> static inline
|
|
1463
|
+
Vec<_Tp, cn> operator * (int alpha, const Vec<_Tp, cn>& a)
|
|
1464
|
+
{
|
|
1465
|
+
return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp());
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
template<typename _Tp, int cn> static inline
|
|
1469
|
+
Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, float alpha)
|
|
1470
|
+
{
|
|
1471
|
+
return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp());
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
template<typename _Tp, int cn> static inline
|
|
1475
|
+
Vec<_Tp, cn> operator * (float alpha, const Vec<_Tp, cn>& a)
|
|
1476
|
+
{
|
|
1477
|
+
return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp());
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
template<typename _Tp, int cn> static inline
|
|
1481
|
+
Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, double alpha)
|
|
1482
|
+
{
|
|
1483
|
+
return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp());
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
template<typename _Tp, int cn> static inline
|
|
1487
|
+
Vec<_Tp, cn> operator * (double alpha, const Vec<_Tp, cn>& a)
|
|
1488
|
+
{
|
|
1489
|
+
return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp());
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
template<typename _Tp, int cn> static inline
|
|
1493
|
+
Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, int alpha)
|
|
1494
|
+
{
|
|
1495
|
+
return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp());
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
template<typename _Tp, int cn> static inline
|
|
1499
|
+
Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, float alpha)
|
|
1500
|
+
{
|
|
1501
|
+
return Vec<_Tp, cn>(a, 1.f/alpha, Matx_ScaleOp());
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
template<typename _Tp, int cn> static inline
|
|
1505
|
+
Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, double alpha)
|
|
1506
|
+
{
|
|
1507
|
+
return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp());
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
template<typename _Tp, int cn> static inline
|
|
1511
|
+
Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a)
|
|
1512
|
+
{
|
|
1513
|
+
Vec<_Tp,cn> t;
|
|
1514
|
+
for( int i = 0; i < cn; i++ ) t.val[i] = saturate_cast<_Tp>(-a.val[i]);
|
|
1515
|
+
return t;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
template<typename _Tp> inline Vec<_Tp, 4> operator * (const Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2)
|
|
1519
|
+
{
|
|
1520
|
+
return Vec<_Tp, 4>(saturate_cast<_Tp>(v1[0]*v2[0] - v1[1]*v2[1] - v1[2]*v2[2] - v1[3]*v2[3]),
|
|
1521
|
+
saturate_cast<_Tp>(v1[0]*v2[1] + v1[1]*v2[0] + v1[2]*v2[3] - v1[3]*v2[2]),
|
|
1522
|
+
saturate_cast<_Tp>(v1[0]*v2[2] - v1[1]*v2[3] + v1[2]*v2[0] + v1[3]*v2[1]),
|
|
1523
|
+
saturate_cast<_Tp>(v1[0]*v2[3] + v1[1]*v2[2] - v1[2]*v2[1] + v1[3]*v2[0]));
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
template<typename _Tp> inline Vec<_Tp, 4>& operator *= (Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2)
|
|
1527
|
+
{
|
|
1528
|
+
v1 = v1 * v2;
|
|
1529
|
+
return v1;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
//! @}
|
|
1533
|
+
|
|
1534
|
+
} // cv
|
|
1535
|
+
|
|
1536
|
+
#endif // OPENCV_CORE_MATX_HPP
|