@rosepetal/node-red-contrib-image-tools 1.3.1 → 1.4.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.
@@ -31,7 +31,11 @@
31
31
 
32
32
  propagateMasks:{value:false},
33
33
  masksPath:{value:"masks"}, masksPathType:{value:"msg"},
34
- masksOutputPath:{value:"masks"}, masksOutputPathType:{value:"msg"}
34
+ masksOutputPath:{value:"masks"}, masksOutputPathType:{value:"msg"},
35
+ // Inference transform
36
+ inferenceEnabled:{value:false},
37
+ inferencePath:{value:"inference"}, inferencePathType:{value:"msg"},
38
+ inferenceOutputPath:{value:"inference"}, inferenceOutputPathType:{value:"msg"}
35
39
  },
36
40
 
37
41
  inputs:1, outputs:1,
@@ -114,6 +118,21 @@
114
118
  updateDebugWidthVisibility();
115
119
  });
116
120
 
121
+ // === Inference Transform Logic ===
122
+ $("#node-input-inferencePath").typedInput({
123
+ default:'msg', types:['msg','flow','global'],
124
+ typeField:"#node-input-inferencePathType"
125
+ });
126
+ $("#node-input-inferenceOutputPath").typedInput({
127
+ default:'msg', types:['msg','flow','global'],
128
+ typeField:"#node-input-inferenceOutputPathType"
129
+ });
130
+ const infCb = $('#node-input-inferenceEnabled');
131
+ const infRows = $('#inference-config-rows');
132
+ function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
133
+ updateInfVis();
134
+ infCb.on('change', updateInfVis);
135
+
117
136
  // Mask propagation visibility
118
137
  const propagateCheckbox = $('#node-input-propagateMasks');
119
138
  const masksPathRow = $('#mask-path-row');
@@ -2068,6 +2087,32 @@
2068
2087
  <li><b>Duplicate:</b> Use "Duplicate" button to copy the selected image configuration</li>
2069
2088
  </ul>
2070
2089
  </div>
2090
+
2091
+ <!-- Advanced Options -->
2092
+ <details id="advanced-options" style="margin-top: 12px;">
2093
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
2094
+ <i class="fa fa-cog"></i> Advanced options
2095
+ </summary>
2096
+ <div style="margin-top: 8px;">
2097
+ <div class="form-row">
2098
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
2099
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
2100
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
2101
+ </div>
2102
+ <div id="inference-config-rows" style="display: none;">
2103
+ <div class="form-row">
2104
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
2105
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
2106
+ <input type="hidden" id="node-input-inferencePathType">
2107
+ </div>
2108
+ <div class="form-row">
2109
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
2110
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
2111
+ <input type="hidden" id="node-input-inferenceOutputPathType">
2112
+ </div>
2113
+ </div>
2114
+ </div>
2115
+ </details>
2071
2116
  </script>
2072
2117
 
2073
2118
  <script type="text/x-red" data-template-name="advanced-mosaic">
@@ -2336,6 +2381,32 @@
2336
2381
  <li><b>Duplicate:</b> Use "Duplicate" button to copy the selected image configuration</li>
2337
2382
  </ul>
2338
2383
  </div>
2384
+
2385
+ <!-- Advanced Options -->
2386
+ <details id="advanced-options" style="margin-top: 12px;">
2387
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
2388
+ <i class="fa fa-cog"></i> Advanced options
2389
+ </summary>
2390
+ <div style="margin-top: 8px;">
2391
+ <div class="form-row">
2392
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
2393
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
2394
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
2395
+ </div>
2396
+ <div id="inference-config-rows" style="display: none;">
2397
+ <div class="form-row">
2398
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
2399
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
2400
+ <input type="hidden" id="node-input-inferencePathType">
2401
+ </div>
2402
+ <div class="form-row">
2403
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
2404
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
2405
+ <input type="hidden" id="node-input-inferenceOutputPathType">
2406
+ </div>
2407
+ </div>
2408
+ </div>
2409
+ </details>
2339
2410
  </script>
