node-native-win-utils 2.1.1 → 2.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  [![License][license-src]][license-href]
3
- ![Node-API v6 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v6%20Badge.svg)
3
+ ![Node-API v8 Badge](assets/Node-API%20v8%20Badge.svg)
4
4
 
5
5
  #### USDT TRC20 - TYAJ3K3MZraJhWimxxeCKcJ2SYABkVsrzi
6
6
  #### USDT TON - UQDokuYZXr4OHvfslDqUoFYcp1_F8tcjQPk_TvqSSDk7SIa7
package/dist/index.cjs CHANGED
@@ -17,7 +17,7 @@ const keyCodes_cjs_1 = require("./keyCodes.cjs");
17
17
  Object.defineProperty(exports, "KeyCodeHelper", { enumerable: true, get: function () { return keyCodes_cjs_1.KeyCodeHelper; } });
18
18
  const dirnameLocal_cjs_1 = require("./dirnameLocal.cjs");
19
19
  const bindings = nodeGypBuild(path_1.default.resolve(dirnameLocal_cjs_1.__dirnameLocal, ".."));
20
- const { setKeyDownCallback, setKeyUpCallback, unsetKeyDownCallback, unsetKeyUpCallback, getWindowData, captureWindowN, captureScreenAsync, mouseMove, mouseClick, mouseDrag, typeString, pressKey, imread, imwrite, matchTemplate, blur, bgrToGray, drawRectangle, getRegion, textRecognition } = bindings;
20
+ const { setKeyDownCallback, setKeyUpCallback, unsetKeyDownCallback, unsetKeyUpCallback, getWindowData, captureWindowN, captureScreenAsync, mouseMove, mouseClick, mouseDrag, typeString, pressKey, imread, imwrite, matchTemplate, blur, bgrToGray, drawRectangle, getRegion, textRecognition, equalizeHist } = bindings;
21
21
  exports.getWindowData = getWindowData;
22
22
  exports.captureWindowN = captureWindowN;
23
23
  exports.captureScreenAsync = captureScreenAsync;
