@rosepetal/node-red-contrib-image-tools 1.3.2 → 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.
- package/node-red-contrib-image-tools/lib/inference-transform.js +626 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +6 -10
- package/node-red-contrib-image-tools/nodes/io/image-out.js +0 -1
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +72 -1
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +25 -0
- package/node-red-contrib-image-tools/nodes/mix/concat.html +74 -3
- package/node-red-contrib-image-tools/nodes/mix/concat.js +23 -0
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +72 -1
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +25 -0
- package/node-red-contrib-image-tools/nodes/transform/crop.html +76 -5
- package/node-red-contrib-image-tools/nodes/transform/crop.js +31 -0
- package/node-red-contrib-image-tools/nodes/transform/padding.html +76 -5
- package/node-red-contrib-image-tools/nodes/transform/padding.js +24 -0
- package/node-red-contrib-image-tools/nodes/transform/resize.html +76 -3
- package/node-red-contrib-image-tools/nodes/transform/resize.js +30 -0
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +76 -3
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +25 -0
- package/package.json +2 -35
- package/rosepetal-image-engine/src/add-bbs.cpp +13 -5
- package/scripts/dual-register.js +0 -30
|
@@ -28,7 +28,11 @@
|
|
|
28
28
|
right :{value:"0"}, rightType :{value:"num"},
|
|
29
29
|
|
|
30
30
|
/* colour */
|
|
31
|
-
padColor:{value:"#000000"}
|
|
31
|
+
padColor:{value:"#000000"},
|
|
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
|
inputs:1, outputs:1,
|
|
34
38
|
label:function(){ return this.name || "rp-padding"; },
|
|
@@ -97,6 +101,21 @@
|
|
|
97
101
|
// Store debug state for runtime access
|
|
98
102
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
99
103
|
});
|
|
104
|
+
|
|
105
|
+
// === Inference Transform Logic ===
|
|
106
|
+
$("#node-input-inferencePath").typedInput({
|
|
107
|
+
default:'msg', types:['msg','flow','global'],
|
|
108
|
+
typeField:"#node-input-inferencePathType"
|
|
109
|
+
});
|
|
110
|
+
$("#node-input-inferenceOutputPath").typedInput({
|
|
111
|
+
default:'msg', types:['msg','flow','global'],
|
|
112
|
+
typeField:"#node-input-inferenceOutputPathType"
|
|
113
|
+
});
|
|
114
|
+
const infCb = $('#node-input-inferenceEnabled');
|
|
115
|
+
const infRows = $('#inference-config-rows');
|
|
116
|
+
function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
|
|
117
|
+
updateInfVis();
|
|
118
|
+
infCb.on('change', updateInfVis);
|
|
100
119
|
}
|
|
101
120
|
};
|
|
102
121
|
RED.nodes.registerType('rp-padding', _rpNodeCfg);
|
|
@@ -278,9 +297,9 @@
|
|
|
278
297
|
<input type="hidden" id="node-input-debugWidthType">
|
|
279
298
|
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
280
299
|
</div>
|
|
281
|
-
|
|
300
|
+
|
|
282
301
|
<hr>
|
|
283
|
-
|
|
302
|
+
|
|
284
303
|
<strong>Margins (pixels)</strong>
|
|
285
304
|
<div class="form-row">
|
|
286
305
|
<label>Top</label>
|
|
@@ -307,6 +326,32 @@
|
|
|
307
326
|
<label for="node-input-padColor"><i class="fa fa-tint"></i> Colour</label>
|
|
308
327
|
<input type="color" id="node-input-padColor" style="width:80px;">
|
|
309
328
|
</div>
|
|
329
|
+
|
|
330
|
+
<!-- Advanced Options -->
|
|
331
|
+
<details id="advanced-options" style="margin-top: 12px;">
|
|
332
|
+
<summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
|
|
333
|
+
<i class="fa fa-cog"></i> Advanced options
|
|
334
|
+
</summary>
|
|
335
|
+
<div style="margin-top: 8px;">
|
|
336
|
+
<div class="form-row">
|
|
337
|
+
<label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
|
|
338
|
+
<input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
339
|
+
<label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
|
|
340
|
+
</div>
|
|
341
|
+
<div id="inference-config-rows" style="display: none;">
|
|
342
|
+
<div class="form-row">
|
|
343
|
+
<label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
|
|
344
|
+
<input type="text" id="node-input-inferencePath" style="width:70%;">
|
|
345
|
+
<input type="hidden" id="node-input-inferencePathType">
|
|
346
|
+
</div>
|
|
347
|
+
<div class="form-row">
|
|
348
|
+
<label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
|
|
349
|
+
<input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
|
|
350
|
+
<input type="hidden" id="node-input-inferenceOutputPathType">
|
|
351
|
+
</div>
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
</details>
|
|
310
355
|
</script>
|
|
311
356
|
|
|
312
357
|
<script type="text/x-red" data-template-name="padding">
|
|
@@ -374,9 +419,9 @@
|
|
|
374
419
|
<input type="hidden" id="node-input-debugWidthType">
|
|
375
420
|
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
376
421
|
</div>
|
|
377
|
-
|
|
422
|
+
|
|
378
423
|
<hr>
|
|
379
|
-
|
|
424
|
+
|
|
380
425
|
<strong>Margins (pixels)</strong>
|
|
381
426
|
<div class="form-row">
|
|
382
427
|
<label>Top</label>
|
|
@@ -403,6 +448,32 @@
|
|
|
403
448
|
<label for="node-input-padColor"><i class="fa fa-tint"></i> Colour</label>
|
|
404
449
|
<input type="color" id="node-input-padColor" style="width:80px;">
|
|
405
450
|
</div>
|
|
451
|
+
|
|
452
|
+
<!-- Advanced Options -->
|
|
453
|
+
<details id="advanced-options" style="margin-top: 12px;">
|
|
454
|
+
<summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
|
|
455
|
+
<i class="fa fa-cog"></i> Advanced options
|
|
456
|
+
</summary>
|
|
457
|
+
<div style="margin-top: 8px;">
|
|
458
|
+
<div class="form-row">
|
|
459
|
+
<label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
|
|
460
|
+
<input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
461
|
+
<label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
|
|
462
|
+
</div>
|
|
463
|
+
<div id="inference-config-rows" style="display: none;">
|
|
464
|
+
<div class="form-row">
|
|
465
|
+
<label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
|
|
466
|
+
<input type="text" id="node-input-inferencePath" style="width:70%;">
|
|
467
|
+
<input type="hidden" id="node-input-inferencePathType">
|
|
468
|
+
</div>
|
|
469
|
+
<div class="form-row">
|
|
470
|
+
<label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
|
|
471
|
+
<input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
|
|
472
|
+
<input type="hidden" id="node-input-inferenceOutputPathType">
|
|
473
|
+
</div>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
</details>
|
|
406
477
|
</script>
|
|
407
478
|
|
|
408
479
|
<!-- 3 ▸ Help panel --------------------------------------------------------->
|
|
@@ -157,6 +157,30 @@ module.exports = function (RED) {
|
|
|
157
157
|
taskMs: tMs
|
|
158
158
|
}, elapsedTime);
|
|
159
159
|
|
|
160
|
+
// --- Inference Transform ---
|
|
161
|
+
if (cfg.inferenceEnabled === true || cfg.inferenceEnabled === 'true') {
|
|
162
|
+
try {
|
|
163
|
+
const InfTx = require('../../lib/inference-transform.js');
|
|
164
|
+
const infPath = cfg.inferencePath || 'inference';
|
|
165
|
+
const infPathType = cfg.inferencePathType || 'msg';
|
|
166
|
+
const infOutPath = cfg.inferenceOutputPath || 'inference';
|
|
167
|
+
const infOutPathType = cfg.inferenceOutputPathType || 'msg';
|
|
168
|
+
const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
|
|
169
|
+
|
|
170
|
+
if (inferences && Array.isArray(inferences) && inferences.length > 0) {
|
|
171
|
+
const origImg = imgs[0];
|
|
172
|
+
const txInfo = InfTx.makePaddingTransform({
|
|
173
|
+
top: tVal, bottom: bVal, left: lVal, right: rVal,
|
|
174
|
+
origW: origImg.width, origH: origImg.height
|
|
175
|
+
});
|
|
176
|
+
const transformed = await InfTx.applyTransform(inferences, txInfo, CppProcessor);
|
|
177
|
+
NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
|
|
178
|
+
}
|
|
179
|
+
} catch (infErr) {
|
|
180
|
+
node.warn(`Inference transform: ${infErr.message}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
160
184
|
send(msg); done && done();
|
|
161
185
|
} catch (err) {
|
|
162
186
|
NodeUtils.handleNodeErrorWithPassthrough(
|
|
@@ -26,7 +26,13 @@
|
|
|
26
26
|
// Propiedades para la configuración del Alto (Height)
|
|
27
27
|
heightMode: { value: "set" },
|
|
28
28
|
heightValue: { value: "" },
|
|
29
|
-
heightType: { value: "num" } // Tipo para el TypedInput
|
|
29
|
+
heightType: { value: "num" }, // Tipo para el TypedInput
|
|
30
|
+
// Inference transform
|
|
31
|
+
inferenceEnabled: { value: false },
|
|
32
|
+
inferencePath: { value: "inference" },
|
|
33
|
+
inferencePathType: { value: "msg" },
|
|
34
|
+
inferenceOutputPath: { value: "inference" },
|
|
35
|
+
inferenceOutputPathType: { value: "msg" }
|
|
30
36
|
},
|
|
31
37
|
inputs: 1,
|
|
32
38
|
outputs: 1,
|
|
@@ -154,6 +160,21 @@
|
|
|
154
160
|
// Store debug state for runtime access
|
|
155
161
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
156
162
|
});
|
|
163
|
+
|
|
164
|
+
// === Inference Transform Logic ===
|
|
165
|
+
$("#node-input-inferencePath").typedInput({
|
|
166
|
+
default:'msg', types:['msg','flow','global'],
|
|
167
|
+
typeField:"#node-input-inferencePathType"
|
|
168
|
+
});
|
|
169
|
+
$("#node-input-inferenceOutputPath").typedInput({
|
|
170
|
+
default:'msg', types:['msg','flow','global'],
|
|
171
|
+
typeField:"#node-input-inferenceOutputPathType"
|
|
172
|
+
});
|
|
173
|
+
const infCb = $('#node-input-inferenceEnabled');
|
|
174
|
+
const infRows = $('#inference-config-rows');
|
|
175
|
+
function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
|
|
176
|
+
updateInfVis();
|
|
177
|
+
infCb.on('change', updateInfVis);
|
|
157
178
|
}
|
|
158
179
|
};
|
|
159
180
|
RED.nodes.registerType('rp-resize', _rpNodeCfg);
|
|
@@ -348,7 +369,7 @@
|
|
|
348
369
|
<input type="hidden" id="node-input-debugWidthType">
|
|
349
370
|
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
350
371
|
</div>
|
|
351
|
-
|
|
372
|
+
|
|
352
373
|
<hr>
|
|
353
374
|
|
|
354
375
|
<div class="form-row">
|
|
@@ -377,6 +398,32 @@
|
|
|
377
398
|
<div class="form-tips">
|
|
378
399
|
<b>Tip:</b> If a dimension value is left empty, it will be set to 'Auto' to maintain the original aspect ratio.
|
|
379
400
|
</div>
|
|
401
|
+
|
|
402
|
+
<!-- Advanced Options -->
|
|
403
|
+
<details id="advanced-options" style="margin-top: 12px;">
|
|
404
|
+
<summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
|
|
405
|
+
<i class="fa fa-cog"></i> Advanced options
|
|
406
|
+
</summary>
|
|
407
|
+
<div style="margin-top: 8px;">
|
|
408
|
+
<div class="form-row">
|
|
409
|
+
<label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
|
|
410
|
+
<input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
411
|
+
<label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
|
|
412
|
+
</div>
|
|
413
|
+
<div id="inference-config-rows" style="display: none;">
|
|
414
|
+
<div class="form-row">
|
|
415
|
+
<label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
|
|
416
|
+
<input type="text" id="node-input-inferencePath" style="width:70%;">
|
|
417
|
+
<input type="hidden" id="node-input-inferencePathType">
|
|
418
|
+
</div>
|
|
419
|
+
<div class="form-row">
|
|
420
|
+
<label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
|
|
421
|
+
<input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
|
|
422
|
+
<input type="hidden" id="node-input-inferenceOutputPathType">
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
</details>
|
|
380
427
|
</script>
|
|
381
428
|
|
|
382
429
|
<script type="text/x-red" data-template-name="resize">
|
|
@@ -445,7 +492,7 @@
|
|
|
445
492
|
<input type="hidden" id="node-input-debugWidthType">
|
|
446
493
|
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
447
494
|
</div>
|
|
448
|
-
|
|
495
|
+
|
|
449
496
|
<hr>
|
|
450
497
|
|
|
451
498
|
<div class="form-row">
|
|
@@ -474,6 +521,32 @@
|
|
|
474
521
|
<div class="form-tips">
|
|
475
522
|
<b>Tip:</b> If a dimension value is left empty, it will be set to 'Auto' to maintain the original aspect ratio.
|
|
476
523
|
</div>
|
|
524
|
+
|
|
525
|
+
<!-- Advanced Options -->
|
|
526
|
+
<details id="advanced-options" style="margin-top: 12px;">
|
|
527
|
+
<summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
|
|
528
|
+
<i class="fa fa-cog"></i> Advanced options
|
|
529
|
+
</summary>
|
|
530
|
+
<div style="margin-top: 8px;">
|
|
531
|
+
<div class="form-row">
|
|
532
|
+
<label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
|
|
533
|
+
<input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
534
|
+
<label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
|
|
535
|
+
</div>
|
|
536
|
+
<div id="inference-config-rows" style="display: none;">
|
|
537
|
+
<div class="form-row">
|
|
538
|
+
<label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
|
|
539
|
+
<input type="text" id="node-input-inferencePath" style="width:70%;">
|
|
540
|
+
<input type="hidden" id="node-input-inferencePathType">
|
|
541
|
+
</div>
|
|
542
|
+
<div class="form-row">
|
|
543
|
+
<label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
|
|
544
|
+
<input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
|
|
545
|
+
<input type="hidden" id="node-input-inferenceOutputPathType">
|
|
546
|
+
</div>
|
|
547
|
+
</div>
|
|
548
|
+
</div>
|
|
549
|
+
</details>
|
|
477
550
|
</script>
|
|
478
551
|
|
|
479
552
|
<script type="text/x-red" data-help-name="rp-resize">
|
|
@@ -180,6 +180,36 @@ module.exports = function (RED) {
|
|
|
180
180
|
|
|
181
181
|
NodeUtils.setOutputValue(node, msg, outputPath, outputPathType, out);
|
|
182
182
|
|
|
183
|
+
// --- Inference Transform ---
|
|
184
|
+
// For resize, normalized coords are invariant (identity transform).
|
|
185
|
+
// Only bitmap masks would need resizing, but we pass through coords unchanged.
|
|
186
|
+
if (config.inferenceEnabled === true || config.inferenceEnabled === 'true') {
|
|
187
|
+
try {
|
|
188
|
+
const InfTx = require('../../lib/inference-transform.js');
|
|
189
|
+
const infPath = config.inferencePath || 'inference';
|
|
190
|
+
const infPathType = config.inferencePathType || 'msg';
|
|
191
|
+
const infOutPath = config.inferenceOutputPath || 'inference';
|
|
192
|
+
const infOutPathType = config.inferenceOutputPathType || 'msg';
|
|
193
|
+
const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
|
|
194
|
+
|
|
195
|
+
if (inferences && Array.isArray(inferences) && inferences.length > 0) {
|
|
196
|
+
const origImg = inputList[0];
|
|
197
|
+
// Try to get output dims from raw result; fall back to input dims
|
|
198
|
+
const rawResult = results[0] && results[0].image;
|
|
199
|
+
const newW = (rawResult && rawResult.width) || origImg.width;
|
|
200
|
+
const newH = (rawResult && rawResult.height) || origImg.height;
|
|
201
|
+
const txInfo = InfTx.makeResizeTransform({
|
|
202
|
+
origW: origImg.width, origH: origImg.height,
|
|
203
|
+
newW, newH
|
|
204
|
+
});
|
|
205
|
+
const transformed = await InfTx.applyTransform(inferences, txInfo, CppProcessor);
|
|
206
|
+
NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
|
|
207
|
+
}
|
|
208
|
+
} catch (infErr) {
|
|
209
|
+
node.warn(`Inference transform: ${infErr.message}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
183
213
|
send(msg);
|
|
184
214
|
done && done();
|
|
185
215
|
} catch (err) {
|
|
@@ -20,7 +20,13 @@
|
|
|
20
20
|
debugWidthType : { value:"num" },
|
|
21
21
|
angleValue : { value:"90" },
|
|
22
22
|
angleType : { value:"num" },
|
|
23
|
-
padColor : { value:"#000000" } // siempre visible
|
|
23
|
+
padColor : { value:"#000000" }, // siempre visible
|
|
24
|
+
// Inference transform
|
|
25
|
+
inferenceEnabled : { value:false },
|
|
26
|
+
inferencePath : { value:"inference" },
|
|
27
|
+
inferencePathType : { value:"msg" },
|
|
28
|
+
inferenceOutputPath : { value:"inference" },
|
|
29
|
+
inferenceOutputPathType : { value:"msg" }
|
|
24
30
|
},
|
|
25
31
|
inputs :1, outputs:1,
|
|
26
32
|
icon:"font-awesome/fa-rotate-right",
|
|
@@ -75,6 +81,21 @@
|
|
|
75
81
|
// Store debug state for runtime access
|
|
76
82
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
77
83
|
});
|
|
84
|
+
|
|
85
|
+
// === Inference Transform Logic ===
|
|
86
|
+
$("#node-input-inferencePath").typedInput({
|
|
87
|
+
default:'msg', types:['msg','flow','global'],
|
|
88
|
+
typeField:"#node-input-inferencePathType"
|
|
89
|
+
});
|
|
90
|
+
$("#node-input-inferenceOutputPath").typedInput({
|
|
91
|
+
default:'msg', types:['msg','flow','global'],
|
|
92
|
+
typeField:"#node-input-inferenceOutputPathType"
|
|
93
|
+
});
|
|
94
|
+
const infCb = $('#node-input-inferenceEnabled');
|
|
95
|
+
const infRows = $('#inference-config-rows');
|
|
96
|
+
function updateInfVis(){ infRows.toggle(infCb.is(':checked')); }
|
|
97
|
+
updateInfVis();
|
|
98
|
+
infCb.on('change', updateInfVis);
|
|
78
99
|
}
|
|
79
100
|
};
|
|
80
101
|
RED.nodes.registerType('rp-rotate', _rpNodeCfg);
|
|
@@ -242,10 +263,36 @@
|
|
|
242
263
|
<input type="hidden" id="node-input-debugWidthType">
|
|
243
264
|
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
244
265
|
</div>
|
|
245
|
-
|
|
266
|
+
|
|
246
267
|
<hr>
|
|
247
268
|
<div class="form-row"><label for="node-input-angleValue"><i class="fa fa-refresh"></i> Angle (°)</label><input type="text" id="node-input-angleValue" style="width:70%;"><input type="hidden" id="node-input-angleType"></div>
|
|
248
269
|
<div class="form-row"><label for="node-input-padColor"><i class="fa fa-tint"></i> Pad colour</label><input type="color" id="node-input-padColor" style="width:80px;"></div>
|
|
270
|
+
|
|
271
|
+
<!-- Advanced Options -->
|
|
272
|
+
<details id="advanced-options" style="margin-top: 12px;">
|
|
273
|
+
<summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
|
|
274
|
+
<i class="fa fa-cog"></i> Advanced options
|
|
275
|
+
</summary>
|
|
276
|
+
<div style="margin-top: 8px;">
|
|
277
|
+
<div class="form-row">
|
|
278
|
+
<label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
|
|
279
|
+
<input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
280
|
+
<label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
|
|
281
|
+
</div>
|
|
282
|
+
<div id="inference-config-rows" style="display: none;">
|
|
283
|
+
<div class="form-row">
|
|
284
|
+
<label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
|
|
285
|
+
<input type="text" id="node-input-inferencePath" style="width:70%;">
|
|
286
|
+
<input type="hidden" id="node-input-inferencePathType">
|
|
287
|
+
</div>
|
|
288
|
+
<div class="form-row">
|
|
289
|
+
<label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
|
|
290
|
+
<input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
|
|
291
|
+
<input type="hidden" id="node-input-inferenceOutputPathType">
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</details>
|
|
249
296
|
</script>
|
|
250
297
|
|
|
251
298
|
<script type="text/x-red" data-template-name="rotate">
|
|
@@ -300,10 +347,36 @@
|
|
|
300
347
|
<input type="hidden" id="node-input-debugWidthType">
|
|
301
348
|
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
302
349
|
</div>
|
|
303
|
-
|
|
350
|
+
|
|
304
351
|
<hr>
|
|
305
352
|
<div class="form-row"><label for="node-input-angleValue"><i class="fa fa-refresh"></i> Angle (°)</label><input type="text" id="node-input-angleValue" style="width:70%;"><input type="hidden" id="node-input-angleType"></div>
|
|
306
353
|
<div class="form-row"><label for="node-input-padColor"><i class="fa fa-tint"></i> Pad colour</label><input type="color" id="node-input-padColor" style="width:80px;"></div>
|
|
354
|
+
|
|
355
|
+
<!-- Advanced Options -->
|
|
356
|
+
<details id="advanced-options" style="margin-top: 12px;">
|
|
357
|
+
<summary style="cursor: pointer; font-weight: bold; padding: 4px 0;">
|
|
358
|
+
<i class="fa fa-cog"></i> Advanced options
|
|
359
|
+
</summary>
|
|
360
|
+
<div style="margin-top: 8px;">
|
|
361
|
+
<div class="form-row">
|
|
362
|
+
<label for="node-input-inferenceEnabled"><i class="fa fa-crosshairs"></i> Inference</label>
|
|
363
|
+
<input type="checkbox" id="node-input-inferenceEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
364
|
+
<label for="node-input-inferenceEnabled" style="width:auto; margin-left:5px;">Transform inference coordinates</label>
|
|
365
|
+
</div>
|
|
366
|
+
<div id="inference-config-rows" style="display: none;">
|
|
367
|
+
<div class="form-row">
|
|
368
|
+
<label for="node-input-inferencePath"><i class="fa fa-sign-in"></i> Inf. Input</label>
|
|
369
|
+
<input type="text" id="node-input-inferencePath" style="width:70%;">
|
|
370
|
+
<input type="hidden" id="node-input-inferencePathType">
|
|
371
|
+
</div>
|
|
372
|
+
<div class="form-row">
|
|
373
|
+
<label for="node-input-inferenceOutputPath"><i class="fa fa-sign-out"></i> Inf. Output</label>
|
|
374
|
+
<input type="text" id="node-input-inferenceOutputPath" style="width:70%;">
|
|
375
|
+
<input type="hidden" id="node-input-inferenceOutputPathType">
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
</details>
|
|
307
380
|
</script>
|
|
308
381
|
|
|
309
382
|
<script type="text/x-red" data-help-name="rp-rotate">
|
|
@@ -154,6 +154,31 @@ module.exports = function (RED) {
|
|
|
154
154
|
taskMs: totalTaskMs
|
|
155
155
|
}, durMs);
|
|
156
156
|
|
|
157
|
+
// --- Inference Transform ---
|
|
158
|
+
if (config.inferenceEnabled === true || config.inferenceEnabled === 'true') {
|
|
159
|
+
try {
|
|
160
|
+
const InfTx = require('../../lib/inference-transform.js');
|
|
161
|
+
const infPath = config.inferencePath || 'inference';
|
|
162
|
+
const infPathType = config.inferencePathType || 'msg';
|
|
163
|
+
const infOutPath = config.inferenceOutputPath || 'inference';
|
|
164
|
+
const infOutPathType = config.inferenceOutputPathType || 'msg';
|
|
165
|
+
const { value: inferences } = NodeUtils.getInputValue(node, msg, infPath, infPathType);
|
|
166
|
+
|
|
167
|
+
if (inferences && Array.isArray(inferences) && inferences.length > 0) {
|
|
168
|
+
const origImg = imgs[0];
|
|
169
|
+
const txInfo = InfTx.makeRotateTransform({
|
|
170
|
+
angleDeg: angle,
|
|
171
|
+
origW: origImg.width,
|
|
172
|
+
origH: origImg.height
|
|
173
|
+
});
|
|
174
|
+
const transformed = await InfTx.applyTransform(inferences, txInfo, CppProcessor);
|
|
175
|
+
NodeUtils.setOutputValue(node, msg, infOutPath, infOutPathType, transformed);
|
|
176
|
+
}
|
|
177
|
+
} catch (infErr) {
|
|
178
|
+
node.warn(`Inference transform: ${infErr.message}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
157
182
|
send(msg);
|
|
158
183
|
done && done();
|
|
159
184
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosepetal/node-red-contrib-image-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Node-RED Image Processing Toolkit",
|
|
5
5
|
"main": "install.sh",
|
|
6
6
|
"directories": {
|
|
@@ -47,9 +47,6 @@
|
|
|
47
47
|
"rp-image-in": "node-red-contrib-image-tools/nodes/io/image-in.js",
|
|
48
48
|
"rp-folder-in": "node-red-contrib-image-tools/nodes/io/folder-in.js",
|
|
49
49
|
"rp-image-out": "node-red-contrib-image-tools/nodes/io/image-out.js",
|
|
50
|
-
"rp-array-in": "node-red-contrib-image-tools/nodes/io/array-in.js",
|
|
51
|
-
"rp-array-out": "node-red-contrib-image-tools/nodes/io/array-out.js",
|
|
52
|
-
"rp-array-select": "node-red-contrib-image-tools/nodes/io/array-select.js",
|
|
53
50
|
"rp-cropBB": "node-red-contrib-image-tools/nodes/specialized/cropBB.js",
|
|
54
51
|
"rp-image-align": "node-red-contrib-image-tools/nodes/specialized/image-align.js",
|
|
55
52
|
"rp-resize": "node-red-contrib-image-tools/nodes/transform/resize.js",
|
|
@@ -65,37 +62,7 @@
|
|
|
65
62
|
"rp-blend": "node-red-contrib-image-tools/nodes/blend/blend.js",
|
|
66
63
|
"rp-add-mask": "node-red-contrib-image-tools/nodes/blend/add-mask.js",
|
|
67
64
|
"rp-add-masks": "node-red-contrib-image-tools/nodes/blend/add-masks.js",
|
|
68
|
-
"rp-add-bbs": "node-red-contrib-image-tools/nodes/blend/add-bbs.js"
|
|
69
|
-
"rp-queue": "node-red-contrib-image-tools/nodes/io/queue.js",
|
|
70
|
-
"rp-save-file": "node-red-contrib-image-tools/nodes/io/save-file.js",
|
|
71
|
-
"rp-clean-debug": "node-red-contrib-image-tools/nodes/util/clean-debug.js",
|
|
72
|
-
"rp-block-detect": "node-red-contrib-image-tools/nodes/util/block-detect.js",
|
|
73
|
-
"image-in": "node-red-contrib-image-tools/nodes/io/image-in.js",
|
|
74
|
-
"folder-in": "node-red-contrib-image-tools/nodes/io/folder-in.js",
|
|
75
|
-
"image-out": "node-red-contrib-image-tools/nodes/io/image-out.js",
|
|
76
|
-
"array-in": "node-red-contrib-image-tools/nodes/io/array-in.js",
|
|
77
|
-
"array-out": "node-red-contrib-image-tools/nodes/io/array-out.js",
|
|
78
|
-
"array-select": "node-red-contrib-image-tools/nodes/io/array-select.js",
|
|
79
|
-
"cropBB": "node-red-contrib-image-tools/nodes/specialized/cropBB.js",
|
|
80
|
-
"image-align": "node-red-contrib-image-tools/nodes/specialized/image-align.js",
|
|
81
|
-
"resize": "node-red-contrib-image-tools/nodes/transform/resize.js",
|
|
82
|
-
"rotate": "node-red-contrib-image-tools/nodes/transform/rotate.js",
|
|
83
|
-
"crop": "node-red-contrib-image-tools/nodes/transform/crop.js",
|
|
84
|
-
"concat": "node-red-contrib-image-tools/nodes/mix/concat.js",
|
|
85
|
-
"padding": "node-red-contrib-image-tools/nodes/transform/padding.js",
|
|
86
|
-
"filter": "node-red-contrib-image-tools/nodes/transform/filter.js",
|
|
87
|
-
"draw": "node-red-contrib-image-tools/nodes/transform/draw.js",
|
|
88
|
-
"color-convert": "node-red-contrib-image-tools/nodes/transform/color-convert.js",
|
|
89
|
-
"mosaic": "node-red-contrib-image-tools/nodes/mix/mosaic.js",
|
|
90
|
-
"advanced-mosaic": "node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js",
|
|
91
|
-
"blend": "node-red-contrib-image-tools/nodes/blend/blend.js",
|
|
92
|
-
"add-mask": "node-red-contrib-image-tools/nodes/blend/add-mask.js",
|
|
93
|
-
"add-masks": "node-red-contrib-image-tools/nodes/blend/add-masks.js",
|
|
94
|
-
"add-bbs": "node-red-contrib-image-tools/nodes/blend/add-bbs.js",
|
|
95
|
-
"queue": "node-red-contrib-image-tools/nodes/io/queue.js",
|
|
96
|
-
"save-file": "node-red-contrib-image-tools/nodes/io/save-file.js",
|
|
97
|
-
"clean-debug": "node-red-contrib-image-tools/nodes/util/clean-debug.js",
|
|
98
|
-
"block-detect": "node-red-contrib-image-tools/nodes/util/block-detect.js"
|
|
65
|
+
"rp-add-bbs": "node-red-contrib-image-tools/nodes/blend/add-bbs.js"
|
|
99
66
|
}
|
|
100
67
|
}
|
|
101
68
|
}
|
|
@@ -197,12 +197,20 @@ public:
|
|
|
197
197
|
color[2] * 255.0f // R
|
|
198
198
|
);
|
|
199
199
|
|
|
200
|
-
// Convert normalized coordinates to pixels
|
|
200
|
+
// Convert normalized coordinates to pixels (supports rotated boxes)
|
|
201
|
+
float minX = corners[0].x, maxX = corners[0].x;
|
|
202
|
+
float minY = corners[0].y, maxY = corners[0].y;
|
|
203
|
+
for (int i = 1; i < 4; i++) {
|
|
204
|
+
minX = std::min(minX, corners[i].x);
|
|
205
|
+
maxX = std::max(maxX, corners[i].x);
|
|
206
|
+
minY = std::min(minY, corners[i].y);
|
|
207
|
+
maxY = std::max(maxY, corners[i].y);
|
|
208
|
+
}
|
|
201
209
|
cv::Rect bbox;
|
|
202
|
-
bbox.x = static_cast<int>(
|
|
203
|
-
bbox.y = static_cast<int>(
|
|
204
|
-
bbox.width = static_cast<int>((
|
|
205
|
-
bbox.height = static_cast<int>((
|
|
210
|
+
bbox.x = static_cast<int>(minX * imageMat.cols);
|
|
211
|
+
bbox.y = static_cast<int>(minY * imageMat.rows);
|
|
212
|
+
bbox.width = static_cast<int>((maxX - minX) * imageMat.cols);
|
|
213
|
+
bbox.height = static_cast<int>((maxY - minY) * imageMat.rows);
|
|
206
214
|
|
|
207
215
|
// Clamp to image bounds
|
|
208
216
|
bbox.x = std::max(0, std::min(imageMat.cols - 1, bbox.x));
|
package/scripts/dual-register.js
CHANGED
|
@@ -260,36 +260,6 @@ for (const node of NODES) {
|
|
|
260
260
|
console.log('');
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
// ─────────────────────────────────────────────────────────────
|
|
264
|
-
// Add legacy keys to package.json files (so Node-RED can find legacy types)
|
|
265
|
-
// ─────────────────────────────────────────────────────────────
|
|
266
|
-
|
|
267
|
-
function addLegacyPackageJsonKeys(pkgPath) {
|
|
268
|
-
if (!fs.existsSync(pkgPath)) return;
|
|
269
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
270
|
-
const nodes = pkg['node-red'] && pkg['node-red'].nodes;
|
|
271
|
-
if (!nodes) return;
|
|
272
|
-
|
|
273
|
-
let added = 0;
|
|
274
|
-
for (const [key, value] of Object.entries(nodes)) {
|
|
275
|
-
if (key.startsWith('rp-')) {
|
|
276
|
-
const oldKey = key.replace(/^rp-/, '');
|
|
277
|
-
if (!nodes[oldKey]) {
|
|
278
|
-
nodes[oldKey] = value;
|
|
279
|
-
added++;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (added > 0) {
|
|
285
|
-
if (!DRY_RUN) fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 4) + '\n');
|
|
286
|
-
console.log(` package.json: ✓ Added ${added} legacy keys (${path.basename(path.dirname(pkgPath))})`);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
console.log('[package.json]');
|
|
291
|
-
addLegacyPackageJsonKeys(path.join(__dirname, '..', 'package.json'));
|
|
292
|
-
|
|
293
263
|
console.log('\n=== Summary ===');
|
|
294
264
|
console.log(` JS: ${jsOk} ok, ${jsFail} failed`);
|
|
295
265
|
console.log(` HTML: ${htmlOk} ok, ${htmlFail} failed`);
|