2340
2411
 
2341
2412
  <!-- 3 ▸ Help panel -->
@@ -206,6 +206,31 @@ module.exports = function (RED) {
206
206
 
207
207
  NodeUtils.recordPerformanceMetrics(node, msg, timing, totalTime);
208
208
 
209
+ // --- Inference Transform ---
210
+ if (config.inferenceEnabled === true || config.inferenceEnabled === 'true') {
211
+ try {
212
+ const InfTx = require('../../lib/inference-transform.js');
213
+ const infPath = config.inferencePath || 'inference';
214
+ const infPathType = config.inferencePathType || 'msg';
215
+ const infOutPath = config.inferenceOutputPath || 'inference';
216
+ const infOutPathType = config.inferenceOutputPathType || 'msg';
217
+ const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
218
+
219
+ if (inferences && Array.isArray(inferences) && inferences.length > 0) {
220
+ const imageDims = imageArray.map(img => ({ width: img.width, height: img.height }));
221
+ const transformMap = InfTx.makeAdvancedMosaicTransform({
222
+ imageConfigs: validImageConfigs,
223
+ canvasW: canvasWidth, canvasH: canvasHeight,
224
+ imageDims, normalized
225
+ });
226
+ const transformed = await InfTx.applyMultiImageTransform(inferences, transformMap, CppProcessor);
227
+ NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
228
+ }
229
+ } catch (infErr) {
230
+ node.warn(`Inference transform: ${infErr.message}`);
231
+ }
232
+ }
233
+
209
234
  send(msg);
210
235
  done && done();
211
236
  } catch (err) {
@@ -21,7 +21,11 @@
21
21
  debugWidthType:{value:"num"},
22
22
  direction:{value:"right"}, // right|left|down|up
23
23
  strategy :{value:"pad-start"}, // pad-start|pad-end|pad-both|resize
24
- padColor :{value:"#000000"}
24
+ padColor :{value:"#000000"},
25
+ // Inference transform
26
+ inferenceEnabled:{value:false},
27
+ inferencePath:{value:"inference"}, inferencePathType:{value:"msg"},
28
+ inferenceOutputPath:{value:"inference"}, inferenceOutputPathType:{value:"msg"}
25
29
  },
26
30
  inputs:1,outputs:1,
27
31
  label:function(){return this.name||"rp-concat";},
@@ -84,6 +88,21 @@
84
88
  // Store debug state for runtime access
85
89
  $('#node-input-debugEnabled').data('debug-enabled', enabled);
86
90
  });
91
+
92
+ // === Inference Transform Logic ===
93
+ $("#node-input-inferencePath").typedInput({
94
+ default:'msg', types:['msg','flow','global'],
95
+ typeField:"#node-input-inferencePathType"
96
+ });
97
+ $("#node-input-inferenceOutputPath").typedInput({
98
+ default:'msg', types:['msg','flow','global'],
99
+ typeField:"#node-input-inferenceOutputPathType"
100
+ });
101
+ const infCb = $('#node-input-inferenceEnabled');
102
+ const infRows = $('#inference-config-rows');
103
+ function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
104
+ updateInfVis();
105
+ infCb.on('change', updateInfVis);
87
106
  }
88
107
  };
89
108
  RED.nodes.registerType('rp-concat', _rpNodeCfg);
@@ -257,7 +276,7 @@
257
276
  <input type="hidden" id="node-input-debugWidthType">
258
277
  <span style="margin-left: 10px; color: #666;">pixels</span>
259
278
  </div>
260
-
279
+
261
280
  <hr/>
262
281
  <div class="form-row">
263
282
  <label><i class="fa fa-arrows-h"></i> Direction</label>
@@ -282,6 +301,32 @@
282
301
  <label for="node-input-padColor"><i class="fa fa-tint"></i> Pad colour</label>
