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.
Files changed (174) hide show
  1. package/README.md +144 -27
  2. package/binding.gyp +18 -5
  3. package/dist/index.d.ts +146 -4
  4. package/dist/index.js +107 -3
  5. package/include/opencv2/core/affine.hpp +678 -0
  6. package/include/opencv2/core/async.hpp +105 -0
  7. package/include/opencv2/core/base.hpp +664 -0
  8. package/include/opencv2/core/bindings_utils.hpp +325 -0
  9. package/include/opencv2/core/bufferpool.hpp +40 -0
  10. package/include/opencv2/core/check.hpp +170 -0
  11. package/include/opencv2/core/core.hpp +48 -0
  12. package/include/opencv2/core/core_c.h +3128 -0
  13. package/include/opencv2/core/cuda/block.hpp +211 -0
  14. package/include/opencv2/core/cuda/border_interpolate.hpp +722 -0
  15. package/include/opencv2/core/cuda/color.hpp +309 -0
  16. package/include/opencv2/core/cuda/common.hpp +131 -0
  17. package/include/opencv2/core/cuda/datamov_utils.hpp +113 -0
  18. package/include/opencv2/core/cuda/detail/color_detail.hpp +2018 -0
  19. package/include/opencv2/core/cuda/detail/reduce.hpp +365 -0
  20. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +502 -0
  21. package/include/opencv2/core/cuda/detail/transform_detail.hpp +392 -0
  22. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +191 -0
  23. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +121 -0
  24. package/include/opencv2/core/cuda/dynamic_smem.hpp +88 -0
  25. package/include/opencv2/core/cuda/emulation.hpp +269 -0
  26. package/include/opencv2/core/cuda/filters.hpp +293 -0
  27. package/include/opencv2/core/cuda/funcattrib.hpp +79 -0
  28. package/include/opencv2/core/cuda/functional.hpp +805 -0
  29. package/include/opencv2/core/cuda/limits.hpp +128 -0
  30. package/include/opencv2/core/cuda/reduce.hpp +209 -0
  31. package/include/opencv2/core/cuda/saturate_cast.hpp +292 -0
  32. package/include/opencv2/core/cuda/scan.hpp +258 -0
  33. package/include/opencv2/core/cuda/simd_functions.hpp +869 -0
  34. package/include/opencv2/core/cuda/transform.hpp +75 -0
  35. package/include/opencv2/core/cuda/type_traits.hpp +90 -0
  36. package/include/opencv2/core/cuda/utility.hpp +230 -0
  37. package/include/opencv2/core/cuda/vec_distance.hpp +232 -0
  38. package/include/opencv2/core/cuda/vec_math.hpp +923 -0
  39. package/include/opencv2/core/cuda/vec_traits.hpp +288 -0
  40. package/include/opencv2/core/cuda/warp.hpp +139 -0
  41. package/include/opencv2/core/cuda/warp_reduce.hpp +76 -0
  42. package/include/opencv2/core/cuda/warp_shuffle.hpp +162 -0
  43. package/include/opencv2/core/cuda.hpp +1279 -0
  44. package/include/opencv2/core/cuda.inl.hpp +763 -0
  45. package/include/opencv2/core/cuda_stream_accessor.hpp +86 -0
  46. package/include/opencv2/core/cuda_types.hpp +144 -0
  47. package/include/opencv2/core/cv_cpu_dispatch.h +381 -0
  48. package/include/opencv2/core/cv_cpu_helper.h +550 -0
  49. package/include/opencv2/core/cvdef.h +973 -0
  50. package/include/opencv2/core/cvstd.hpp +190 -0
  51. package/include/opencv2/core/cvstd.inl.hpp +197 -0
  52. package/include/opencv2/core/cvstd_wrapper.hpp +154 -0
  53. package/include/opencv2/core/detail/async_promise.hpp +71 -0
  54. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +49 -0
  55. package/include/opencv2/core/detail/exception_ptr.hpp +27 -0
  56. package/include/opencv2/core/directx.hpp +184 -0
  57. package/include/opencv2/core/dualquaternion.hpp +979 -0
  58. package/include/opencv2/core/dualquaternion.inl.hpp +487 -0
  59. package/include/opencv2/core/eigen.hpp +402 -0
  60. package/include/opencv2/core/fast_math.hpp +433 -0
  61. package/include/opencv2/core/hal/hal.hpp +256 -0
  62. package/include/opencv2/core/hal/interface.h +190 -0
  63. package/include/opencv2/core/hal/intrin.hpp +939 -0
  64. package/include/opencv2/core/hal/intrin_avx.hpp +3177 -0
  65. package/include/opencv2/core/hal/intrin_avx512.hpp +3090 -0
  66. package/include/opencv2/core/hal/intrin_cpp.hpp +3321 -0
  67. package/include/opencv2/core/hal/intrin_forward.hpp +191 -0
  68. package/include/opencv2/core/hal/intrin_lasx.hpp +3236 -0
  69. package/include/opencv2/core/hal/intrin_msa.hpp +1887 -0
  70. package/include/opencv2/core/hal/intrin_neon.hpp +2610 -0
  71. package/include/opencv2/core/hal/intrin_rvv.hpp +3320 -0
  72. package/include/opencv2/core/hal/intrin_rvv071.hpp +2545 -0
  73. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2080 -0
  74. package/include/opencv2/core/hal/intrin_sse.hpp +3467 -0
  75. package/include/opencv2/core/hal/intrin_sse_em.hpp +180 -0
  76. package/include/opencv2/core/hal/intrin_vsx.hpp +1608 -0
  77. package/include/opencv2/core/hal/intrin_wasm.hpp +2782 -0
  78. package/include/opencv2/core/hal/msa_macros.h +1558 -0
  79. package/include/opencv2/core/hal/simd_utils.impl.hpp +186 -0
  80. package/include/opencv2/core/llapi/llapi.h +102 -0
  81. package/include/opencv2/core/mat.hpp +3775 -0
  82. package/include/opencv2/core/mat.inl.hpp +3422 -0
  83. package/include/opencv2/core/matx.hpp +1536 -0
  84. package/include/opencv2/core/neon_utils.hpp +128 -0
  85. package/include/opencv2/core/ocl.hpp +917 -0
  86. package/include/opencv2/core/ocl_genbase.hpp +69 -0
  87. package/include/opencv2/core/opencl/ocl_defs.hpp +82 -0
  88. package/include/opencv2/core/opencl/opencl_info.hpp +212 -0
  89. package/include/opencv2/core/opencl/opencl_svm.hpp +81 -0
  90. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +602 -0
  91. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +146 -0
  92. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +371 -0
  93. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +272 -0
  94. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +62 -0
  95. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +42 -0
  96. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +53 -0
  97. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +53 -0
  98. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +84 -0
  99. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +47 -0
  100. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +53 -0
  101. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +47 -0
  102. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +48 -0
  103. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +42 -0
  104. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +166 -0
  105. package/include/opencv2/core/opengl.hpp +733 -0
  106. package/include/opencv2/core/openvx/ovx_defs.hpp +48 -0
  107. package/include/opencv2/core/operations.hpp +610 -0
  108. package/include/opencv2/core/optim.hpp +302 -0
  109. package/include/opencv2/core/ovx.hpp +28 -0
  110. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +72 -0
  111. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +153 -0
  112. package/include/opencv2/core/parallel/parallel_backend.hpp +90 -0
  113. package/include/opencv2/core/persistence.hpp +1350 -0
  114. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +30 -0
  115. package/include/opencv2/core/private.cuda.hpp +169 -0
  116. package/include/opencv2/core/private.hpp +896 -0
  117. package/include/opencv2/core/quaternion.hpp +1696 -0
  118. package/include/opencv2/core/quaternion.inl.hpp +1063 -0
  119. package/include/opencv2/core/saturate.hpp +180 -0
  120. package/include/opencv2/core/simd_intrinsics.hpp +87 -0
  121. package/include/opencv2/core/softfloat.hpp +514 -0
  122. package/include/opencv2/core/sse_utils.hpp +652 -0
  123. package/include/opencv2/core/traits.hpp +417 -0
  124. package/include/opencv2/core/types.hpp +2457 -0
  125. package/include/opencv2/core/types_c.h +2126 -0
  126. package/include/opencv2/core/utility.hpp +1229 -0
  127. package/include/opencv2/core/utils/allocator_stats.hpp +29 -0
  128. package/include/opencv2/core/utils/allocator_stats.impl.hpp +158 -0
  129. package/include/opencv2/core/utils/buffer_area.private.hpp +136 -0
  130. package/include/opencv2/core/utils/configuration.private.hpp +22 -0
  131. package/include/opencv2/core/utils/filesystem.hpp +82 -0
  132. package/include/opencv2/core/utils/filesystem.private.hpp +66 -0
  133. package/include/opencv2/core/utils/fp_control.private.hpp +29 -0
  134. package/include/opencv2/core/utils/fp_control_utils.hpp +69 -0
  135. package/include/opencv2/core/utils/instrumentation.hpp +125 -0
  136. package/include/opencv2/core/utils/lock.private.hpp +119 -0
  137. package/include/opencv2/core/utils/logger.defines.hpp +42 -0
  138. package/include/opencv2/core/utils/logger.hpp +218 -0
  139. package/include/opencv2/core/utils/logtag.hpp +28 -0
  140. package/include/opencv2/core/utils/plugin_loader.private.hpp +165 -0
  141. package/include/opencv2/core/utils/tls.hpp +235 -0
  142. package/include/opencv2/core/utils/trace.hpp +252 -0
  143. package/include/opencv2/core/utils/trace.private.hpp +421 -0
  144. package/include/opencv2/core/va_intel.hpp +75 -0
  145. package/include/opencv2/core/version.hpp +26 -0
  146. package/include/opencv2/core/vsx_utils.hpp +1047 -0
  147. package/include/opencv2/core.hpp +3365 -0
  148. package/include/opencv2/imgcodecs/imgcodecs.hpp +48 -0
  149. package/include/opencv2/imgcodecs/imgcodecs_c.h +1 -0
  150. package/include/opencv2/imgcodecs/ios.h +59 -0
  151. package/include/opencv2/imgcodecs/legacy/constants_c.h +54 -0
  152. package/include/opencv2/imgcodecs/macosx.h +20 -0
  153. package/include/opencv2/imgcodecs.hpp +407 -0
  154. package/include/opencv2/imgproc/bindings.hpp +34 -0
  155. package/include/opencv2/imgproc/detail/gcgraph.hpp +395 -0
  156. package/include/opencv2/imgproc/hal/hal.hpp +246 -0
  157. package/include/opencv2/imgproc/hal/interface.h +46 -0
  158. package/include/opencv2/imgproc/imgproc.hpp +48 -0
  159. package/include/opencv2/imgproc/imgproc_c.h +1177 -0
  160. package/include/opencv2/imgproc/segmentation.hpp +141 -0
  161. package/include/opencv2/imgproc/types_c.h +659 -0
  162. package/include/opencv2/imgproc.hpp +5035 -0
  163. package/include/opencv2/opencv_modules.hpp +17 -0
  164. package/libs/libjpeg-turbo.lib +0 -0
  165. package/libs/libpng.lib +0 -0
  166. package/libs/opencv_core470.lib +0 -0
  167. package/libs/opencv_imgcodecs470.lib +0 -0
  168. package/libs/opencv_imgproc470.lib +0 -0
  169. package/libs/zlib.lib +0 -0
  170. package/package.json +14 -3
  171. package/prebuilds/win32-x64/node.napi.node +0 -0
  172. package/src/cpp/capturewindow.cpp +36 -46
  173. package/src/cpp/main.cpp +10 -2
  174. package/src/cpp/opencv.cpp +425 -0
