node-native-win-utils 2.1.2 → 2.1.4
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 +0 -7
- package/dist/index.cjs +15 -1
- package/dist/index.d.cts +39 -0
- package/dist/index.d.mts +39 -0
- package/dist/index.mjs +14 -0
- package/package.json +1 -1
- package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
- package/src/cpp/opencv.cpp +2 -2
- package/src/index.mts +40 -0
package/README.md
CHANGED
|
@@ -24,13 +24,6 @@ I did it for myself because I didn't feel like dealing with libraries like 'node
|
|
|
24
24
|
This package is a native addon for Node.js that allows you to perform various utility operations on Windows systems. It includes key event listeners, window data retrieval, window screenshot capture functionality, mouse movement, mouse click, mouse drag, and typing functionality, also I included precompiled libs of OpenCV(core, imgcodecs, imgproc)
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
# VESRION 1.3.3
|
|
29
|
-
|
|
30
|
-
Added a new function to simulate button press and release (`keyPress`), introduced an enumeration `KeyCodesHelper` with the most common key codes, and fixed a bug where the `typeString` function was not working with languages other than English.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
27
|
# Installation
|
|
35
28
|
|
|
36
29
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OpenCV = exports.KeyboardListener = exports.captureScreenAsync = exports.textRecognition = exports.KeyCodeHelper = exports.rawPressKey = exports.typeString = exports.mouseDrag = exports.mouseClick = exports.mouseMove = exports.captureWindowN = exports.getWindowData = void 0;
|
|
6
|
+
exports.OpenCV = exports.KeyboardListener = exports.captureScreenAsync = exports.textRecognition = exports.KeyCodeHelper = exports.rawPressKey = exports.typeString = exports.mouseDrag = exports.mouseClick = exports.mouseMove = exports.captureWindowN = exports.getWindowData = exports.TemplateMatchModes = void 0;
|
|
7
7
|
exports.captureWindow = captureWindow;
|
|
8
8
|
exports.keyPress = keyPress;
|
|
9
9
|
exports.captureScreenToFile = captureScreenToFile;
|
|
@@ -128,6 +128,18 @@ class KeyboardListener {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
exports.KeyboardListener = KeyboardListener;
|
|
131
|
+
var TemplateMatchModes;
|
|
132
|
+
(function (TemplateMatchModes) {
|
|
133
|
+
TemplateMatchModes[TemplateMatchModes["TM_SQDIFF"] = 0] = "TM_SQDIFF";
|
|
134
|
+
TemplateMatchModes[TemplateMatchModes["TM_SQDIFF_NORMED"] = 1] = "TM_SQDIFF_NORMED";
|
|
135
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCORR"] = 2] = "TM_CCORR";
|
|
136
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCORR_NORMED"] = 3] = "TM_CCORR_NORMED";
|
|
137
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCOEFF"] = 4] = "TM_CCOEFF";
|
|
138
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCOEFF_NORMED"] = 5] = "TM_CCOEFF_NORMED"; /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{
|
|
139
|
+
\sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2}
|
|
140
|
+
}\f] */
|
|
141
|
+
})(TemplateMatchModes || (exports.TemplateMatchModes = TemplateMatchModes = {}));
|
|
142
|
+
;
|
|
131
143
|
/**
|
|
132
144
|
* Represents the OpenCV class that provides image processing functionality.
|
|
133
145
|
*/
|
|
@@ -164,6 +176,8 @@ class OpenCV {
|
|
|
164
176
|
* @returns The result of the template matching operation.
|
|
165
177
|
*/
|
|
166
178
|
matchTemplate(template, method, mask) {
|
|
179
|
+
if (typeof method !== "number")
|
|
180
|
+
method = TemplateMatchModes.TM_CCOEFF_NORMED;
|
|
167
181
|
return matchTemplate(this.imageData, template, method, mask);
|
|
168
182
|
}
|
|
169
183
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -169,6 +169,45 @@ declare class KeyboardListener {
|
|
|
169
169
|
*/
|
|
170
170
|
static destroy(): void;
|
|
171
171
|
}
|
|
172
|
+
export declare enum TemplateMatchModes {
|
|
173
|
+
TM_SQDIFF = 0,/*!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
|
|
174
|
+
with mask:
|
|
175
|
+
\f[R(x,y)= \sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot
|
|
176
|
+
M(x',y') \right)^2\f] */
|
|
177
|
+
TM_SQDIFF_NORMED = 1,/*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{
|
|
178
|
+
x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
|
|
179
|
+
with mask:
|
|
180
|
+
\f[R(x,y)= \frac{\sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot
|
|
181
|
+
M(x',y') \right)^2}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot
|
|
182
|
+
M(x',y') \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot
|
|
183
|
+
M(x',y') \right)^2}}\f] */
|
|
184
|
+
TM_CCORR = 2,/*!< \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y'))\f]
|
|
185
|
+
with mask:
|
|
186
|
+
\f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot M(x',y')
|
|
187
|
+
^2)\f] */
|
|
188
|
+
TM_CCORR_NORMED = 3,/*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{
|
|
189
|
+
\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
|
|
190
|
+
with mask:
|
|
191
|
+
\f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot
|
|
192
|
+
M(x',y')^2)}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot M(x',y')
|
|
193
|
+
\right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot M(x',y')
|
|
194
|
+
\right)^2}}\f] */
|
|
195
|
+
TM_CCOEFF = 4,/*!< \f[R(x,y)= \sum _{x',y'} (T'(x',y') \cdot I'(x+x',y+y'))\f]
|
|
196
|
+
where
|
|
197
|
+
\f[\begin{array}{l} T'(x',y')=T(x',y') - 1/(w \cdot h) \cdot \sum _{
|
|
198
|
+
x'',y''} T(x'',y'') \\ I'(x+x',y+y')=I(x+x',y+y') - 1/(w \cdot h)
|
|
199
|
+
\cdot \sum _{x'',y''} I(x+x'',y+y'') \end{array}\f]
|
|
200
|
+
with mask:
|
|
201
|
+
\f[\begin{array}{l} T'(x',y')=M(x',y') \cdot \left( T(x',y') -
|
|
202
|
+
\frac{1}{\sum _{x'',y''} M(x'',y'')} \cdot \sum _{x'',y''}
|
|
203
|
+
(T(x'',y'') \cdot M(x'',y'')) \right) \\ I'(x+x',y+y')=M(x',y')
|
|
204
|
+
\cdot \left( I(x+x',y+y') - \frac{1}{\sum _{x'',y''} M(x'',y'')}
|
|
205
|
+
\cdot \sum _{x'',y''} (I(x+x'',y+y'') \cdot M(x'',y'')) \right)
|
|
206
|
+
\end{array} \f] */
|
|
207
|
+
TM_CCOEFF_NORMED = 5 /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{
|
|
208
|
+
\sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2}
|
|
209
|
+
}\f] */
|
|
210
|
+
}
|
|
172
211
|
/**
|
|
173
212
|
* Represents the OpenCV class that provides image processing functionality.
|
|
174
213
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -169,6 +169,45 @@ declare class KeyboardListener {
|
|
|
169
169
|
*/
|
|
170
170
|
static destroy(): void;
|
|
171
171
|
}
|
|
172
|
+
export declare enum TemplateMatchModes {
|
|
173
|
+
TM_SQDIFF = 0,/*!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
|
|
174
|
+
with mask:
|
|
175
|
+
\f[R(x,y)= \sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot
|
|
176
|
+
M(x',y') \right)^2\f] */
|
|
177
|
+
TM_SQDIFF_NORMED = 1,/*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{
|
|
178
|
+
x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
|
|
179
|
+
with mask:
|
|
180
|
+
\f[R(x,y)= \frac{\sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot
|
|
181
|
+
M(x',y') \right)^2}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot
|
|
182
|
+
M(x',y') \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot
|
|
183
|
+
M(x',y') \right)^2}}\f] */
|
|
184
|
+
TM_CCORR = 2,/*!< \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y'))\f]
|
|
185
|
+
with mask:
|
|
186
|
+
\f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot M(x',y')
|
|
187
|
+
^2)\f] */
|
|
188
|
+
TM_CCORR_NORMED = 3,/*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{
|
|
189
|
+
\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
|
|
190
|
+
with mask:
|
|
191
|
+
\f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot
|
|
192
|
+
M(x',y')^2)}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot M(x',y')
|
|
193
|
+
\right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot M(x',y')
|
|
194
|
+
\right)^2}}\f] */
|
|
195
|
+
TM_CCOEFF = 4,/*!< \f[R(x,y)= \sum _{x',y'} (T'(x',y') \cdot I'(x+x',y+y'))\f]
|
|
196
|
+
where
|
|
197
|
+
\f[\begin{array}{l} T'(x',y')=T(x',y') - 1/(w \cdot h) \cdot \sum _{
|
|
198
|
+
x'',y''} T(x'',y'') \\ I'(x+x',y+y')=I(x+x',y+y') - 1/(w \cdot h)
|
|
199
|
+
\cdot \sum _{x'',y''} I(x+x'',y+y'') \end{array}\f]
|
|
200
|
+
with mask:
|
|
201
|
+
\f[\begin{array}{l} T'(x',y')=M(x',y') \cdot \left( T(x',y') -
|
|
202
|
+
\frac{1}{\sum _{x'',y''} M(x'',y'')} \cdot \sum _{x'',y''}
|
|
203
|
+
(T(x'',y'') \cdot M(x'',y'')) \right) \\ I'(x+x',y+y')=M(x',y')
|
|
204
|
+
\cdot \left( I(x+x',y+y') - \frac{1}{\sum _{x'',y''} M(x'',y'')}
|
|
205
|
+
\cdot \sum _{x'',y''} (I(x+x'',y+y'') \cdot M(x'',y'')) \right)
|
|
206
|
+
\end{array} \f] */
|
|
207
|
+
TM_CCOEFF_NORMED = 5 /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{
|
|
208
|
+
\sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2}
|
|
209
|
+
}\f] */
|
|
210
|
+
}
|
|
172
211
|
/**
|
|
173
212
|
* Represents the OpenCV class that provides image processing functionality.
|
|
174
213
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -109,6 +109,18 @@ class KeyboardListener {
|
|
|
109
109
|
unsetKeyUpCallback();
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
export var TemplateMatchModes;
|
|
113
|
+
(function (TemplateMatchModes) {
|
|
114
|
+
TemplateMatchModes[TemplateMatchModes["TM_SQDIFF"] = 0] = "TM_SQDIFF";
|
|
115
|
+
TemplateMatchModes[TemplateMatchModes["TM_SQDIFF_NORMED"] = 1] = "TM_SQDIFF_NORMED";
|
|
116
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCORR"] = 2] = "TM_CCORR";
|
|
117
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCORR_NORMED"] = 3] = "TM_CCORR_NORMED";
|
|
118
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCOEFF"] = 4] = "TM_CCOEFF";
|
|
119
|
+
TemplateMatchModes[TemplateMatchModes["TM_CCOEFF_NORMED"] = 5] = "TM_CCOEFF_NORMED"; /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{
|
|
120
|
+
\sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2}
|
|
121
|
+
}\f] */
|
|
122
|
+
})(TemplateMatchModes || (TemplateMatchModes = {}));
|
|
123
|
+
;
|
|
112
124
|
/**
|
|
113
125
|
* Represents the OpenCV class that provides image processing functionality.
|
|
114
126
|
*/
|
|
@@ -145,6 +157,8 @@ class OpenCV {
|
|
|
145
157
|
* @returns The result of the template matching operation.
|
|
146
158
|
*/
|
|
147
159
|
matchTemplate(template, method, mask) {
|
|
160
|
+
if (typeof method !== "number")
|
|
161
|
+
method = TemplateMatchModes.TM_CCOEFF_NORMED;
|
|
148
162
|
return matchTemplate(this.imageData, template, method, mask);
|
|
149
163
|
}
|
|
150
164
|
/**
|
package/package.json
CHANGED
|
Binary file
|
package/src/cpp/opencv.cpp
CHANGED
|
@@ -158,11 +158,11 @@ Napi::Value MatchTemplate(const Napi::CallbackInfo &info)
|
|
|
158
158
|
cv::Mat result;
|
|
159
159
|
if (mask.empty())
|
|
160
160
|
{
|
|
161
|
-
cv::matchTemplate(src, templ, result,
|
|
161
|
+
cv::matchTemplate(src, templ, result, method);
|
|
162
162
|
}
|
|
163
163
|
else
|
|
164
164
|
{
|
|
165
|
-
cv::matchTemplate(src, templ, result,
|
|
165
|
+
cv::matchTemplate(src, templ, result, method, mask);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
double minVal, maxVal;
|
package/src/index.mts
CHANGED
|
@@ -326,6 +326,45 @@ class KeyboardListener {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
export enum TemplateMatchModes {
|
|
330
|
+
TM_SQDIFF = 0, /*!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
|
|
331
|
+
with mask:
|
|
332
|
+
\f[R(x,y)= \sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot
|
|
333
|
+
M(x',y') \right)^2\f] */
|
|
334
|
+
TM_SQDIFF_NORMED = 1, /*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{
|
|
335
|
+
x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
|
|
336
|
+
with mask:
|
|
337
|
+
\f[R(x,y)= \frac{\sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot
|
|
338
|
+
M(x',y') \right)^2}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot
|
|
339
|
+
M(x',y') \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot
|
|
340
|
+
M(x',y') \right)^2}}\f] */
|
|
341
|
+
TM_CCORR = 2, /*!< \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y'))\f]
|
|
342
|
+
with mask:
|
|
343
|
+
\f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot M(x',y')
|
|
344
|
+
^2)\f] */
|
|
345
|
+
TM_CCORR_NORMED = 3, /*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{
|
|
346
|
+
\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
|
|
347
|
+
with mask:
|
|
348
|
+
\f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot
|
|
349
|
+
M(x',y')^2)}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot M(x',y')
|
|
350
|
+
\right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot M(x',y')
|
|
351
|
+
\right)^2}}\f] */
|
|
352
|
+
TM_CCOEFF = 4, /*!< \f[R(x,y)= \sum _{x',y'} (T'(x',y') \cdot I'(x+x',y+y'))\f]
|
|
353
|
+
where
|
|
354
|
+
\f[\begin{array}{l} T'(x',y')=T(x',y') - 1/(w \cdot h) \cdot \sum _{
|
|
355
|
+
x'',y''} T(x'',y'') \\ I'(x+x',y+y')=I(x+x',y+y') - 1/(w \cdot h)
|
|
356
|
+
\cdot \sum _{x'',y''} I(x+x'',y+y'') \end{array}\f]
|
|
357
|
+
with mask:
|
|
358
|
+
\f[\begin{array}{l} T'(x',y')=M(x',y') \cdot \left( T(x',y') -
|
|
359
|
+
\frac{1}{\sum _{x'',y''} M(x'',y'')} \cdot \sum _{x'',y''}
|
|
360
|
+
(T(x'',y'') \cdot M(x'',y'')) \right) \\ I'(x+x',y+y')=M(x',y')
|
|
361
|
+
\cdot \left( I(x+x',y+y') - \frac{1}{\sum _{x'',y''} M(x'',y'')}
|
|
362
|
+
\cdot \sum _{x'',y''} (I(x+x'',y+y'') \cdot M(x'',y'')) \right)
|
|
363
|
+
\end{array} \f] */
|
|
364
|
+
TM_CCOEFF_NORMED = 5 /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{
|
|
365
|
+
\sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2}
|
|
366
|
+
}\f] */
|
|
367
|
+
};
|
|
329
368
|
|
|
330
369
|
/**
|
|
331
370
|
* Represents the OpenCV class that provides image processing functionality.
|
|
@@ -366,6 +405,7 @@ class OpenCV {
|
|
|
366
405
|
* @returns The result of the template matching operation.
|
|
367
406
|
*/
|
|
368
407
|
matchTemplate(template: ImageData, method?: number | null, mask?: ImageData) {
|
|
408
|
+
if(typeof method !== "number") method = TemplateMatchModes.TM_CCOEFF_NORMED;
|
|
369
409
|
return matchTemplate(this.imageData, template, method, mask);
|
|
370
410
|
}
|
|
371
411
|
|