283
302
  <input type="color" id="node-input-padColor" style="width:80px;">
284
303
  </div>
304
+
305
+ <!-- Advanced Options -->
306
+ <details id="advanced-options" style="margin-top: 12px;">
307
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
308
+ <i class="fa fa-cog"></i> Advanced options
309
+ </summary>
310
+ <div style="margin-top: 8px;">
311
+ <div class="form-row">
312
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
313
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
314
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
315
+ </div>
316
+ <div id="inference-config-rows" style="display: none;">
317
+ <div class="form-row">
318
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
319
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
320
+ <input type="hidden" id="node-input-inferencePathType">
321
+ </div>
322
+ <div class="form-row">
323
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
324
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
325
+ <input type="hidden" id="node-input-inferenceOutputPathType">
326
+ </div>
327
+ </div>
328
+ </div>
329
+ </details>
285
330
  </script>
286
331
 
287
332
  <script type="text/x-red" data-template-name="concat">
@@ -342,7 +387,7 @@
342
387
  <input type="hidden" id="node-input-debugWidthType">
343
388
  <span style="margin-left: 10px; color: #666;">pixels</span>
344
389
  </div>
345
-
390
+
346
391
  <hr/>
347
392
  <div class="form-row">
348
393
  <label><i class="fa fa-arrows-h"></i> Direction</label>
@@ -367,6 +412,32 @@
367
412
  <label for="node-input-padColor"><i class="fa fa-tint"></i> Pad colour</label>
368
413
  <input type="color" id="node-input-padColor" style="width:80px;">
369
414
  </div>
415
+
416
+ <!-- Advanced Options -->
417
+ <details id="advanced-options" style="margin-top: 12px;">
418
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
419
+ <i class="fa fa-cog"></i> Advanced options
420
+ </summary>
421
+ <div style="margin-top: 8px;">
422
+ <div class="form-row">
423
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
424
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
425
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
426
+ </div>
427
+ <div id="inference-config-rows" style="display: none;">
428
+ <div class="form-row">
429
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
430
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
431
+ <input type="hidden" id="node-input-inferencePathType">
432
+ </div>
433
+ <div class="form-row">
434
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
435
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
436
+ <input type="hidden" id="node-input-inferenceOutputPathType">
437
+ </div>
438
+ </div>
439
+ </div>
440
+ </details>
370
441
  </script>
371
442
 
372
443
  <script type="text/x-red" data-help-name="rp-concat">
@@ -134,6 +134,29 @@ module.exports = function (RED) {
134
134
 
135
135
  NodeUtils.recordPerformanceMetrics(node, msg, timing || {}, total);
136
136
 
137
+ // --- Inference Transform ---
138
+ if (config.inferenceEnabled === true || config.inferenceEnabled === 'true') {
139
+ try {
140
+ const InfTx = require('../../lib/inference-transform.js');
141
+ const infPath = config.inferencePath || 'inference';
142
+ const infPathType = config.inferencePathType || 'msg';
143
+ const infOutPath = config.inferenceOutputPath || 'inference';
144
+ const infOutPathType = config.inferenceOutputPathType || 'msg';
145
+ const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
146
+
147
+ if (inferences && Array.isArray(inferences) && inferences.length > 0) {
148
+ const imageDims = imgs.map(img => ({ width: img.width, height: img.height }));
149
+ const transforms = InfTx.makeConcatTransforms({
150
+ direction, strategy, imageDims
151
+ });
152
+ const transformed = await InfTx.applyMultiImageTransform(inferences, transforms, Cpp);
153
+ NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
154
+ }
155
+ } catch (infErr) {
156
+ node.warn(`Inference transform: ${infErr.message}`);
157
+ }
158
+ }
159
+
137
160
  send(msg);
138
161
  done && done();
139
162
  } catch (err) {
@@ -28,7 +28,11 @@
28
28
  backgroundColor:{value:"#000000"},
29
29
  coordNorm:{value:false},
30
30
 
31
- positions:{value:[]} // Array of {arrayIndex, x, y} objects
31
+ positions:{value:[]}, // Array of {arrayIndex, x, y} objects
32
+ // Inference transform
33
+ inferenceEnabled:{value:false},
34
+ inferencePath:{value:"inference"}, inferencePathType:{value:"msg"},
35
+ inferenceOutputPath:{value:"inference"}, inferenceOutputPathType:{value:"msg"}
32
36
  },