@@ -182,6 +182,13 @@ class OpenCV {
182
182
  bgrToGray() {
183
183
  return new OpenCV(bgrToGray(this.imageData));
184
184
  }
185
+ /**
186
+ * Equalize the Histogram by using the OpenCV function cv::equalizeHist.
187
+ * @returns A new OpenCV instance with the equalized image data.
188
+ */
189
+ equalizeHist() {
190
+ return new OpenCV(equalizeHist(this.imageData));
191
+ }
185
192
  /**
186
193
  * Draws a rectangle on the image.
187
194
  * @param start - The starting point of the rectangle.
package/dist/index.d.cts CHANGED
@@ -78,6 +78,7 @@ export type Imwrite = (image: ImageData) => Buffer;
78
78
  export type MatchTemplate = (image: ImageData, template: ImageData, method?: number | null, mask?: ImageData) => MatchData;
79
79
  export type Blur = (image: ImageData, sizeX: number, sizeY: number) => ImageData;
80
80
  export type BgrToGray = (image: ImageData) => ImageData;
81
+ export type EqualizeHist = (image: ImageData) => ImageData;
81
82
  export type DrawRectangle = (image: ImageData, start: Point, end: Point, rgb: Color, thickness: number) => ImageData;
82
83
  export type GetRegion = (image: ImageData, region: ROI) => ImageData;
83
84
  export type TextRecognition = (trainedDataPath: string, dataLang: string, imagePath: string) => string;
@@ -205,6 +206,11 @@ declare class OpenCV {
205
206
  * @returns A new OpenCV instance with the grayscale image data.
206
207
  */
207
208
  bgrToGray(): OpenCV;
209
+ /**
210
+ * Equalize the Histogram by using the OpenCV function cv::equalizeHist.
211
+ * @returns A new OpenCV instance with the equalized image data.
212
+ */
213
+ equalizeHist(): OpenCV;
208
214
  /**
209
215
  * Draws a rectangle on the image.
210
216
  * @param start - The starting point of the rectangle.
package/dist/index.d.mts CHANGED
@@ -78,6 +78,7 @@ export type Imwrite = (image: ImageData) => Buffer;
78
78
  export type MatchTemplate = (image: ImageData, template: ImageData, method?: number | null, mask?: ImageData) => MatchData;
79
79
  export type Blur = (image: ImageData, sizeX: number, sizeY: number) => ImageData;
80
80
  export type BgrToGray = (image: ImageData) => ImageData;
81
+ export type EqualizeHist = (image: ImageData) => ImageData;
81
82
  export type DrawRectangle = (image: ImageData, start: Point, end: Point, rgb: Color, thickness: number) => ImageData;
82
83
  export type GetRegion = (image: ImageData, region: ROI) => ImageData;
83
84
  export type TextRecognition = (trainedDataPath: string, dataLang: string, imagePath: string) => string;
@@ -205,6 +206,11 @@ declare class OpenCV {
205
206
  * @returns A new OpenCV instance with the grayscale image data.
206
207
  */
207
208
  bgrToGray(): OpenCV;
209
+ /**
210
+ * Equalize the Histogram by using the OpenCV function cv::equalizeHist.
211
+ * @returns A new OpenCV instance with the equalized image data.
212
+ */
213
+ equalizeHist(): OpenCV;
208
214
  /**
209
215
  * Draws a rectangle on the image.
210
216
  * @param start - The starting point of the rectangle.
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ const nodeGypBuild = __require("node-gyp-build");
8
8
  import { keyCodes, KeyCodeHelper } from "./keyCodes.mjs";
9
9
  import { __dirnameLocal } from "./dirnameLocal.mjs";
10
10
  const bindings = nodeGypBuild(path.resolve(__dirnameLocal, ".."));
11
- const { setKeyDownCallback, setKeyUpCallback, unsetKeyDownCallback, unsetKeyUpCallback, getWindowData, captureWindowN, captureScreenAsync, mouseMove, mouseClick, mouseDrag, typeString, pressKey, imread, imwrite, matchTemplate, blur, bgrToGray, drawRectangle, getRegion, textRecognition } = bindings;
11
+ const { setKeyDownCallback, setKeyUpCallback, unsetKeyDownCallback, unsetKeyUpCallback, getWindowData, captureWindowN, captureScreenAsync, mouseMove, mouseClick, mouseDrag, typeString, pressKey, imread, imwrite, matchTemplate, blur, bgrToGray, drawRectangle, getRegion, textRecognition, equalizeHist } = bindings;
12
12
  const rawPressKey = pressKey;
13
13
  /**
14
14
  * Captures a window and saves it to a file.
@@ -163,6 +163,13 @@ class OpenCV {
163
163
  bgrToGray() {
164
164
  return new OpenCV(bgrToGray(this.imageData));
165
165
  }
166
+ /**
167
+ * Equalize the Histogram by using the OpenCV function cv::equalizeHist.
168
+ * @returns A new OpenCV instance with the equalized image data.
169
+ */
170
+ equalizeHist() {
171
+ return new OpenCV(equalizeHist(this.imageData));
172
+ }
166
173
  /**
167
174
  * Draws a rectangle on the image.
168
175
  * @param start - The starting point of the rectangle.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-native-win-utils",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "author": "Andrew K.",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/T-Rumibul/node-native-win-utils.git",
package/src/cpp/main.cpp CHANGED
@@ -26,6 +26,7 @@ Napi::Object Init(Napi::Env env, Napi::Object exports)
26
26
  exports.Set("matchTemplate", Napi::Function::New(env, MatchTemplate));
27
27
  exports.Set("blur", Napi::Function::New(env, Blur));
28
28
  exports.Set("bgrToGray", Napi::Function::New(env, BgrToGray));
29
+ exports.Set("equalizeHist", Napi::Function::New(env, EqualizeHist));
29
30
  exports.Set("drawRectangle", Napi::Function::New(env, DrawRectangle));
30
31
  exports.Set("getRegion", Napi::Function::New(env, GetRegion));
31
32
  exports.Set("textRecognition", Napi::Function::New(env, TextRecognition));
@@ -234,6 +234,52 @@ Napi::Value BgrToGray(const Napi::CallbackInfo &info)
234
234
  return result;
235
235
  }
236
236
 
237
+ Napi::Value EqualizeHist(const Napi::CallbackInfo &info)
238
+ {
239
+ Napi::Env env = info.Env();
240
+
241
+ if (info.Length() < 1 || !info[0].IsObject())
242
+ {
243
+ Napi::TypeError::New(env, "Invalid arguments. Expected: (object)").ThrowAsJavaScriptException();
244
+ return env.Null();
245
+ }
246
+
247
+ Napi::Object srcObj = info[0].As<Napi::Object>();
248
+
249
+ if (!srcObj.Has("data") || !srcObj.Has("width") || !srcObj.Has("height"))
250
+ {
251
+ Napi::TypeError::New(env, "Invalid image data object. Expected properties: 'data', 'width', 'height'").ThrowAsJavaScriptException();
252
+ return env.Null();
253
+ }
254
+
255
+ if (!srcObj.Get("data").IsTypedArray())
256
+ {
257
+ Napi::TypeError::New(env, "TypedArray expected for 'data' property").ThrowAsJavaScriptException();
258
+ return env.Null();
259
+ }
260
+
261
+ int width = srcObj.Get("width").ToNumber().Int32Value();
262
+ int height = srcObj.Get("height").ToNumber().Int32Value();
263
+
264
+ cv::Mat src(height, width, CV_8UC1, srcObj.Get("data").As<Napi::TypedArray>().ArrayBuffer().Data());
265
+ cv::Mat dst;
266
+
267
+ cv::equalizeHist(src, dst);
268
+
269
+ Napi::Object result = Napi::Object::New(env);
270
+ size_t totalBytes = dst.total() * dst.elemSize();
271
+ Napi::ArrayBuffer arrayBuffer = Napi::ArrayBuffer::New(env, totalBytes);
272
+ Napi::Uint8Array uint8Array = Napi::Uint8Array::New(env, totalBytes, arrayBuffer, 0);
273
+
274
+ memcpy(uint8Array.Data(), dst.data, totalBytes);
275
+ result.Set("width", width);
276
+ result.Set("height", height);
277
+ result.Set("data", uint8Array);
278
+
279
+ return result;
280
+ }
281
+
282
+
237
283
  Napi::Value Blur(const Napi::CallbackInfo &info)
238
284
  {
239
285
  Napi::Env env = info.Env();
package/src/index.mts CHANGED
@@ -120,7 +120,7 @@ export type Blur = (
120
120
  sizeY: number
121
121
  ) => ImageData;
122
122
  export type BgrToGray = (image: ImageData) => ImageData;
123
-
123
+ export type EqualizeHist = (image: ImageData) => ImageData;
124
124
  export type DrawRectangle = (
125
125
  image: ImageData,
126
126
  start: Point,
@@ -153,7 +153,8 @@ const {
153
153
  bgrToGray,
154
154
  drawRectangle,
155
155
  getRegion,
156
- textRecognition
156
+ textRecognition,
157
+ equalizeHist
157
158
  }: {
158
159
  setKeyDownCallback: SetKeyCallback;
159
160
  setKeyUpCallback: SetKeyCallback;
@@ -175,6 +176,7 @@ const {
175
176
  getRegion: GetRegion;
176
177
  textRecognition: TextRecognition;
177
178
  captureScreenAsync: CaptureScreenAsync;
179
+ equalizeHist: EqualizeHist
178
180
  } = bindings;
179
181
 
180
182
  const rawPressKey = pressKey;
@@ -385,6 +387,15 @@ class OpenCV {
385
387
  return new OpenCV(bgrToGray(this.imageData));
386
388
  }
387
389
 
390
+ /**
391
+ * Equalize the Histogram by using the OpenCV function cv::equalizeHist.
392
+ * @returns A new OpenCV instance with the equalized image data.
393
+ */
394
+ equalizeHist() {
395
+ return new OpenCV(equalizeHist(this.imageData));
396
+ }
397
+
398
+
388
399
  /**
389
400
  * Draws a rectangle on the image.
390
401
  * @param start - The starting point of the rectangle.