node-native-win-utils 1.3.1 → 1.3.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/package.json
CHANGED
|
Binary file
|
package/src/cpp/opencv.cpp
CHANGED
|
@@ -32,7 +32,7 @@ Napi::Value Imread(const Napi::CallbackInfo &info)
|
|
|
32
32
|
|
|
33
33
|
// Create a new Uint8Array with the correct size
|
|
34
34
|
|
|
35
|
-
size_t totalBytes = image.
|
|
35
|
+
size_t totalBytes = image.total() * image.elemSize();
|
|
36
36
|
Napi::ArrayBuffer arrayBuffer = Napi::ArrayBuffer::New(env, totalBytes);
|
|
37
37
|
Napi::Uint8Array uint8Array = Napi::Uint8Array::New(env, totalBytes, arrayBuffer, 0);
|
|
38
38
|
|
|
@@ -354,7 +354,7 @@ Napi::Value GetRegion(const Napi::CallbackInfo &info)
|
|
|
354
354
|
{
|
|
355
355
|
Napi::Env env = info.Env();
|
|
356
356
|
|
|
357
|
-
if (info.Length() < 2 || !info[0].IsObject()
|
|
357
|
+
if (info.Length() < 2 || !info[0].IsObject() || !info[1].IsObject())
|
|
358
358
|
{
|
|
359
359
|
Napi::TypeError::New(env, "Invalid arguments. Expected: (object)").ThrowAsJavaScriptException();
|
|
360
360
|
return env.Null();
|
|
@@ -391,7 +391,8 @@ Napi::Value GetRegion(const Napi::CallbackInfo &info)
|
|
|
391
391
|
cv::Mat image(imageHeight, imageWidth, CV_8UC3, imageObj.Get("data").As<Napi::TypedArray>().ArrayBuffer().Data());
|
|
392
392
|
|
|
393
393
|
cv::Rect region(x, y, width, height);
|
|
394
|
-
cv::Mat regionImage = image(region);
|
|
394
|
+
cv::Mat regionImage = image(region).clone();
|
|
395
|
+
|
|
395
396
|
size_t totalBytes = regionImage.total() * regionImage.elemSize();
|
|
396
397
|
Napi::ArrayBuffer arrayBuffer = Napi::ArrayBuffer::New(env, totalBytes);
|
|
397
398
|
Napi::Uint8Array uint8Array = Napi::Uint8Array::New(env, totalBytes, arrayBuffer, 0);
|