33
37
 
34
38
  inputs:1, outputs:1,
@@ -178,6 +182,21 @@
178
182
  // Store debug state for runtime access
179
183
  $('#node-input-debugEnabled').data('debug-enabled', enabled);
180
184
  });
185
+
186
+ // === Inference Transform Logic ===
187
+ $("#node-input-inferencePath").typedInput({
188
+ default:'msg', types:['msg','flow','global'],
189
+ typeField:"#node-input-inferencePathType"
190
+ });
191
+ $("#node-input-inferenceOutputPath").typedInput({
192
+ default:'msg', types:['msg','flow','global'],
193
+ typeField:"#node-input-inferenceOutputPathType"
194
+ });
195
+ const infCb = $('#node-input-inferenceEnabled');
196
+ const infRows = $('#inference-config-rows');
197
+ function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
198
+ updateInfVis();
199
+ infCb.on('change', updateInfVis);
181
200
  }
182
201
  };
183
202
  RED.nodes.registerType('rp-mosaic', _rpNodeCfg);
@@ -411,6 +430,32 @@
411
430
  <li><b>Dynamic Configuration:</b> Use Add/Remove buttons to manage position mappings</li>
412
431
  </ul>
413
432
  </div>
433
+
434
+ <!-- Advanced Options -->
435
+ <details id="advanced-options" style="margin-top: 12px;">
436
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
437
+ <i class="fa fa-cog"></i> Advanced options
438
+ </summary>
439
+ <div style="margin-top: 8px;">
440
+ <div class="form-row">
441
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
442
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
443
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
444
+ </div>
445
+ <div id="inference-config-rows" style="display: none;">
446
+ <div class="form-row">
447
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
448
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
449
+ <input type="hidden" id="node-input-inferencePathType">
450
+ </div>
451
+ <div class="form-row">
452
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
453
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
454
+ <input type="hidden" id="node-input-inferenceOutputPathType">
455
+ </div>
456
+ </div>
457
+ </div>
458
+ </details>
414
459
  </script>
415
460
 
416
461
  <script type="text/x-red" data-template-name="mosaic">
@@ -530,6 +575,32 @@
530
575
  <li><b>Dynamic Configuration:</b> Use Add/Remove buttons to manage position mappings</li>
531
576
  </ul>
532
577
  </div>
578
+
579
+ <!-- Advanced Options -->
580
+ <details id="advanced-options" style="margin-top: 12px;">
581
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
582
+ <i class="fa fa-cog"></i> Advanced options
583
+ </summary>
584
+ <div style="margin-top: 8px;">
585
+ <div class="form-row">
586
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
587
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
588
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
589
+ </div>
590
+ <div id="inference-config-rows" style="display: none;">
591
+ <div class="form-row">
592
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
593
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
594
+ <input type="hidden" id="node-input-inferencePathType">
595
+ </div>
596
+ <div class="form-row">
597
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
598
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
599
+ <input type="hidden" id="node-input-inferenceOutputPathType">
600
+ </div>
601
+ </div>
602
+ </div>
603
+ </details>
533
604
  </script>
534
605
 
535
606
  <!-- 3 ▸ Help panel -->