@@ -0,0 +1,487 @@
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
+ //
6
+ // License Agreement
7
+ // For Open Source Computer Vision Library
8
+ //
9
+ // Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
10
+ // Third party copyrights are property of their respective owners.
11
+ //
12
+ // Licensed under the Apache License, Version 2.0 (the "License");
13
+ // you may not use this file except in compliance with the License.
14
+ // You may obtain a copy of the License at
15
+ //
16
+ // http://www.apache.org/licenses/LICENSE-2.0
17
+ //
18
+ // Unless required by applicable law or agreed to in writing, software
19
+ // distributed under the License is distributed on an "AS IS" BASIS,
20
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ // See the License for the specific language governing permissions and
22
+ // limitations under the License.
23
+ //
24
+ // Author: Liangqian Kong <kongliangqian@huawei.com>
25
+ // Longbu Wang <wanglongbu@huawei.com>
26
+
27
+ #ifndef OPENCV_CORE_DUALQUATERNION_INL_HPP
28
+ #define OPENCV_CORE_DUALQUATERNION_INL_HPP
29
+
30
+ #ifndef OPENCV_CORE_DUALQUATERNION_HPP
31
+ #error This is not a standalone header. Include dualquaternion.hpp instead.
32
+ #endif
33
+
34
+ ///////////////////////////////////////////////////////////////////////////////////////
35
+ //Implementation
36
+ namespace cv {
37
+
38
+ template <typename T>
39
+ DualQuat<T>::DualQuat():w(0), x(0), y(0), z(0), w_(0), x_(0), y_(0), z_(0){};
40
+
41
+ template <typename T>
42
+ DualQuat<T>::DualQuat(const T vw, const T vx, const T vy, const T vz, const T _w, const T _x, const T _y, const T _z):
43
+ w(vw), x(vx), y(vy), z(vz), w_(_w), x_(_x), y_(_y), z_(_z){};
44
+
45
+ template <typename T>
46
+ DualQuat<T>::DualQuat(const Vec<T, 8> &q):w(q[0]), x(q[1]), y(q[2]), z(q[3]),
47
+ w_(q[4]), x_(q[5]), y_(q[6]), z_(q[7]){};
48
+
49
+ template <typename T>
50
+ DualQuat<T> DualQuat<T>::createFromQuat(const Quat<T> &realPart, const Quat<T> &dualPart)
51
+ {
52
+ T w = realPart.w;
53
+ T x = realPart.x;
54
+ T y = realPart.y;
55
+ T z = realPart.z;
56
+ T w_ = dualPart.w;
57
+ T x_ = dualPart.x;
58
+ T y_ = dualPart.y;
59
+ T z_ = dualPart.z;
60
+ return DualQuat<T>(w, x, y, z, w_, x_, y_, z_);
61
+ }
62
+
63
+ template <typename T>
64
+ DualQuat<T> DualQuat<T>::createFromAngleAxisTrans(const T angle, const Vec<T, 3> &axis, const Vec<T, 3> &trans)
65
+ {
66
+ Quat<T> r = Quat<T>::createFromAngleAxis(angle, axis);
67
+ Quat<T> t{0, trans[0], trans[1], trans[2]};
68
+ return createFromQuat(r, t * r * T(0.5));
69
+ }
70
+
71
+ template <typename T>
72
+ DualQuat<T> DualQuat<T>::createFromMat(InputArray _R)
73
+ {
74
+ CV_CheckTypeEQ(_R.type(), cv::traits::Type<T>::value, "");
75
+ if (_R.size() != Size(4, 4))
76
+ {
77
+ CV_Error(Error::StsBadArg, "The input matrix must have 4 columns and 4 rows");
78
+ }
79
+ Mat R = _R.getMat();
80
+ Quat<T> r = Quat<T>::createFromRotMat(R.colRange(0, 3).rowRange(0, 3));
81
+ Quat<T> trans(0, R.at<T>(0, 3), R.at<T>(1, 3), R.at<T>(2, 3));
82
+ return createFromQuat(r, trans * r * T(0.5));
83
+ }
84
+
85
+ template <typename T>
86
+ DualQuat<T> DualQuat<T>::createFromAffine3(const Affine3<T> &R)
87
+ {
88
+ return createFromMat(R.matrix);
89
+ }
90
+
91
+ template <typename T>
92
+ DualQuat<T> DualQuat<T>::createFromPitch(const T angle, const T d, const Vec<T, 3> &axis, const Vec<T, 3> &moment)
93
+ {
94
+ T half_angle = angle * T(0.5), half_d = d * T(0.5);
95
+ Quat<T> qaxis = Quat<T>(0, axis[0], axis[1], axis[2]).normalize();
96
+ Quat<T> qmoment = Quat<T>(0, moment[0], moment[1], moment[2]);
97
+ qmoment -= qaxis * axis.dot(moment);
98
+ Quat<T> dual = -half_d * std::sin(half_angle) + std::sin(half_angle) * qmoment +
99
+ half_d * std::cos(half_angle) * qaxis;
100
+ return createFromQuat(Quat<T>::createFromAngleAxis(angle, axis), dual);
101
+ }
102
+
103
+ template <typename T>
104
+ inline bool DualQuat<T>::operator==(const DualQuat<T> &q) const
105
+ {
106
+ return (abs(w - q.w) < CV_DUAL_QUAT_EPS && abs(x - q.x) < CV_DUAL_QUAT_EPS &&
107
+ abs(y - q.y) < CV_DUAL_QUAT_EPS && abs(z - q.z) < CV_DUAL_QUAT_EPS &&
108
+ abs(w_ - q.w_) < CV_DUAL_QUAT_EPS && abs(x_ - q.x_) < CV_DUAL_QUAT_EPS &&
109
+ abs(y_ - q.y_) < CV_DUAL_QUAT_EPS && abs(z_ - q.z_) < CV_DUAL_QUAT_EPS);
110
+ }
111
+
112
+ template <typename T>
113
+ inline Quat<T> DualQuat<T>::getRealPart() const
114
+ {
115
+ return Quat<T>(w, x, y, z);
116
+ }
117
+
118
+ template <typename T>
119
+ inline Quat<T> DualQuat<T>::getDualPart() const
120
+ {
121
+ return Quat<T>(w_, x_, y_, z_);
122
+ }
123
+
124
+ template <typename T>
125
+ inline DualQuat<T> conjugate(const DualQuat<T> &dq)
126
+ {
127
+ return dq.conjugate();
128
+ }
129
+
130
+ template <typename T>
131
+ inline DualQuat<T> DualQuat<T>::conjugate() const
132
+ {
133
+ return DualQuat<T>(w, -x, -y, -z, w_, -x_, -y_, -z_);
134
+ }
135
+
136
+ template <typename T>
137
+ DualQuat<T> DualQuat<T>::norm() const
138
+ {
139
+ Quat<T> real = getRealPart();
140
+ T realNorm = real.norm();
141
+ Quat<T> dual = getDualPart();
142
+ if (realNorm < CV_DUAL_QUAT_EPS){
143
+ return DualQuat<T>(0, 0, 0, 0, 0, 0, 0, 0);
144
+ }
145
+ return DualQuat<T>(realNorm, 0, 0, 0, real.dot(dual) / realNorm, 0, 0, 0);
146
+ }
147
+
148
+ template <typename T>
149
+ inline Quat<T> DualQuat<T>::getRotation(QuatAssumeType assumeUnit) const
150
+ {
151
+ if (assumeUnit)
152
+ {
153
+ return getRealPart();
154
+ }
155
+ return getRealPart().normalize();
156
+ }
157
+
158
+ template <typename T>
159
+ inline Vec<T, 3> DualQuat<T>::getTranslation(QuatAssumeType assumeUnit) const
160
+ {
161
+ Quat<T> trans = T(2.0) * (getDualPart() * getRealPart().inv(assumeUnit));
162
+ return Vec<T, 3>{trans[1], trans[2], trans[3]};
163
+ }
164
+
165
+ template <typename T>
166
+ DualQuat<T> DualQuat<T>::normalize() const
167
+ {
168
+ Quat<T> p = getRealPart();
169
+ Quat<T> q = getDualPart();
170
+ T p_norm = p.norm();
171
+ if (p_norm < CV_DUAL_QUAT_EPS)
172
+ {
173
+ CV_Error(Error::StsBadArg, "Cannot normalize this dual quaternion: the norm is too small.");
174
+ }
175
+ Quat<T> p_nr = p / p_norm;
176
+ Quat<T> q_nr = q / p_norm;
177
+ return createFromQuat(p_nr, q_nr - p_nr * p_nr.dot(q_nr));
178
+ }
179
+
180
+ template <typename T>
181
+ inline T DualQuat<T>::dot(DualQuat<T> q) const
182
+ {
183
+ return q.w * w + q.x * x + q.y * y + q.z * z + q.w_ * w_ + q.x_ * x_ + q.y_ * y_ + q.z_ * z_;
184
+ }
185
+
186
+ template <typename T>
187
+ inline DualQuat<T> inv(const DualQuat<T> &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
188
+ {
189
+ return dq.inv(assumeUnit);
190
+ }
191
+
192
+ template <typename T>
193
+ inline DualQuat<T> DualQuat<T>::inv(QuatAssumeType assumeUnit) const
194
+ {
195
+ Quat<T> real = getRealPart();
196
+ Quat<T> dual = getDualPart();
197
+ return createFromQuat(real.inv(assumeUnit), -real.inv(assumeUnit) * dual * real.inv(assumeUnit));
198
+ }
199
+
200
+ template <typename T>
201
+ inline DualQuat<T> DualQuat<T>::operator-(const DualQuat<T> &q) const
202
+ {
203
+ return DualQuat<T>(w - q.w, x - q.x, y - q.y, z - q.z, w_ - q.w_, x_ - q.x_, y_ - q.y_, z_ - q.z_);
204
+ }
205
+
206
+ template <typename T>
207
+ inline DualQuat<T> DualQuat<T>::operator-() const
208
+ {
209
+ return DualQuat<T>(-w, -x, -y, -z, -w_, -x_, -y_, -z_);
210
+ }
211
+
212
+ template <typename T>
213
+ inline DualQuat<T> DualQuat<T>::operator+(const DualQuat<T> &q) const
214
+ {
215
+ return DualQuat<T>(w + q.w, x + q.x, y + q.y, z + q.z, w_ + q.w_, x_ + q.x_, y_ + q.y_, z_ + q.z_);
216
+ }
217
+
218
+ template <typename T>
219
+ inline DualQuat<T>& DualQuat<T>::operator+=(const DualQuat<T> &q)
220
+ {
221
+ *this = *this + q;
222
+ return *this;
223
+ }
224
+
225
+ template <typename T>
226
+ inline DualQuat<T> DualQuat<T>::operator*(const DualQuat<T> &q) const
227
+ {
228
+ Quat<T> A = getRealPart();
229
+ Quat<T> B = getDualPart();
230
+ Quat<T> C = q.getRealPart();
231
+ Quat<T> D = q.getDualPart();
232
+ return DualQuat<T>::createFromQuat(A * C, A * D + B * C);
233
+ }
234
+
235
+ template <typename T>
236
+ inline DualQuat<T>& DualQuat<T>::operator*=(const DualQuat<T> &q)
237
+ {
238
+ *this = *this * q;
239
+ return *this;
240
+ }
241
+
242
+ template <typename T>
243
+ inline DualQuat<T> operator+(const T a, const DualQuat<T> &q)
244
+ {
245
+ return DualQuat<T>(a + q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_);
246
+ }
247
+
248
+ template <typename T>
249
+ inline DualQuat<T> operator+(const DualQuat<T> &q, const T a)
250
+ {
251
+ return DualQuat<T>(a + q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_);
252
+ }
253
+
254
+ template <typename T>
255
+ inline DualQuat<T> operator-(const DualQuat<T> &q, const T a)
256
+ {
257
+ return DualQuat<T>(q.w - a, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_);
258
+ }
259
+
260
+ template <typename T>
261
+ inline DualQuat<T>& DualQuat<T>::operator-=(const DualQuat<T> &q)
262
+ {
263
+ *this = *this - q;
264
+ return *this;
265
+ }
266
+
267
+ template <typename T>
268
+ inline DualQuat<T> operator-(const T a, const DualQuat<T> &q)
269
+ {
270
+ return DualQuat<T>(a - q.w, -q.x, -q.y, -q.z, -q.w_, -q.x_, -q.y_, -q.z_);
271
+ }
272
+
273
+ template <typename T>
274
+ inline DualQuat<T> operator*(const T a, const DualQuat<T> &q)
275
+ {
276
+ return DualQuat<T>(q.w * a, q.x * a, q.y * a, q.z * a, q.w_ * a, q.x_ * a, q.y_ * a, q.z_ * a);
277
+ }
278
+
279
+ template <typename T>
280
+ inline DualQuat<T> operator*(const DualQuat<T> &q, const T a)
281
+ {
282
+ return DualQuat<T>(q.w * a, q.x * a, q.y * a, q.z * a, q.w_ * a, q.x_ * a, q.y_ * a, q.z_ * a);
283
+ }
284
+
285
+ template <typename T>
286
+ inline DualQuat<T> DualQuat<T>::operator/(const T a) const
287
+ {
288
+ return DualQuat<T>(w / a, x / a, y / a, z / a, w_ / a, x_ / a, y_ / a, z_ / a);
289
+ }
290
+
291
+ template <typename T>
292
+ inline DualQuat<T> DualQuat<T>::operator/(const DualQuat<T> &q) const
293
+ {
294
+ return *this * q.inv();
295
+ }
296
+
297
+ template <typename T>
298
+ inline DualQuat<T>& DualQuat<T>::operator/=(const DualQuat<T> &q)
299
+ {
300
+ *this = *this / q;
301
+ return *this;
302
+ }
303
+
304
+ template <typename T>
305
+ std::ostream & operator<<(std::ostream &os, const DualQuat<T> &q)
306
+ {
307
+ os << "DualQuat " << Vec<T, 8>{q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_};
308
+ return os;
309
+ }
310
+
311
+ template <typename T>
312
+ inline DualQuat<T> exp(const DualQuat<T> &dq)
313
+ {
314
+ return dq.exp();
315
+ }
316
+
317
+ namespace detail {
318
+
319
+ template <typename _Tp>
320
+ Matx<_Tp, 4, 4> jacob_exp(const Quat<_Tp> &q)
321
+ {
322
+ _Tp nv = std::sqrt(q.x * q.x + q.y * q.y + q.z * q.z);
323
+ _Tp sinc_nv = abs(nv) < cv::DualQuat<_Tp>::CV_DUAL_QUAT_EPS ? _Tp(1.0) - nv * nv * _Tp(1.0/6.0) : std::sin(nv) / nv;
324
+ _Tp csiii_nv = abs(nv) < cv::DualQuat<_Tp>::CV_DUAL_QUAT_EPS ? -_Tp(1.0/3.0) : (std::cos(nv) - sinc_nv) / nv / nv;
325
+ Matx<_Tp, 4, 4> J_exp_quat {
326
+ std::cos(nv), -sinc_nv * q.x, -sinc_nv * q.y, -sinc_nv * q.z,
327
+ sinc_nv * q.x, csiii_nv * q.x * q.x + sinc_nv, csiii_nv * q.x * q.y, csiii_nv * q.x * q.z,
328
+ sinc_nv * q.y, csiii_nv * q.y * q.x, csiii_nv * q.y * q.y + sinc_nv, csiii_nv * q.y * q.z,
329
+ sinc_nv * q.z, csiii_nv * q.z * q.x, csiii_nv * q.z * q.y, csiii_nv * q.z * q.z + sinc_nv
330
+ };
331
+ return std::exp(q.w) * J_exp_quat;
332
+ }
333
+
334
+ } // namespace detail
335
+
336
+ template <typename T>
337
+ DualQuat<T> DualQuat<T>::exp() const
338
+ {
339
+ Quat<T> real = getRealPart();
340
+ return createFromQuat(real.exp(), Quat<T>(detail::jacob_exp(real) * getDualPart().toVec()));
341
+ }
342
+
343
+ template <typename T>
344
+ DualQuat<T> log(const DualQuat<T> &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
345
+ {
346
+ return dq.log(assumeUnit);
347
+ }
348
+
349
+ template <typename T>
350
+ DualQuat<T> DualQuat<T>::log(QuatAssumeType assumeUnit) const
351
+ {
352
+ Quat<T> plog = getRealPart().log(assumeUnit);
353
+ Matx<T, 4, 4> jacob = detail::jacob_exp(plog);
354
+ return createFromQuat(plog, Quat<T>(jacob.inv() * getDualPart().toVec()));
355
+ }
356
+
357
+ template <typename T>
358
+ inline DualQuat<T> power(const DualQuat<T> &dq, const T t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
359
+ {
360
+ return dq.power(t, assumeUnit);
361
+ }
362
+
363
+ template <typename T>
364
+ inline DualQuat<T> DualQuat<T>::power(const T t, QuatAssumeType assumeUnit) const
365
+ {
366
+ return (t * log(assumeUnit)).exp();
367
+ }
368
+
369
+ template <typename T>
370
+ inline DualQuat<T> power(const DualQuat<T> &p, const DualQuat<T> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
371
+ {
372
+ return p.power(q, assumeUnit);
373
+ }
374
+
375
+ template <typename T>
376
+ inline DualQuat<T> DualQuat<T>::power(const DualQuat<T> &q, QuatAssumeType assumeUnit) const
377
+ {
378
+ return (q * log(assumeUnit)).exp();
379
+ }
380
+
381
+ template <typename T>
382
+ inline Vec<T, 8> DualQuat<T>::toVec() const
383
+ {
384
+ return Vec<T, 8>(w, x, y, z, w_, x_, y_, z_);
385
+ }
386
+
387
+ template <typename T>
388
+ Affine3<T> DualQuat<T>::toAffine3(QuatAssumeType assumeUnit) const
389
+ {
390
+ return Affine3<T>(toMat(assumeUnit));
391
+ }
392
+
393
+ template <typename T>
394
+ Matx<T, 4, 4> DualQuat<T>::toMat(QuatAssumeType assumeUnit) const
395
+ {
396
+ Matx<T, 4, 4> rot44 = getRotation(assumeUnit).toRotMat4x4();
397
+ Vec<T, 3> translation = getTranslation(assumeUnit);
398
+ rot44(0, 3) = translation[0];
399
+ rot44(1, 3) = translation[1];
400
+ rot44(2, 3) = translation[2];
401
+ return rot44;
402
+ }
403
+
404
+ template <typename T>
405
+ DualQuat<T> DualQuat<T>::sclerp(const DualQuat<T> &q0, const DualQuat<T> &q1, const T t, bool directChange, QuatAssumeType assumeUnit)
406
+ {
407
+ DualQuat<T> v0(q0), v1(q1);
408
+ if (!assumeUnit)
409
+ {
410
+ v0 = v0.normalize();
411
+ v1 = v1.normalize();
412
+ }
413
+ Quat<T> v0Real = v0.getRealPart();
414
+ Quat<T> v1Real = v1.getRealPart();
415
+ if (directChange && v1Real.dot(v0Real) < 0)
416
+ {
417
+ v0 = -v0;
418
+ }
419
+ DualQuat<T> v0inv1 = v0.inv() * v1;
420
+ return v0 * v0inv1.power(t, QUAT_ASSUME_UNIT);
421
+ }
422
+
423
+ template <typename T>
424
+ DualQuat<T> DualQuat<T>::dqblend(const DualQuat<T> &q1, const DualQuat<T> &q2, const T t, QuatAssumeType assumeUnit)
425
+ {
426
+ DualQuat<T> v1(q1), v2(q2);
427
+ if (!assumeUnit)
428
+ {
429
+ v1 = v1.normalize();
430
+ v2 = v2.normalize();
431
+ }
432
+ if (v1.getRotation(assumeUnit).dot(v2.getRotation(assumeUnit)) < 0)
433
+ {
434
+ return ((1 - t) * v1 - t * v2).normalize();
435
+ }
436
+ return ((1 - t) * v1 + t * v2).normalize();
437
+ }
438
+
439
+ template <typename T>
440
+ DualQuat<T> DualQuat<T>::gdqblend(InputArray _dualquat, InputArray _weight, QuatAssumeType assumeUnit)
441
+ {
442
+ CV_CheckTypeEQ(_weight.type(), cv::traits::Type<T>::value, "");
443
+ CV_CheckTypeEQ(_dualquat.type(), CV_MAKETYPE(CV_MAT_DEPTH(cv::traits::Type<T>::value), 8), "");
444
+ Size dq_s = _dualquat.size();
445
+ if (dq_s != _weight.size() || (dq_s.height != 1 && dq_s.width != 1))
446
+ {
447
+ CV_Error(Error::StsBadArg, "The size of weight must be the same as dualquat, both of them should be (1, n) or (n, 1)");
448
+ }
449
+ Mat dualquat = _dualquat.getMat(), weight = _weight.getMat();
450
+ const int cn = std::max(dq_s.width, dq_s.height);
451
+ if (!assumeUnit)
452
+ {
453
+ for (int i = 0; i < cn; ++i)
454
+ {
455
+ dualquat.at<Vec<T, 8>>(i) = DualQuat<T>{dualquat.at<Vec<T, 8>>(i)}.normalize().toVec();
456
+ }
457
+ }
458
+ Vec<T, 8> dq_blend = dualquat.at<Vec<T, 8>>(0) * weight.at<T>(0);
459
+ Quat<T> q0 = DualQuat<T> {dualquat.at<Vec<T, 8>>(0)}.getRotation(assumeUnit);
460
+ for (int i = 1; i < cn; ++i)
461
+ {
462
+ T k = q0.dot(DualQuat<T>{dualquat.at<Vec<T, 8>>(i)}.getRotation(assumeUnit)) < 0 ? -1: 1;
463
+ dq_blend = dq_blend + dualquat.at<Vec<T, 8>>(i) * k * weight.at<T>(i);
464
+ }
465
+ return DualQuat<T>{dq_blend}.normalize();
466
+ }
467
+
468
+ template <typename T>
469
+ template <int cn>
470
+ DualQuat<T> DualQuat<T>::gdqblend(const Vec<DualQuat<T>, cn> &_dualquat, InputArray _weight, QuatAssumeType assumeUnit)
471
+ {
472
+ Vec<DualQuat<T>, cn> dualquat(_dualquat);
473
+ if (cn == 0)
474
+ {
475
+ return DualQuat<T>(1, 0, 0, 0, 0, 0, 0, 0);
476
+ }
477
+ Mat dualquat_mat(cn, 1, CV_64FC(8));
478
+ for (int i = 0; i < cn ; ++i)
479
+ {
480
+ dualquat_mat.at<Vec<T, 8>>(i) = dualquat[i].toVec();
481
+ }
482
+ return gdqblend(dualquat_mat, _weight, assumeUnit);
483
+ }
484
+
485
+ } //namespace cv
486
+
487
+ #endif /*OPENCV_CORE_DUALQUATERNION_INL_HPP*/