@rosepetal/node-red-contrib-image-tools 1.5.4 → 1.6.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.
@@ -20,8 +20,10 @@
20
20
  debugWidth:{value:200},
21
21
  debugWidthType:{value:"num"},
22
22
  colormap:{value:"JET"},
23
- blurSize:{value:0},
24
- threshold:{value:0}
23
+ blurSize:{value:0}, blurSizeType:{value:"num"},
24
+ threshold:{value:0}, thresholdType:{value:"num"},
25
+ statsEnabled:{value:true},
26
+ statsPath:{value:"diffStats"}, statsPathType:{value:"msg"}
25
27
  },
26
28
  inputs:1,outputs:1,
27
29
  label:function(){return this.name||"rp-heat-diff";},
@@ -35,15 +37,24 @@
35
37
  $("#node-input-outputPath").typedInput({
36
38
  default:'msg',types:['msg','flow','global'],
37
39
  typeField:"#node-input-outputPathType"});
40
+ $("#node-input-statsPath").typedInput({
41
+ default:'msg',types:['msg','flow','global'],
42
+ typeField:"#node-input-statsPathType"});
38
43
 
39
- // Threshold slider
40
- var $thresholdSlider = $("#node-input-threshold");
41
- var $thresholdValue = $("#threshold-value");
42
- function updateThresholdDisplay() {
43
- $thresholdValue.text($thresholdSlider.val());
44
+ // Stats path only relevant when stats are enabled
45
+ var statsCheckbox = $('#node-input-statsEnabled');
46
+ function updateStatsPathVisibility(){
47
+ $("#stats-path-row").toggle(statsCheckbox.is(':checked'));
44
48
  }
45
- $thresholdSlider.on("input", updateThresholdDisplay);
46
- updateThresholdDisplay();
49
+ statsCheckbox.on('change', updateStatsPathVisibility);
50
+ updateStatsPathVisibility();
51
+
52
+ $("#node-input-blurSize").typedInput({
53
+ default:'num',types:['num','msg','flow','global'],
54
+ typeField:"#node-input-blurSizeType"});
55
+ $("#node-input-threshold").typedInput({
56
+ default:'num',types:['num','msg','flow','global'],
57
+ typeField:"#node-input-thresholdType"});
47
58
 
48
59
  // Output format visibility
49
60
  function updateQualityVisibility(){
@@ -109,6 +120,17 @@
109
120
  </select>
110
121
  </div>
111
122
 
123
+ <div class="form-row">
124
+ <label for="node-input-statsEnabled"><i class="fa fa-bar-chart"></i> Statistics</label>
125
+ <input type="checkbox" id="node-input-statsEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
126
+ <label for="node-input-statsEnabled" style="width:auto; margin-left:5px;">Compute diff statistics</label>
127
+ </div>
128
+ <div class="form-row" id="stats-path-row">
129
+ <label for="node-input-statsPath"><i class="fa fa-bar-chart"></i> Stats to</label>
130
+ <input type="text" id="node-input-statsPath" style="width:70%;">
131
+ <input type="hidden" id="node-input-statsPathType">
132
+ </div>
133
+
112
134
  <div class="form-row" id="quality-row">
113
135
  <label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
114
136
  <input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
@@ -169,17 +191,16 @@
169
191
 
170
192
  <div class="form-row">
171
193
  <label for="node-input-blurSize"><i class="fa fa-circle-o"></i> Blur</label>
172
- <input type="number" id="node-input-blurSize" min="0" max="99" value="0" style="width: 70px;">
194
+ <input type="text" id="node-input-blurSize" style="width: 160px;">
195
+ <input type="hidden" id="node-input-blurSizeType">
173
196
  <span style="margin-left: 10px; color: #666;">Gaussian blur kernel size (0 = off, odd values)</span>
174
197
  </div>
175
198
 
176
199
  <div class="form-row">
177
200
  <label for="node-input-threshold"><i class="fa fa-filter"></i> Threshold</label>
178
- <input type="range" id="node-input-threshold" min="0" max="255" value="0" style="width: 200px;">
179
- <span id="threshold-value" style="margin-left: 10px; font-weight: bold;">0</span>
180
- <div style="margin-top: 5px; font-size: 10px; color: #999;">
181
- Pixel differences below this value are suppressed (0 = show all)
182
- </div>
201
+ <input type="text" id="node-input-threshold" style="width: 160px;">
202
+ <input type="hidden" id="node-input-thresholdType">
203
+ <span style="margin-left: 10px; color: #666;">0-255; differences below this are suppressed (0 = show all)</span>
183
204
  </div>
184
205
  </script>
185
206
 
@@ -203,11 +224,17 @@
203
224
  <dt>Colormap <span class="property-type">string</span></dt>
204
225
  <dd>Color mapping applied to the difference: JET, HOT, INFERNO, TURBO, BONE, COOL, RAINBOW, OCEAN, PINK, HSV.</dd>
205
226
 
206
- <dt>Blur <span class="property-type">number</span></dt>
207
- <dd>Gaussian blur kernel size applied to the difference before colormapping. Smooths noise. 0 to disable.</dd>
227
+ <dt>Blur <span class="property-type">number | msg | flow | global</span></dt>
228
+ <dd>Gaussian blur kernel size applied to the difference before colormapping. Smooths noise. 0 to disable. Can be a fixed number or resolved from a msg/flow/global property per message.</dd>
229
+
230
+ <dt>Threshold <span class="property-type">number | msg | flow | global</span></dt>
231
+ <dd>Pixel differences below this value (0-255) are set to zero before colormapping. Suppresses minor noise. Also defines which pixels count as "changed" for the statistics. Can be a fixed number or resolved from a msg/flow/global property per message.</dd>
232
+
233
+ <dt>Statistics <span class="property-type">boolean</span></dt>
234
+ <dd>When enabled (default), numeric diff statistics are computed.</dd>
208
235
 
209
- <dt>Threshold <span class="property-type">number</span></dt>
210
- <dd>Pixel differences below this value (0-255) are set to zero before colormapping. Suppresses minor noise.</dd>
236
+ <dt>Stats to <span class="property-type">string</span></dt>
237
+ <dd>Message property where the statistics object is stored. Default <code>msg.diffStats</code>.</dd>
211
238
  </dl>
212
239
 
213
240
  <h3>Inputs</h3>
@@ -215,4 +242,17 @@
215
242
 
216
243
  <h3>Outputs</h3>
217
244
  <p>A 3-channel BGR heat map image in the selected output format. If the inputs were arrays, the output is an array of heat maps in the same order.</p>
245
+ <p>When Statistics is enabled, the configured stats property (default <code>msg.diffStats</code>) holds an object (or array, matching the input shape) with:</p>
246
+ <dl class="message-properties">
247
+ <dt>validRatio <span class="property-type">number</span></dt>
248
+ <dd>Fraction of pixels used for statistics. Pixels that are pure black in either input (alignment borders, composite padding) are excluded from all stats.</dd>
249
+ <dt>changedRatio <span class="property-type">number</span></dt>
250
+ <dd>Fraction of valid pixels whose difference exceeds the threshold.</dd>
251
+ <dt>meanDiff / maxDiff / p50 / p95 / p99 <span class="property-type">number</span></dt>
252
+ <dd>Mean, maximum and percentiles of the difference values (0-255) over valid pixels.</dd>
253
+ <dt>rmse / psnr / ssim <span class="property-type">number</span></dt>
254
+ <dd>Root-mean-square error, peak signal-to-noise ratio (dB, 100 = identical) and structural similarity (0-1, 1 = identical).</dd>
255
+ <dt>blobCount / largestBlobArea / blobs <span class="property-type">number | array</span></dt>
256
+ <dd>Connected regions of changed pixels. <code>blobs</code> lists up to 50 regions, largest first, each with <code>x, y, w, h, area, cx, cy</code> in output-image coordinates.</dd>
257
+ </dl>
218
258
  </script>
@@ -132,11 +132,17 @@ module.exports = function (RED) {
132
132
  /* Options from the editor */
133
133
  const colormapName = config.colormap || 'JET';
134
134
  const colormapType = COLORMAP[colormapName] !== undefined ? COLORMAP[colormapName] : 2;
135
- const blurSize = Math.max(0, parseInt(config.blurSize) || 0);
136
- const threshold = Math.max(0, Math.min(255, parseInt(config.threshold) || 0));
135
+ const blurSize = Math.max(0, parseInt(NodeUtils.resolveDimension(
136
+ node, config.blurSizeType || 'num', config.blurSize, msg)) || 0);
137
+ const threshold = Math.max(0, Math.min(255, parseInt(NodeUtils.resolveDimension(
138
+ node, config.thresholdType || 'num', config.threshold, msg)) || 0));
137
139
  const outputFormat = config.outputFormat || 'raw';
138
140
  const outputQuality = parseInt(config.outputQuality) || 90;
139
141
  const pngOptimize = config.pngOptimize || false;
142
+ // Stats on by default; existing flows without the property get them too
143
+ const statsEnabled = config.statsEnabled !== false && config.statsEnabled !== 'false';
144
+ const statsPath = config.statsPath || 'diffStats';
145
+ const statsPathType = config.statsPathType || 'msg';
140
146
  const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
141
147
  const cppFormat = useSharpWebp ? 'raw' : outputFormat;
142
148
 
@@ -144,7 +150,7 @@ module.exports = function (RED) {
144
150
  const results = await Promise.all(
145
151
  list1.map((img1, i) =>
146
152
  Cpp.heatDiff(img1, list2[i], colormapType, blurSize, threshold,
147
- cppFormat, outputQuality, pngOptimize))
153
+ cppFormat, outputQuality, pngOptimize, statsEnabled))
148
154
  );
149
155
 
150
156
  // Aggregate timings across pairs
@@ -168,6 +174,12 @@ module.exports = function (RED) {
168
174
  /* Write result — array in, array out */
169
175
  RED.util.setMessageProperty(msg, outputPath, isArray ? images : images[0]);
170
176
 
177
+ /* Diff statistics, same shape as the image output */
178
+ if (statsEnabled) {
179
+ const stats = results.map(r => r.stats);
180
+ NodeUtils.setOutputValue(node, msg, statsPath, statsPathType, isArray ? stats : stats[0]);
181
+ }
182
+
171
183
  /* Status */
172
184
  const total = performance.now() - t0;
173
185
 
@@ -43,6 +43,11 @@
43
43
  // never - never run ECC (equivalent to pipeline=features)
44
44
  // Default 'always' for back-compat. Existing saved flows use 'always'.
45
45
  eccRefine: { value: "always" },
46
+ // Feature detector for the seed stage (features / features+ecc):
47
+ // orb - binary descriptors, fastest (default)
48
+ // sift - float descriptors, more robust on low-texture/blurry
49
+ // images, ~2-4x slower
50
+ detector: { value: "orb" },
46
51
  returnMatrix: { value: false },
47
52
  transformPolygon: { value: false },
48
53
  polygonPath: { value: "payload.polygon" },
@@ -217,11 +222,32 @@
217
222
  // ECC Refine policy is only meaningful when ECC actually runs
218
223
  $('#ecc-refine-row').toggle(pipeline === 'features+ecc');
219
224
  $('#ecc-refine-description').toggle(pipeline === 'features+ecc');
225
+ // Detector is only used by the feature-seed stage
226
+ $('#detector-row').toggle(pipeline !== 'ecc');
227
+ $('#detector-description').toggle(pipeline !== 'ecc');
220
228
  }
221
229
 
222
230
  $('#node-input-pipeline').on('change', updatePipelineDescription);
223
231
  updatePipelineDescription();
224
232
 
233
+ // Detector description
234
+ function updateDetectorDescription() {
235
+ const detector = $('#node-input-detector').val();
236
+ let description = '';
237
+ switch (detector) {
238
+ case 'orb':
239
+ description = 'ORB: binary descriptors, fastest. Good default for textured industrial images.';
240
+ break;
241
+ case 'sift':
242
+ description = 'SIFT: float descriptors, more robust on low-texture, blurry, or scale-changed images. ~2-4x slower than ORB.';
243
+ break;
244
+ }
245
+ $('#detector-description').text(description);
246
+ }
247
+
248
+ $('#node-input-detector').on('change', updateDetectorDescription);
249
+ updateDetectorDescription();
250
+
225
251
  // ECC Refine description
226
252
  function updateEccRefineDescription() {
227
253
  const eccRefine = $('#node-input-eccRefine').val();
@@ -491,6 +517,18 @@
491
517
  <div id="pipeline-description" style="font-size: 12px; color: #666; margin-top: 5px;"></div>
492
518
  </div>
493
519
 
520
+ <div class="form-row" id="detector-row">
521
+ <label for="node-input-detector"><i class="fa fa-dot-circle-o"></i> Detector</label>
522
+ <select id="node-input-detector" style="width: 250px;">
523
+ <option value="orb">ORB (fast, default)</option>
524
+ <option value="sift">SIFT (robust, slower)</option>
525
+ </select>
526
+ </div>
527
+ <div class="form-row">
528
+ <label></label>
529
+ <div id="detector-description" style="font-size: 12px; color: #666; margin-top: 5px;"></div>
530
+ </div>
531
+
494
532
  <div class="form-row" id="ecc-refine-row">
495
533
  <label for="node-input-eccRefine"><i class="fa fa-rocket"></i> ECC Refine</label>
496
534
  <select id="node-input-eccRefine" style="width: 250px;">
@@ -670,6 +708,18 @@
670
708
  <div id="pipeline-description" style="font-size: 12px; color: #666; margin-top: 5px;"></div>
671
709
  </div>
672
710
 
711
+ <div class="form-row" id="detector-row">
712
+ <label for="node-input-detector"><i class="fa fa-dot-circle-o"></i> Detector</label>
713
+ <select id="node-input-detector" style="width: 250px;">
714
+ <option value="orb">ORB (fast, default)</option>
715
+ <option value="sift">SIFT (robust, slower)</option>
716
+ </select>
717
+ </div>
718
+ <div class="form-row">
719
+ <label></label>
720
+ <div id="detector-description" style="font-size: 12px; color: #666; margin-top: 5px;"></div>
721
+ </div>
722
+
673
723
  <div class="form-row" id="ecc-refine-row">
674
724
  <label for="node-input-eccRefine"><i class="fa fa-rocket"></i> ECC Refine</label>
675
725
  <select id="node-input-eccRefine" style="width: 250px;">
@@ -768,6 +818,14 @@
768
818
  </ul>
769
819
  New nodes default to <code>features+ecc</code>; existing saved flows that lack this field fall back to <code>ecc</code> for full backward compatibility. If ECC diverges after a successful feature seed, the seed itself is returned (rather than failing the alignment).
770
820
  </dd>
821
+ <dt>Detector <span class="property-type">string</span></dt>
822
+ <dd>Feature detector used by the seed stage (pipelines <code>features</code> and <code>features+ecc</code>):
823
+ <ul>
824
+ <li><code>orb</code> &mdash; binary descriptors, fastest. Good default for textured industrial images. Legacy behavior.</li>
825
+ <li><code>sift</code> &mdash; float descriptors, more robust on low-texture, blurry, or scale-changed images; roughly 2-4x slower than ORB.</li>
826
+ </ul>
827
+ Ignored when Pipeline is <code>ecc</code>. Default <code>orb</code>.
828
+ </dd>
771
829
  <dt>ECC Refine <span class="property-type">string</span></dt>
772
830
  <dd>Only used when Pipeline is <code>features+ecc</code>. Controls whether ECC's slow iterative refinement actually runs after the ORB seed:
773
831
  <ul>
@@ -805,6 +863,7 @@
805
863
  <li><code>preset</code>: speed preset used</li>
806
864
  <li><code>pipeline</code>: pipeline used (<code>ecc</code>, <code>features</code>, or <code>features+ecc</code>)</li>
807
865
  <li><code>eccRefine</code>: ECC refinement policy used (<code>always</code>, <code>auto</code>, or <code>never</code>)</li>
866
+ <li><code>detector</code>: feature detector used (<code>orb</code> or <code>sift</code>)</li>
808
867
  <li><code>motionModel</code>: motion model used (<code>translation</code>, <code>euclidean</code>, <code>affine</code>, or <code>homography</code>)</li>
809
868
  <li><code>transformMatrix</code>: (optional) transformation matrix when enabled:
810
869
  <ul>
@@ -914,6 +973,14 @@ msg.payload = targetImageObject;</code></pre>
914
973
  </ul>
915
974
  New nodes default to <code>features+ecc</code>; existing saved flows that lack this field fall back to <code>ecc</code> for full backward compatibility. If ECC diverges after a successful feature seed, the seed itself is returned (rather than failing the alignment).
916
975
  </dd>
976
+ <dt>Detector <span class="property-type">string</span></dt>
977
+ <dd>Feature detector used by the seed stage (pipelines <code>features</code> and <code>features+ecc</code>):
978
+ <ul>
979
+ <li><code>orb</code> &mdash; binary descriptors, fastest. Good default for textured industrial images. Legacy behavior.</li>
980
+ <li><code>sift</code> &mdash; float descriptors, more robust on low-texture, blurry, or scale-changed images; roughly 2-4x slower than ORB.</li>
981
+ </ul>
982
+ Ignored when Pipeline is <code>ecc</code>. Default <code>orb</code>.
983
+ </dd>
917
984
  <dt>ECC Refine <span class="property-type">string</span></dt>
918
985
  <dd>Only used when Pipeline is <code>features+ecc</code>. Controls whether ECC's slow iterative refinement actually runs after the ORB seed:
919
986
  <ul>
@@ -951,6 +1018,7 @@ msg.payload = targetImageObject;</code></pre>
951
1018
  <li><code>preset</code>: speed preset used</li>
952
1019
  <li><code>pipeline</code>: pipeline used (<code>ecc</code>, <code>features</code>, or <code>features+ecc</code>)</li>
953
1020
  <li><code>eccRefine</code>: ECC refinement policy used (<code>always</code>, <code>auto</code>, or <code>never</code>)</li>
1021
+ <li><code>detector</code>: feature detector used (<code>orb</code> or <code>sift</code>)</li>
954
1022
  <li><code>motionModel</code>: motion model used (<code>translation</code>, <code>euclidean</code>, <code>affine</code>, or <code>homography</code>)</li>
955
1023
  <li><code>transformMatrix</code>: (optional) transformation matrix when enabled:
956
1024
  <ul>
@@ -132,6 +132,24 @@ module.exports = function (RED) {
132
132
  );
133
133
  }
134
134
 
135
+ // Feature detector for the seed stage (pipelines features / features+ecc).
136
+ // orb - binary descriptors, fastest (default)
137
+ // sift - float descriptors, more robust on low-texture/blurry images
138
+ const detector = config.detector || 'orb';
139
+ const VALID_DETECTORS = ['orb', 'sift'];
140
+ if (!VALID_DETECTORS.includes(detector)) {
141
+ return NodeUtils.handleValidationErrorWithPassthrough(
142
+ node,
143
+ {
144
+ message: `Invalid detector "${detector}"`,
145
+ hint: `detector must be one of: ${VALID_DETECTORS.join(', ')}`,
146
+ details: { detector, referenceImagePath, targetImagePath, outputPath }
147
+ },
148
+ msg, send, done,
149
+ { originalPayload: passthroughImage, outputPath, outputType: 'single' }
150
+ );
151
+ }
152
+
135
153
  /* ▸ Read images from message ------------------------------------ */
136
154
  // Validate input images
137
155
  const ref = NodeUtils.validateImageStructure(referenceImage, node);
@@ -322,7 +340,8 @@ module.exports = function (RED) {
322
340
  polygon,
323
341
  motionModel,
324
342
  pipeline,
325
- eccRefine
343
+ eccRefine,
344
+ detector
326
345
  );
327
346
 
328
347
  if (useSharpWebp) {
@@ -382,7 +401,8 @@ module.exports = function (RED) {
382
401
  preset: preset,
383
402
  motionModel: motionModel,
384
403
  pipeline: pipeline,
385
- eccRefine: eccRefine
404
+ eccRefine: eccRefine,
405
+ detector: detector
386
406
  };
387
407
 
388
408
  // Add transformation matrix if returned
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-darwin-arm64",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Prebuilt native binary for macOS ARM64 (Apple Silicon)",
5
5
  "os": ["darwin"],
6
6
  "cpu": ["arm64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-darwin-x64",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Prebuilt native binary for macOS x64 (Intel)",
5
5
  "os": ["darwin"],
6
6
  "cpu": ["x64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-linux-arm64",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Prebuilt native binary for Linux ARM64 (glibc)",
5
5
  "os": ["linux"],
6
6
  "cpu": ["arm64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-linux-x64",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Prebuilt native binary for Linux x64 (glibc)",
5
5
  "os": ["linux"],
6
6
  "cpu": ["x64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-linuxmusl-x64",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Prebuilt native binary for Linux x64 (musl/Alpine)",
5
5
  "os": ["linux"],
6
6
  "cpu": ["x64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/rosepetal-engine-win32-x64",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Prebuilt rosepetal-image-engine binary for Windows x64",
5
5
  "os": ["win32"],
6
6
  "cpu": ["x64"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Node-RED Image Processing Toolkit",
5
5
  "main": "install.sh",
6
6
  "directories": {
@@ -36,11 +36,11 @@
36
36
  "sharp": "^0.34.2"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@rosepetal/node-red-contrib-image-tools-linux-x64": "1.5.4",
40
- "@rosepetal/node-red-contrib-image-tools-linux-arm64": "1.5.4",
41
- "@rosepetal/node-red-contrib-image-tools-linuxmusl-x64": "1.5.4",
42
- "@rosepetal/node-red-contrib-image-tools-darwin-x64": "1.5.4",
43
- "@rosepetal/node-red-contrib-image-tools-darwin-arm64": "1.5.4"
39
+ "@rosepetal/node-red-contrib-image-tools-linux-x64": "1.6.0",
40
+ "@rosepetal/node-red-contrib-image-tools-linux-arm64": "1.6.0",
41
+ "@rosepetal/node-red-contrib-image-tools-linuxmusl-x64": "1.6.0",
42
+ "@rosepetal/node-red-contrib-image-tools-darwin-x64": "1.6.0",
43
+ "@rosepetal/node-red-contrib-image-tools-darwin-arm64": "1.6.0"
44
44
  },
45
45
  "node-red": {
46
46
  "version": ">=1.0.0",
@@ -1,7 +1,31 @@
1
1
  #include <napi.h>
2
2
  #include <opencv2/opencv.hpp>
3
+ #include <algorithm>
4
+ #include <cmath>
3
5
  #include "utils.h"
4
6
 
7
+ // Mean SSIM over the valid mask (standard 11x11 Gaussian, sigma 1.5)
8
+ static double MaskedSSIM(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& valid) {
9
+ const double C1 = 6.5025, C2 = 58.5225;
10
+ cv::Mat a, b;
11
+ img1.convertTo(a, CV_32F);
12
+ img2.convertTo(b, CV_32F);
13
+ const cv::Size k(11, 11);
14
+ cv::Mat mu1, mu2;
15
+ cv::GaussianBlur(a, mu1, k, 1.5);
16
+ cv::GaussianBlur(b, mu2, k, 1.5);
17
+ cv::Mat mu1sq = mu1.mul(mu1), mu2sq = mu2.mul(mu2), mu12 = mu1.mul(mu2);
18
+ cv::Mat s1, s2, s12;
19
+ cv::GaussianBlur(a.mul(a), s1, k, 1.5); s1 -= mu1sq;
20
+ cv::GaussianBlur(b.mul(b), s2, k, 1.5); s2 -= mu2sq;
21
+ cv::GaussianBlur(a.mul(b), s12, k, 1.5); s12 -= mu12;
22
+ cv::Mat num = (2 * mu12 + C1).mul(2 * s12 + C2);
23
+ cv::Mat den = (mu1sq + mu2sq + C1).mul(s1 + s2 + C2);
24
+ cv::Mat map;
25
+ cv::divide(num, den, map);
26
+ return cv::mean(map, valid)[0];
27
+ }
28
+
5
29
  class HeatDiffWorker final : public Napi::AsyncWorker {
6
30
  public:
7
31
  HeatDiffWorker(Napi::Function cb,
@@ -12,14 +36,16 @@ public:
12
36
  int threshold,
13
37
  std::string outputFormat,
14
38
  int quality = 90,
15
- bool pngOptimize = false)
39
+ bool pngOptimize = false,
40
+ bool computeStats = false)
16
41
  : Napi::AsyncWorker(cb),
17
42
  colormapType(colormapType),
18
43
  blurSize(blurSize),
19
44
  threshold(threshold),
20
45
  outputFormat(std::move(outputFormat)),
21
46
  quality(quality),
22
- pngOptimize(pngOptimize)
47
+ pngOptimize(pngOptimize),
48
+ computeStats(computeStats)
23
49
  {
24
50
  const int64 t0 = cv::getTickCount();
25
51
  mat1 = ConvertToMat(jsImg1);
@@ -75,6 +101,8 @@ protected:
75
101
  cv::threshold(diff, diff, threshold, 0, cv::THRESH_TOZERO);
76
102
  }
77
103
 
104
+ if (computeStats) ComputeStats(diff, gray1, gray2);
105
+
78
106
  // Apply colormap
79
107
  cv::applyColorMap(diff, result, colormapType);
80
108
  // applyColorMap outputs BGR
@@ -97,10 +125,107 @@ protected:
97
125
  Napi::Object out = Napi::Object::New(env);
98
126
  out.Set("image", jsImg);
99
127
  out.Set("timing", MakeTimingJS(env, convertMs, taskMs, encodeMs));
128
+
129
+ if (computeStats) {
130
+ Napi::Object st = Napi::Object::New(env);
131
+ st.Set("validRatio", statValidRatio);
132
+ st.Set("changedRatio", statChangedRatio);
133
+ st.Set("meanDiff", statMean);
134
+ st.Set("maxDiff", statMax);
135
+ st.Set("p50", statP50);
136
+ st.Set("p95", statP95);
137
+ st.Set("p99", statP99);
138
+ st.Set("rmse", statRmse);
139
+ st.Set("psnr", statPsnr);
140
+ st.Set("ssim", statSsim);
141
+ st.Set("threshold", threshold);
142
+ st.Set("blobCount", statBlobCount);
143
+ st.Set("largestBlobArea", statLargestBlobArea);
144
+ Napi::Array arr = Napi::Array::New(env, statBlobs.size());
145
+ for (size_t i = 0; i < statBlobs.size(); i++) {
146
+ const BlobStat& b = statBlobs[i];
147
+ Napi::Object o = Napi::Object::New(env);
148
+ o.Set("x", b.x); o.Set("y", b.y); o.Set("w", b.w); o.Set("h", b.h);
149
+ o.Set("area", b.area);
150
+ o.Set("cx", b.cx); o.Set("cy", b.cy);
151
+ arr.Set(static_cast<uint32_t>(i), o);
152
+ }
153
+ st.Set("blobs", arr);
154
+ out.Set("stats", st);
155
+ }
156
+
100
157
  Callback().Call({env.Null(), out});
101
158
  }
102
159
 
103
160
  private:
161
+ struct BlobStat { int x, y, w, h, area; double cx, cy; };
162
+ static constexpr size_t kMaxBlobs = 50;
163
+
164
+ // All stats ignore pixels that are pure black in either input (alignment
165
+ // borders / composite padding produce huge fake diffs there).
166
+ void ComputeStats(const cv::Mat& diff, const cv::Mat& gray1, const cv::Mat& gray2) {
167
+ const double total = static_cast<double>(diff.rows) * diff.cols;
168
+ cv::Mat valid = (gray1 > 0) & (gray2 > 0);
169
+ const int validCount = cv::countNonZero(valid);
170
+ statValidRatio = validCount / total;
171
+ if (validCount == 0) return;
172
+
173
+ cv::Mat changed;
174
+ cv::compare(diff, threshold, changed, cv::CMP_GT);
175
+ changed &= valid;
176
+ statChangedRatio = cv::countNonZero(changed) / static_cast<double>(validCount);
177
+
178
+ statMean = cv::mean(diff, valid)[0];
179
+ double maxVal = 0;
180
+ cv::minMaxLoc(diff, nullptr, &maxVal, nullptr, nullptr, valid);
181
+ statMax = maxVal;
182
+
183
+ // Percentiles of the diff values via a masked 256-bin histogram
184
+ int histSize = 256;
185
+ float range[] = {0, 256};
186
+ const float* ranges[] = {range};
187
+ cv::Mat hist;
188
+ cv::calcHist(&diff, 1, nullptr, valid, hist, 1, &histSize, ranges);
189
+ double cum = 0;
190
+ statP50 = statP95 = statP99 = -1;
191
+ for (int i = 0; i < histSize; i++) {
192
+ cum += hist.at<float>(i);
193
+ const double frac = cum / validCount;
194
+ if (statP50 < 0 && frac >= 0.50) statP50 = i;
195
+ if (statP95 < 0 && frac >= 0.95) statP95 = i;
196
+ if (statP99 < 0 && frac >= 0.99) { statP99 = i; break; }
197
+ }
198
+
199
+ cv::Mat diffF;
200
+ diff.convertTo(diffF, CV_32F);
201
+ const double meanSq = cv::mean(diffF.mul(diffF), valid)[0];
202
+ statRmse = std::sqrt(meanSq);
203
+ statPsnr = meanSq > 0 ? 10.0 * std::log10(255.0 * 255.0 / meanSq) : 100.0;
204
+
205
+ statSsim = MaskedSSIM(gray1, gray2, valid);
206
+
207
+ // Connected components on the changed mask -> blobs (largest first, capped)
208
+ cv::Mat labels, ccStats, centroids;
209
+ const int n = cv::connectedComponentsWithStats(changed, labels, ccStats, centroids, 8, CV_32S);
210
+ statBlobCount = n - 1;
211
+ std::vector<BlobStat> blobs;
212
+ blobs.reserve(n - 1);
213
+ for (int i = 1; i < n; i++) {
214
+ blobs.push_back({ccStats.at<int>(i, cv::CC_STAT_LEFT),
215
+ ccStats.at<int>(i, cv::CC_STAT_TOP),
216
+ ccStats.at<int>(i, cv::CC_STAT_WIDTH),
217
+ ccStats.at<int>(i, cv::CC_STAT_HEIGHT),
218
+ ccStats.at<int>(i, cv::CC_STAT_AREA),
219
+ centroids.at<double>(i, 0),
220
+ centroids.at<double>(i, 1)});
221
+ }
222
+ std::sort(blobs.begin(), blobs.end(),
223
+ [](const BlobStat& a, const BlobStat& b) { return a.area > b.area; });
224
+ if (blobs.size() > kMaxBlobs) blobs.resize(kMaxBlobs);
225
+ statLargestBlobArea = blobs.empty() ? 0 : blobs[0].area;
226
+ statBlobs = std::move(blobs);
227
+ }
228
+
104
229
  cv::Mat mat1, mat2, result;
105
230
  std::string format1, format2, outputChannel;
106
231
  int colormapType;
@@ -109,8 +234,14 @@ private:
109
234
  std::string outputFormat;
110
235
  int quality;
111
236
  bool pngOptimize;
237
+ bool computeStats;
112
238
  double convertMs = 0, taskMs = 0, encodeMs = 0;
113
239
  std::vector<uchar> encodedBuf;
240
+
241
+ double statValidRatio = 0, statChangedRatio = 0, statMean = 0, statMax = 0;
242
+ double statP50 = 0, statP95 = 0, statP99 = 0, statRmse = 0, statPsnr = 0, statSsim = 0;
243
+ int statBlobCount = 0, statLargestBlobArea = 0;
244
+ std::vector<BlobStat> statBlobs;
114
245
  };
115
246
 
116
247
  Napi::Value HeatDiff(const Napi::CallbackInfo& info) {
@@ -118,7 +249,7 @@ Napi::Value HeatDiff(const Napi::CallbackInfo& info) {
118
249
 
119
250
  if (info.Length() < 3 || !info[info.Length() - 1].IsFunction()) {
120
251
  Napi::TypeError::New(env,
121
- "heatDiff(image1, image2, colormapType, [blurSize], [threshold], [outputFormat], [quality], [pngOptimize], callback)")
252
+ "heatDiff(image1, image2, colormapType, [blurSize], [threshold], [outputFormat], [quality], [pngOptimize], [computeStats], callback)")
122
253
  .ThrowAsJavaScriptException();
123
254
  return env.Null();
124
255
  }
@@ -132,15 +263,18 @@ Napi::Value HeatDiff(const Napi::CallbackInfo& info) {
132
263
  std::string outputFormat = "raw";
133
264
  int quality = 90;
134
265
  bool pngOptimize = false;
266
+ bool computeStats = false;
135
267
  size_t cbIdx = 3;
136
268
 
137
- if (info.Length() >= 5) { blurSize = info[3].As<Napi::Number>().Int32Value(); cbIdx = 4; }
138
- if (info.Length() >= 6) { threshold = info[4].As<Napi::Number>().Int32Value(); cbIdx = 5; }
139
- if (info.Length() >= 7) { outputFormat = info[5].As<Napi::String>().Utf8Value(); cbIdx = 6; }
140
- if (info.Length() >= 8) { quality = info[6].As<Napi::Number>().Int32Value(); cbIdx = 7; }
141
- if (info.Length() >= 9) { pngOptimize = info[7].As<Napi::Boolean>().Value(); cbIdx = 8; }
269
+ if (info.Length() >= 5) { blurSize = info[3].As<Napi::Number>().Int32Value(); cbIdx = 4; }
270
+ if (info.Length() >= 6) { threshold = info[4].As<Napi::Number>().Int32Value(); cbIdx = 5; }
271
+ if (info.Length() >= 7) { outputFormat = info[5].As<Napi::String>().Utf8Value(); cbIdx = 6; }
272
+ if (info.Length() >= 8) { quality = info[6].As<Napi::Number>().Int32Value(); cbIdx = 7; }
273
+ if (info.Length() >= 9) { pngOptimize = info[7].As<Napi::Boolean>().Value(); cbIdx = 8; }
274
+ if (info.Length() >= 10) { computeStats = info[8].As<Napi::Boolean>().Value(); cbIdx = 9; }
142
275
 
143
276
  (new HeatDiffWorker(info[cbIdx].As<Napi::Function>(),
144
- jsImg1, jsImg2, colormapType, blurSize, threshold, outputFormat, quality, pngOptimize))->Queue();
277
+ jsImg1, jsImg2, colormapType, blurSize, threshold, outputFormat, quality, pngOptimize,
278
+ computeStats))->Queue();
145
279
  return env.Undefined();
146
280
  }
@@ -185,6 +185,18 @@ static EccRefineMode ParseEccRefine(const std::string& name) {
185
185
  " (expected: always, auto, or never)");
186
186
  }
187
187
 
188
+ // Feature detector for the feature-seed stage:
189
+ // ORB - binary descriptors, fastest (default)
190
+ // SIFT - float descriptors, more robust on low-texture/blurry images, slower
191
+ enum class FeatureDetectorKind { ORB, SIFT };
192
+
193
+ static FeatureDetectorKind ParseDetector(const std::string& name) {
194
+ if (name == "orb") return FeatureDetectorKind::ORB;
195
+ if (name == "sift") return FeatureDetectorKind::SIFT;
196
+ throw std::runtime_error("Unknown detector: " + name +
197
+ " (expected: orb or sift)");
198
+ }
199
+
188
200
  class ImageAlignWorker : public Napi::AsyncWorker {
189
201
  public:
190
202
  ImageAlignWorker(Napi::Function& callback,
@@ -200,7 +212,8 @@ public:
200
212
  const Napi::Value& polygonValue = Napi::Value(),
201
213
  std::string motionModel = "translation",
202
214
  std::string pipeline = "ecc",
203
- std::string eccRefine = "always")
215
+ std::string eccRefine = "always",
216
+ std::string detector = "orb")
204
217
  : Napi::AsyncWorker(callback),
205
218
  scale(scale),
206
219
  maxIterations(maxIterations),
@@ -216,6 +229,8 @@ public:
216
229
  pipelineMode(AlignPipeline::ECC),
217
230
  eccRefineName(std::move(eccRefine)),
218
231
  eccRefineMode(EccRefineMode::ALWAYS),
232
+ detectorName(std::move(detector)),
233
+ detectorKind(FeatureDetectorKind::ORB),
219
234
  alignmentSuccess(false),
220
235
  hasPolygon(false),
221
236
  isPolygonArray(false) {
@@ -234,6 +249,9 @@ public:
234
249
  // And the ECC refinement policy (always / auto / never).
235
250
  eccRefineMode = ParseEccRefine(eccRefineName);
236
251
 
252
+ // And the feature detector (orb / sift).
253
+ detectorKind = ParseDetector(detectorName);
254
+
237
255
  // Convert input images to OpenCV Mat
238
256
  referenceMat = ConvertToMat(referenceImage);
239
257
  targetMat = ConvertToMat(targetImage);
@@ -328,11 +346,19 @@ protected:
328
346
  int refHeight = referenceMat.rows;
329
347
  int refWidth = referenceMat.cols;
330
348
 
349
+ // Only ECC (pixel-for-pixel correlation) and the polygon round-trip
350
+ // (normalizes by reference dims) require equal sizes. The features
351
+ // pipeline works on keypoint coordinates, and forcing the resize
352
+ // there injects an anisotropic stretch the motion model can only
353
+ // "explain" as a spurious rotation.
354
+ const bool needsSameSize =
355
+ (pipelineMode != AlignPipeline::FEATURES) || hasPolygon;
356
+
331
357
  // Resize target image to match reference dimensions, with caching.
332
358
  // For the constant-golden / changing-scan production pattern, the
333
359
  // golden's resize result is constant per call. Hash + cache it.
334
360
  cv::Mat targetResized;
335
- if (targetMat.size() != referenceMat.size()) {
361
+ if (needsSameSize && targetMat.size() != referenceMat.size()) {
336
362
  const uint64_t key = FastImageFingerprint(targetMat)
337
363
  ^ (static_cast<uint64_t>(refWidth) << 16)
338
364
  ^ static_cast<uint64_t>(refHeight)
@@ -381,6 +407,10 @@ protected:
381
407
 
382
408
  // Apply transformation to the color target image
383
409
  ApplyTransformation(targetResized, transformMatrix, cv::Size(refWidth, refHeight));
410
+ } else if (targetResized.size() != referenceMat.size()) {
411
+ // Alignment failed with the resize skipped: still emit a
412
+ // reference-sized image to keep the output-dimension contract.
413
+ cv::resize(targetResized, alignedImage, cv::Size(refWidth, refHeight));
384
414
  } else {
385
415
  // If alignment fails, use the resized target as-is
386
416
  alignedImage = targetResized;
@@ -545,6 +575,10 @@ private:
545
575
  std::string eccRefineName; // raw string from JS ('always' | 'auto' | 'never')
546
576
  EccRefineMode eccRefineMode; // resolved enum
547
577
 
578
+ // Feature detector for the seed stage ('orb' | 'sift')
579
+ std::string detectorName;
580
+ FeatureDetectorKind detectorKind;
581
+
548
582
  bool alignmentSuccess;
549
583
 
550
584
  // Polygon data
@@ -622,9 +656,13 @@ private:
622
656
  try {
623
657
  // First check the seed-matrix cache: if we've already solved this
624
658
  // exact (ref, target, motion) triple, return the saved matrix and
625
- // skip everything (ORB detect/describe, BFMatcher, RANSAC).
626
- const uint64_t refFp = FastImageFingerprint(refGray);
627
- const uint64_t targetFp = FastImageFingerprint(targetGray);
659
+ // skip everything (detect/describe, BFMatcher, RANSAC).
660
+ // Fingerprints are salted with the detector kind so ORB and SIFT
661
+ // entries (features and seed matrices) never collide.
662
+ const uint64_t detSalt = (detectorKind == FeatureDetectorKind::SIFT)
663
+ ? 0x51465400d5a7c3b1ULL : 0ULL;
664
+ const uint64_t refFp = FastImageFingerprint(refGray) ^ detSalt;
665
+ const uint64_t targetFp = FastImageFingerprint(targetGray) ^ detSalt;
628
666
  // Composite key: mix the two fingerprints with the motion flag.
629
667
  uint64_t seedKey = refFp;
630
668
  seedKey ^= targetFp + 0x9e3779b97f4a7c15ULL + (seedKey << 6) + (seedKey >> 2);
@@ -643,15 +681,20 @@ private:
643
681
  }
644
682
  }
645
683
 
646
- cv::Ptr<cv::ORB> orb = cv::ORB::create(
647
- /*nfeatures*/ 800,
648
- /*scaleFactor*/ 1.2f,
649
- /*nlevels*/ 5);
684
+ cv::Ptr<cv::Feature2D> det;
685
+ if (detectorKind == FeatureDetectorKind::SIFT) {
686
+ det = cv::SIFT::create(/*nfeatures*/ 800);
687
+ } else {
688
+ det = cv::ORB::create(
689
+ /*nfeatures*/ 800,
690
+ /*scaleFactor*/ 1.2f,
691
+ /*nlevels*/ 5);
692
+ }
650
693
 
651
694
  // Detect-or-cache helper. Looks up by FastImageFingerprint and skips
652
- // ORB entirely on cache hit. The big win is the "constant golden,
695
+ // detection entirely on cache hit. The big win is the "constant golden,
653
696
  // changing scan" pattern: golden hits the cache from call #2 onward.
654
- auto detectOrCached = [&orb](const cv::Mat& img, uint64_t fp,
697
+ auto detectOrCached = [&det](const cv::Mat& img, uint64_t fp,
655
698
  std::vector<cv::KeyPoint>& kp,
656
699
  cv::Mat& des) {
657
700
  OrbCacheEntry hit;
@@ -660,7 +703,7 @@ private:
660
703
  des = hit.des;
661
704
  return;
662
705
  }
663
- orb->detectAndCompute(img, cv::noArray(), kp, des);
706
+ det->detectAndCompute(img, cv::noArray(), kp, des);
664
707
  OrbCacheEntry e;
665
708
  e.kp = kp;
666
709
  e.des = des.clone(); // detach storage
@@ -687,8 +730,11 @@ private:
687
730
  return false;
688
731
  }
689
732
 
690
- // Brute-force Hamming + Lowe's ratio test (0.75) for robust matching.
691
- cv::BFMatcher matcher(cv::NORM_HAMMING, /*crossCheck=*/false);
733
+ // Brute-force matching + Lowe's ratio test (0.75).
734
+ // Hamming for ORB's binary descriptors, L2 for SIFT's floats.
735
+ const int normType = (detectorKind == FeatureDetectorKind::SIFT)
736
+ ? cv::NORM_L2 : cv::NORM_HAMMING;
737
+ cv::BFMatcher matcher(normType, /*crossCheck=*/false);
692
738
  std::vector<std::vector<cv::DMatch>> knn;
693
739
  matcher.knnMatch(des1, des2, knn, 2);
694
740
 
@@ -728,9 +774,12 @@ private:
728
774
 
729
775
  // Translation and Euclidean both start from a partial-affine estimate
730
776
  // (translation + rotation + uniform scale = 4 DoF), then post-process
731
- // it to drop the unwanted DoFs.
777
+ // it to drop the unwanted DoFs. Classic RANSAC here, not USAC:
778
+ // estimateAffinePartial2D rejects every USAC_* method (throws
779
+ // StsBadArg on all OpenCV versions), which made these seeds
780
+ // silently fail forever.
732
781
  cv::Mat P = cv::estimateAffinePartial2D(srcPts, dstPts, inlierMask,
733
- cv::USAC_MAGSAC, 5.0);
782
+ cv::RANSAC, 5.0);
734
783
  if (P.empty()) return false;
735
784
  P.convertTo(P, CV_32F);
736
785
 
@@ -804,21 +853,21 @@ private:
804
853
  // instead of returning a wildly wrong identity warp.
805
854
  bool FindTransformation(const cv::Mat& refGray, const cv::Mat& targetGray, cv::Mat& transformMatrix) {
806
855
  try {
807
- int height = refGray.rows;
808
- int width = refGray.cols;
809
-
810
856
  // Downsample images for faster alignment.
811
- // ORB and ECC both run on this same small grid so all intermediate
812
- // matrix arithmetic stays in small-frame coords; we rescale once at
813
- // the very end via RescaleSmallToFull().
814
- int scaledWidth = std::max(1, static_cast<int>(std::round(width * scale)));
815
- int scaledHeight = std::max(1, static_cast<int>(std::round(height * scale)));
816
-
857
+ // Each image is scaled by the same *factor* (not to the ref's dims:
858
+ // sizes can legitimately differ on the features pipeline, and forcing
859
+ // ref dims onto the target would stretch it anisotropically).
860
+ // RescaleSmallToFull divides translation by exactly `scale`, so both
861
+ // sides must use that factor. Equal-sized inputs get identical dims,
862
+ // keeping the common path bit-identical.
863
+ //
817
864
  // Cached resize: skips cv::resize when the input gray hasn't changed
818
865
  // (constant-golden, repeated-call pattern). Lookup is keyed by the
819
866
  // FULL-resolution input fingerprint AND the requested small dims.
820
- auto resizeOrCached = [scaledWidth, scaledHeight](const cv::Mat& fullGray,
821
- cv::Mat& smallOut) {
867
+ auto resizeOrCached = [this](const cv::Mat& fullGray,
868
+ cv::Mat& smallOut) {
869
+ const int scaledWidth = std::max(1, static_cast<int>(std::round(fullGray.cols * scale)));
870
+ const int scaledHeight = std::max(1, static_cast<int>(std::round(fullGray.rows * scale)));
822
871
  const uint64_t key = FastImageFingerprint(fullGray)
823
872
  ^ (static_cast<uint64_t>(scaledWidth) << 16)
824
873
  ^ static_cast<uint64_t>(scaledHeight);
@@ -1069,8 +1118,8 @@ Napi::Value ImageAlign(const Napi::CallbackInfo& info) {
1069
1118
  Napi::Env env = info.Env();
1070
1119
 
1071
1120
  // Validate arguments - expect callback as last argument
1072
- if (info.Length() < 3 || info.Length() > 14 || !info[info.Length() - 1].IsFunction()) {
1073
- Napi::TypeError::New(env, "imageAlign(referenceImage, targetImage, [scale], [maxIterations], [terminationEps], [outputFormat], [quality], [pngOptimize], [returnMatrix], [polygon], [motionModel], [pipeline], [eccRefine], callback)")
1121
+ if (info.Length() < 3 || info.Length() > 15 || !info[info.Length() - 1].IsFunction()) {
1122
+ Napi::TypeError::New(env, "imageAlign(referenceImage, targetImage, [scale], [maxIterations], [terminationEps], [outputFormat], [quality], [pngOptimize], [returnMatrix], [polygon], [motionModel], [pipeline], [eccRefine], [detector], callback)")
1074
1123
  .ThrowAsJavaScriptException();
1075
1124
  return env.Null();
1076
1125
  }
@@ -1096,6 +1145,8 @@ Napi::Value ImageAlign(const Napi::CallbackInfo& info) {
1096
1145
  std::string pipeline = "ecc";
1097
1146
  // Default eccRefine is "always" - never silently skips ECC.
1098
1147
  std::string eccRefine = "always";
1148
+ // Default detector is ORB (fastest; pre-existing behavior).
1149
+ std::string detector = "orb";
1099
1150
 
1100
1151
  // Parse optional parameters (before callback)
1101
1152
  if (info.Length() >= 4) {
@@ -1131,12 +1182,15 @@ Napi::Value ImageAlign(const Napi::CallbackInfo& info) {
1131
1182
  if (info.Length() >= 14) {
1132
1183
  eccRefine = info[12].As<Napi::String>().Utf8Value();
1133
1184
  }
1185
+ if (info.Length() >= 15) {
1186
+ detector = info[13].As<Napi::String>().Utf8Value();
1187
+ }
1134
1188
 
1135
1189
  // Create and queue worker
1136
1190
  ImageAlignWorker* worker = new ImageAlignWorker(callback, referenceImage, targetImage,
1137
1191
  scale, maxIterations, terminationEps,
1138
1192
  outputFormat, quality, pngOptimize, returnMatrix, polygon,
1139
- motionModel, pipeline, eccRefine);
1193
+ motionModel, pipeline, eccRefine, detector);
1140
1194
  worker->Queue();
1141
1195
 
1142
1196
  return env.Undefined();