@@ -173,6 +173,31 @@ module.exports = function (RED) {
173
173
 
174
174
  NodeUtils.recordPerformanceMetrics(node, msg, timing, totalTime);
175
175
 
176
+ // --- Inference Transform ---
177
+ if (config.inferenceEnabled === true || config.inferenceEnabled === 'true') {
178
+ try {
179
+ const InfTx = require('../../lib/inference-transform.js');
180
+ const infPath = config.inferencePath || 'inference';
181
+ const infPathType = config.inferencePathType || 'msg';
182
+ const infOutPath = config.inferenceOutputPath || 'inference';
183
+ const infOutPathType = config.inferenceOutputPathType || 'msg';
184
+ const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
185
+
186
+ if (inferences && Array.isArray(inferences) && inferences.length > 0) {
187
+ const imageDims = imageArray.map(img => ({ width: img.width, height: img.height }));
188
+ const transformMap = InfTx.makeMosaicTransform({
189
+ positions: validPositions,
190
+ canvasW: canvasWidth, canvasH: canvasHeight,
191
+ imageDims, normalized
192
+ });
193
+ const transformed = await InfTx.applyMultiImageTransform(inferences, transformMap, CppProcessor);
194
+ NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
195
+ }
196
+ } catch (infErr) {
197
+ node.warn(`Inference transform: ${infErr.message}`);
198
+ }
199
+ }
200
+
176
201
  send(msg);
177
202
  done && done();
178
203
  } catch (err) {
@@ -29,7 +29,11 @@
29
29
  cropX:{value:"0"}, cropXType:{value:"num"},
30
30
  cropY:{value:"0"}, cropYType:{value:"num"},
31
31
  width:{value:"1"}, widthType:{value:"num"},
32
- height:{value:"1"}, heightType:{value:"num"}
32
+ height:{value:"1"}, heightType:{value:"num"},
33
+ // Inference transform
34
+ inferenceEnabled:{value:false},
35
+ inferencePath:{value:"inference"}, inferencePathType:{value:"msg"},
36
+ inferenceOutputPath:{value:"inference"}, inferenceOutputPathType:{value:"msg"}
33
37
  },
34
38
 
35
39
  inputs:1, outputs:1,
@@ -111,6 +115,21 @@
111
115
  // Store debug state for runtime access
112
116
  $('#node-input-debugEnabled').data('debug-enabled', enabled);
113
117
  });
118
+
119
+ // === Inference Transform Logic ===
120
+ $("#node-input-inferencePath").typedInput({
121
+ default:'msg', types:['msg','flow','global'],
122
+ typeField:"#node-input-inferencePathType"
123
+ });
124
+ $("#node-input-inferenceOutputPath").typedInput({
125
+ default:'msg', types:['msg','flow','global'],
126
+ typeField:"#node-input-inferenceOutputPathType"
127
+ });
128
+ const infCb = $('#node-input-inferenceEnabled');
129
+ const infRows = $('#inference-config-rows');
130
+ function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
131
+ updateInfVis();
132
+ infCb.on('change', updateInfVis);
114
133
  }
115
134
  };
116
135
  RED.nodes.registerType('rp-crop', _rpNodeCfg);
@@ -295,9 +314,9 @@
295
314
  <input type="hidden" id="node-input-debugWidthType">
296
315
  <span style="margin-left: 10px; color: #666;">pixels</span>
297
316
  </div>
298
-
317
+
299
318
  <hr>
300
-
319
+
301
320
  <!-- CROP-SPECIFIC SECTION -->
302
321
  <div class="form-row">
303
322
  <label for="node-input-coordNorm"><i class="fa fa-percent"></i> Normalised</label>
@@ -341,6 +360,32 @@
341
360
  <li>All parameters support dynamic values from <code>msg</code>, <code>flow</code>, or <code>global</code> context.</li>
342
361
  </ul>
343
362
  </div>
363
+
364
+ <!-- Advanced Options -->
365
+ <details id="advanced-options" style="margin-top: 12px;">
366
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
367
+ <i class="fa fa-cog"></i> Advanced options
368
+ </summary>
369
+ <div style="margin-top: 8px;">
370
+ <div class="form-row">
371
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
372
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
373
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
374
+ </div>
375
+ <div id="inference-config-rows" style="display: none;">
376
+ <div class="form-row">
377
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
378
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
379
+ <input type="hidden" id="node-input-inferencePathType">
380
+ </div>
381
+ <div class="form-row">
382
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
383
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
384
+ <input type="hidden" id="node-input-inferenceOutputPathType">
385
+ </div>
386
+ </div>
387
+ </div>
388
+ </details>
344
389
  </script>
345
390
 
346
391
  <script type="text/x-red" data-template-name="crop">
@@ -411,9 +456,9 @@
411
456
  <input type="hidden" id="node-input-debugWidthType">
412
457
  <span style="margin-left: 10px; color: #666;">pixels</span>
413
458
  </div>
414
-
459
+
415
460
  <hr>
416
-
461
+
417
462
  <!-- CROP-SPECIFIC SECTION -->
418
463
  <div class="form-row">
419
464
  <label for="node-input-coordNorm"><i class="fa fa-percent"></i> Normalised</label>
@@ -457,6 +502,32 @@
457
502
  <li>All parameters support dynamic values from <code>msg</code>, <code>flow</code>, or <code>global</code> context.</li>
458
503
  </ul>
459
504
  </div>
505
+
506
+ <!-- Advanced Options -->
507
+ <details id="advanced-options" style="margin-top: 12px;">
508
+ <summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
509
+ <i class="fa fa-cog"></i> Advanced options
510
+ </summary>
511
+ <div style="margin-top: 8px;">
512
+ <div class="form-row">
513
+ <label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
514
+ <input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
515
+ <label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
516
+ </div>
517
+ <div id="inference-config-rows" style="display: none;">
518
+ <div class="form-row">
519
+ <label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
520
+ <input type="text" id="node-input-inferencePath" style="width:70%;">
521
+ <input type="hidden" id="node-input-inferencePathType">
522
+ </div>
523
+ <div class="form-row">
524
+ <label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
525
+ <input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
526
+ <input type="hidden" id="node-input-inferenceOutputPathType">
527
+ </div>
528
+ </div>
529
+ </div>
530
+ </details>
460
531
  </script>
461
532
 
462
533
  <!-- 3 ▸ Help panel -->
@@ -163,6 +163,37 @@ module.exports = function (RED) {
163
163
  taskMs: totalTaskMs
164
164
  }, dur);
165
165
 
166
+ // --- Inference Transform ---
167
+ if (config.inferenceEnabled === true || config.inferenceEnabled === 'true') {
168
+ try {
169
+ const InfTx = require('../../lib/inference-transform.js');
170
+ const infPath = config.inferencePath || 'inference';
171
+ const infPathType = config.inferencePathType || 'msg';
172
+ const infOutPath = config.inferenceOutputPath || 'inference';
173
+ const infOutPathType = config.inferenceOutputPathType || 'msg';
174
+ const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
175
+
176
+ if (inferences && Array.isArray(inferences) && inferences.length > 0) {
177
+ const origImg = imgs[0];
178
+ // Normalize crop coords to 0-1 if in pixel mode
179
+ let cx0, cy0, cw, ch;
180
+ if (normalized) {
181
+ cx0 = x; cy0 = y; cw = width; ch = height;
182
+ } else {
183
+ cx0 = x / origImg.width;
184
+ cy0 = y / origImg.height;
185
+ cw = width / origImg.width;
186
+ ch = height / origImg.height;
187
+ }
188
+ const txInfo = InfTx.makeCropTransform({ x0: cx0, y0: cy0, w: cw, h: ch });
189
+ const transformed = await InfTx.applyTransform(inferences, txInfo, CppProcessor);
190
+ NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
191
+ }
192
+ } catch (infErr) {
193
+ node.warn(`Inference transform: ${infErr.message}`);
194
+ }
195
+ }
196
+
166
197
  send(msg);
167
198
  done && done();
168
199
  } catch (err) {