@rosepetal/node-red-contrib-image-tools 1.2.2 → 1.3.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/.github/workflows/build-prebuild.yml +3 -0
- package/install.sh +8 -0
- package/node-red-contrib-image-tools/lib/node-utils.js +64 -0
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +242 -3
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +10 -3
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +282 -4
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +15 -8
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +206 -3
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +10 -3
- package/node-red-contrib-image-tools/nodes/blend/blend.html +332 -4
- package/node-red-contrib-image-tools/nodes/blend/blend.js +10 -3
- package/node-red-contrib-image-tools/nodes/io/folder-in.html +147 -3
- package/node-red-contrib-image-tools/nodes/io/folder-in.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/image-in.html +81 -2
- package/node-red-contrib-image-tools/nodes/io/image-in.js +2 -1
- package/node-red-contrib-image-tools/nodes/io/image-out.html +197 -3
- package/node-red-contrib-image-tools/nodes/io/image-out.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +398 -3
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +11 -4
- package/node-red-contrib-image-tools/nodes/mix/concat.html +245 -5
- package/node-red-contrib-image-tools/nodes/mix/concat.js +10 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +307 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +10 -3
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +217 -4
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +11 -2
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +285 -4
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +9 -2
- package/node-red-contrib-image-tools/nodes/transform/color-convert.html +169 -6
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/crop.html +237 -5
- package/node-red-contrib-image-tools/nodes/transform/crop.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/draw.html +152 -3
- package/node-red-contrib-image-tools/nodes/transform/draw.js +10 -3
- package/node-red-contrib-image-tools/nodes/transform/filter.html +369 -4
- package/node-red-contrib-image-tools/nodes/transform/filter.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/padding.html +316 -5
- package/node-red-contrib-image-tools/nodes/transform/padding.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/resize.html +203 -5
- package/node-red-contrib-image-tools/nodes/transform/resize.js +11 -2
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +164 -5
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +11 -2
- package/package.json +71 -71
- package/scripts/dual-register.js +267 -0
package/install.sh
CHANGED
|
@@ -116,6 +116,14 @@ main() {
|
|
|
116
116
|
exit 1
|
|
117
117
|
fi
|
|
118
118
|
|
|
119
|
+
print_step "Adding legacy node type compatibility..."
|
|
120
|
+
cd "$SCRIPT_DIR"
|
|
121
|
+
if node scripts/dual-register.js; then
|
|
122
|
+
print_success "Legacy compatibility added."
|
|
123
|
+
else
|
|
124
|
+
print_info "Warning: Legacy compatibility script failed. Old flow type names may not work."
|
|
125
|
+
fi
|
|
126
|
+
|
|
119
127
|
echo "================================================="
|
|
120
128
|
print_success "Build complete!"
|
|
121
129
|
echo "================================================="
|
|
@@ -344,6 +344,70 @@ module.exports = function(RED) {
|
|
|
344
344
|
return numericValue;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
/**
|
|
348
|
+
* Returns true when any advanced WebP option is explicitly set in the node config.
|
|
349
|
+
* When false the fast C++ encoding path is used unchanged.
|
|
350
|
+
*/
|
|
351
|
+
utils.hasAdvancedWebpOptions = function(config) {
|
|
352
|
+
if (!config) return false;
|
|
353
|
+
if (config.webpLossless === true || config.webpLossless === 'true') return true;
|
|
354
|
+
if (config.webpSmartSubsample === true || config.webpSmartSubsample === 'true') return true;
|
|
355
|
+
if (config.webpEffort !== undefined && config.webpEffort !== '' && config.webpEffort !== null) return true;
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Builds a Sharp `.webp()` options object from node config.
|
|
361
|
+
*/
|
|
362
|
+
utils.buildWebpOptions = function(config) {
|
|
363
|
+
const opts = {};
|
|
364
|
+
const quality = parseInt(config.outputQuality);
|
|
365
|
+
if (Number.isFinite(quality) && quality >= 1 && quality <= 100) opts.quality = quality;
|
|
366
|
+
else opts.quality = CONSTANTS.DEFAULT_JPEG_QUALITY;
|
|
367
|
+
|
|
368
|
+
if (config.webpLossless === true || config.webpLossless === 'true') opts.lossless = true;
|
|
369
|
+
if (config.webpSmartSubsample === true || config.webpSmartSubsample === 'true') opts.smartSubsample = true;
|
|
370
|
+
const effort = parseInt(config.webpEffort);
|
|
371
|
+
if (Number.isFinite(effort) && effort >= 0 && effort <= 6) opts.effort = effort;
|
|
372
|
+
return opts;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Encodes a raw image object to WebP via Sharp with advanced options.
|
|
377
|
+
* Modeled on rawToJpeg() — performs BGR→RGB swap and feeds Sharp.
|
|
378
|
+
*/
|
|
379
|
+
utils.encodeWebpAdvanced = async function(image, config) {
|
|
380
|
+
if (!sharp) {
|
|
381
|
+
throw new Error('Sharp is not available. Install "sharp" in your Node-RED userDir and restart Node-RED.');
|
|
382
|
+
}
|
|
383
|
+
const normalized = utils.validateImageStructure(image, { warn: () => {} });
|
|
384
|
+
if (!normalized)
|
|
385
|
+
throw new Error('Invalid raw image object supplied to encodeWebpAdvanced');
|
|
386
|
+
|
|
387
|
+
const colorSpace = normalized.colorSpace;
|
|
388
|
+
const channels = normalized.channels;
|
|
389
|
+
let data = normalized.data;
|
|
390
|
+
|
|
391
|
+
// BGR/BGRA → RGB/RGBA for Sharp
|
|
392
|
+
if (colorSpace === 'BGR' || colorSpace === 'BGRA') {
|
|
393
|
+
data = Buffer.from(data);
|
|
394
|
+
for (let i = 0; i < data.length; i += channels) {
|
|
395
|
+
const t = data[i];
|
|
396
|
+
data[i] = data[i + 2];
|
|
397
|
+
data[i + 2] = t;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const sh = sharp(data, {
|
|
402
|
+
raw: { width: normalized.width, height: normalized.height, channels }
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
if (colorSpace === 'GRAY') sh.toColourspace('b-w');
|
|
406
|
+
|
|
407
|
+
const webpOpts = utils.buildWebpOptions(config);
|
|
408
|
+
return sh.webp(webpOpts).toBuffer();
|
|
409
|
+
}
|
|
410
|
+
|
|
347
411
|
utils.rawToJpeg = async function (image, quality = CONSTANTS.DEFAULT_JPEG_QUALITY) {
|
|
348
412
|
if (!sharp) {
|
|
349
413
|
throw new Error('Sharp is not available. Install "sharp" in your Node-RED userDir and restart Node-RED.');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- nodes/blend/add-bbs.html -->
|
|
2
2
|
|
|
3
3
|
<script type="text/javascript">
|
|
4
|
-
|
|
4
|
+
var _rpNodeCfg = {
|
|
5
5
|
category:'RP Image',
|
|
6
6
|
color:'#DDA0DD',
|
|
7
7
|
icon:'font-awesome/fa-object-group',
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
outputFormat:{value:"raw"},
|
|
14
14
|
outputQuality:{value:90},
|
|
15
15
|
pngOptimize:{value:false},
|
|
16
|
+
webpLossless:{value:false},
|
|
17
|
+
webpSmartSubsample:{value:false},
|
|
18
|
+
webpEffort:{value:""},
|
|
16
19
|
// Debug configuration
|
|
17
20
|
debugEnabled:{value:false},
|
|
18
21
|
debugWidth:{value:200},
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
classColorMappings:{value:[]}
|
|
29
32
|
},
|
|
30
33
|
inputs:1,outputs:1,
|
|
31
|
-
label:function(){return this.name||"add-bbs";},
|
|
34
|
+
label:function(){return this.name||"rp-add-bbs";},
|
|
32
35
|
oneditprepare:function(){
|
|
33
36
|
const node = this;
|
|
34
37
|
let classMappingIndex = 0;
|
|
@@ -72,6 +75,11 @@
|
|
|
72
75
|
const format = $("#node-input-outputFormat").val();
|
|
73
76
|
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
74
77
|
$("#png-optimize-row").toggle(format === "png");
|
|
78
|
+
// Show WebP advanced options only when WebP is selected
|
|
79
|
+
const isWebp = format === 'webp';
|
|
80
|
+
$("#webp-lossless-row").toggle(isWebp);
|
|
81
|
+
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
82
|
+
$("#webp-effort-row").toggle(isWebp);
|
|
75
83
|
}
|
|
76
84
|
$("#node-input-outputFormat").on("change", updateQualityVisibility);
|
|
77
85
|
updateQualityVisibility();
|
|
@@ -278,7 +286,9 @@
|
|
|
278
286
|
|
|
279
287
|
this.classColorMappings = mappings;
|
|
280
288
|
}
|
|
281
|
-
}
|
|
289
|
+
};
|
|
290
|
+
RED.nodes.registerType('rp-add-bbs', _rpNodeCfg);
|
|
291
|
+
RED.nodes.registerType('add-bbs', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
282
292
|
|
|
283
293
|
// Debug image display renderer - shared across all image processing nodes
|
|
284
294
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -390,6 +400,134 @@
|
|
|
390
400
|
}
|
|
391
401
|
</script>
|
|
392
402
|
|
|
403
|
+
<script type="text/x-red" data-template-name="rp-add-bbs">
|
|
404
|
+
<div class="form-row">
|
|
405
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
406
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
<div class="form-row">
|
|
410
|
+
<label><i class="fa fa-picture-o"></i> Image</label>
|
|
411
|
+
<input type="text" id="node-input-imagePath" style="width:70%;">
|
|
412
|
+
<input type="hidden" id="node-input-imagePathType">
|
|
413
|
+
</div>
|
|
414
|
+
|
|
415
|
+
<div class="form-row">
|
|
416
|
+
<label><i class="fa fa-object-group"></i> Boxes Array</label>
|
|
417
|
+
<input type="text" id="node-input-boxesPath" style="width:70%;">
|
|
418
|
+
<input type="hidden" id="node-input-boxesPathType">
|
|
419
|
+
</div>
|
|
420
|
+
|
|
421
|
+
<div class="form-row">
|
|
422
|
+
<label><i class="fa fa-sign-out"></i> Output</label>
|
|
423
|
+
<input type="text" id="node-input-outputPath" style="width:70%;">
|
|
424
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
425
|
+
</div>
|
|
426
|
+
|
|
427
|
+
<div class="form-row">
|
|
428
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
429
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
430
|
+
<option value="raw">Raw (fastest)</option>
|
|
431
|
+
<option value="jpg">JPEG</option>
|
|
432
|
+
<option value="png">PNG</option>
|
|
433
|
+
<option value="webp">WebP</option>
|
|
434
|
+
</select>
|
|
435
|
+
</div>
|
|
436
|
+
|
|
437
|
+
<div class="form-row" id="quality-row">
|
|
438
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
439
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
440
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
441
|
+
</div>
|
|
442
|
+
|
|
443
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
444
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
445
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
446
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
447
|
+
</div>
|
|
448
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
449
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
450
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
451
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
452
|
+
</div>
|
|
453
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
454
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
455
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
456
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
457
|
+
</div>
|
|
458
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
459
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
460
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
461
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
462
|
+
</div>
|
|
463
|
+
|
|
464
|
+
<!-- Debug Configuration -->
|
|
465
|
+
<div class="form-row">
|
|
466
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
467
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
468
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
469
|
+
</div>
|
|
470
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
471
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
472
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
473
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
474
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
475
|
+
</div>
|
|
476
|
+
|
|
477
|
+
<hr/>
|
|
478
|
+
|
|
479
|
+
<!-- Display Options -->
|
|
480
|
+
<div class="form-row">
|
|
481
|
+
<label><i class="fa fa-eye"></i> Display Options</label>
|
|
482
|
+
<div style="margin-left: 105px;">
|
|
483
|
+
<input type="checkbox" id="node-input-showClassName" style="width:auto; display:inline-block; vertical-align:baseline;">
|
|
484
|
+
<label for="node-input-showClassName" style="width:auto;">Show Tag Name</label>
|
|
485
|
+
<br>
|
|
486
|
+
<input type="checkbox" id="node-input-showConfidence" style="width:auto; display:inline-block; vertical-align:baseline;">
|
|
487
|
+
<label for="node-input-showConfidence" style="width:auto;">Show Confidence</label>
|
|
488
|
+
<br>
|
|
489
|
+
<input type="checkbox" id="node-input-onlyMapped" style="width:auto; display:inline-block; vertical-align:baseline;">
|
|
490
|
+
<label for="node-input-onlyMapped" style="width:auto;">Only Draw Mapped Tags</label>
|
|
491
|
+
</div>
|
|
492
|
+
</div>
|
|
493
|
+
|
|
494
|
+
<hr/>
|
|
495
|
+
|
|
496
|
+
<!-- Visual Settings -->
|
|
497
|
+
<div class="form-row">
|
|
498
|
+
<label for="node-input-boxThickness"><i class="fa fa-square-o"></i> Box Thickness</label>
|
|
499
|
+
<input type="range" id="node-input-boxThickness" min="1" max="10" value="2" style="width:200px;">
|
|
500
|
+
<span id="thickness-value" style="margin-left: 10px; font-weight: bold;">2px</span>
|
|
501
|
+
</div>
|
|
502
|
+
|
|
503
|
+
<div class="form-row">
|
|
504
|
+
<label for="node-input-fontSize"><i class="fa fa-font"></i> Font Size</label>
|
|
505
|
+
<input type="range" id="node-input-fontSize" min="0.3" max="2.0" step="0.1" value="0.5" style="width:200px;">
|
|
506
|
+
<span id="fontSize-value" style="margin-left: 10px; font-weight: bold;">0.5</span>
|
|
507
|
+
</div>
|
|
508
|
+
|
|
509
|
+
<hr/>
|
|
510
|
+
|
|
511
|
+
<!-- Tag Color Mappings -->
|
|
512
|
+
<div class="form-row">
|
|
513
|
+
<label><i class="fa fa-palette"></i> Tag Color Mappings</label>
|
|
514
|
+
<div id="class-mappings-container" style="margin-top: 10px;">
|
|
515
|
+
<!-- Dynamic tag mapping rows will be inserted here -->
|
|
516
|
+
</div>
|
|
517
|
+
<div style="margin-top: 10px;">
|
|
518
|
+
<button type="button" id="add-class-mapping" class="editor-button">
|
|
519
|
+
<i class="fa fa-plus"></i> Add Tag Mapping
|
|
520
|
+
</button>
|
|
521
|
+
</div>
|
|
522
|
+
<div style="margin-top: 5px; font-size: 11px; color: #666;">
|
|
523
|
+
Define colors for specific tags. Undefined tags will automatically use maximally different colors.
|
|
524
|
+
</div>
|
|
525
|
+
</div>
|
|
526
|
+
|
|
527
|
+
<hr/>
|
|
528
|
+
|
|
529
|
+
</script>
|
|
530
|
+
|
|
393
531
|
<script type="text/x-red" data-template-name="add-bbs">
|
|
394
532
|
<div class="form-row">
|
|
395
533
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
@@ -435,6 +573,21 @@
|
|
|
435
573
|
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
436
574
|
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
437
575
|
</div>
|
|
576
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
577
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
578
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
579
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
580
|
+
</div>
|
|
581
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
582
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
583
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
584
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
585
|
+
</div>
|
|
586
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
587
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
588
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
589
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
590
|
+
</div>
|
|
438
591
|
|
|
439
592
|
<!-- Debug Configuration -->
|
|
440
593
|
<div class="form-row">
|
|
@@ -503,6 +656,92 @@
|
|
|
503
656
|
|
|
504
657
|
</script>
|
|
505
658
|
|
|
659
|
+
<script type="text/x-red" data-help-name="rp-add-bbs">
|
|
660
|
+
<p><b>rosepetal-add-bbs</b> draws bounding boxes with optional labels on images for object detection visualization. This node processes arrays of bounding box objects with automatic color assignment for different classes.</p>
|
|
661
|
+
|
|
662
|
+
<h3>Details</h3>
|
|
663
|
+
<p>This node performs high-performance bounding box rendering using OpenCV. Boxes are drawn from 4-corner coordinates (normalized 0-1 range) with customizable colors, thickness, and label display options. Labels can show class names, confidence scores, or both with configurable positioning and background.</p>
|
|
664
|
+
|
|
665
|
+
<h3>Properties</h3>
|
|
666
|
+
<dl class="message-properties">
|
|
667
|
+
<dt>Image <span class="property-type">string</span></dt>
|
|
668
|
+
<dd>Message property path containing the base image on which boxes will be drawn. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
669
|
+
|
|
670
|
+
<dt>Boxes Array <span class="property-type">string</span></dt>
|
|
671
|
+
<dd>Message property path containing the boxes array. Expected structure: array of objects with <code>raw_boxes</code> coordinates (4 corners), <code>tag</code>, and optional <code>confidence</code>. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
672
|
+
|
|
673
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
674
|
+
<dd>Message property path where the image with drawn boxes will be stored. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
675
|
+
|
|
676
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
677
|
+
<dd>Format for the output image: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
678
|
+
|
|
679
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
680
|
+
<dd>Compression quality (1-100) for JPEG and WebP formats. Only visible when JPG or WebP is selected.</dd>
|
|
681
|
+
|
|
682
|
+
<dt>Show Tag Name <span class="property-type">boolean</span></dt>
|
|
683
|
+
<dd>Display the tag name as part of the box label.</dd>
|
|
684
|
+
|
|
685
|
+
<dt>Show Confidence <span class="property-type">boolean</span></dt>
|
|
686
|
+
<dd>Display the confidence score as part of the box label (e.g., "95.4%").</dd>
|
|
687
|
+
|
|
688
|
+
<dt>Only Mapped Tags <span class="property-type">boolean</span></dt>
|
|
689
|
+
<dd>When enabled, only draw boxes for tags that have explicit color mappings defined.</dd>
|
|
690
|
+
|
|
691
|
+
<dt>Box Thickness <span class="property-type">number</span></dt>
|
|
692
|
+
<dd>Line thickness for bounding boxes (1-10 pixels).</dd>
|
|
693
|
+
|
|
694
|
+
<dt>Font Size <span class="property-type">number</span></dt>
|
|
695
|
+
<dd>Scale factor for label text (0.3-2.0).</dd>
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
<dt>Tag Color Mappings <span class="property-type">array</span></dt>
|
|
699
|
+
<dd>Dynamic list of tag name to color mappings. Each mapping defines a specific color for boxes with that tag.</dd>
|
|
700
|
+
</dl>
|
|
701
|
+
|
|
702
|
+
<h3>Input Structure</h3>
|
|
703
|
+
<p>The boxes array should follow this exact structure:</p>
|
|
704
|
+
<pre>[
|
|
705
|
+
{
|
|
706
|
+
"tag": "mountain",
|
|
707
|
+
"raw_boxes": [[x1,y1], [x2,y1], [x2,y2], [x1,y2]], // 4 corners, normalized [0,1]
|
|
708
|
+
"confidence": 0.98095703125
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"tag": "bottle",
|
|
712
|
+
"raw_boxes": [[0.82,0.14], [0.93,0.14], [0.93,0.98], [0.82,0.98]],
|
|
713
|
+
"confidence": 0.96337890625
|
|
714
|
+
}
|
|
715
|
+
]</pre>
|
|
716
|
+
|
|
717
|
+
<h3>Key Features</h3>
|
|
718
|
+
<ul>
|
|
719
|
+
<li><b>4-Corner Box Format:</b> Normalized coordinates [0,1] for resolution-independent processing</li>
|
|
720
|
+
<li><b>Dynamic Color Management:</b> Add/remove tag color mappings with real-time validation</li>
|
|
721
|
+
<li><b>Auto-Color Generation:</b> Maximally different colors for undefined tags</li>
|
|
722
|
+
<li><b>Flexible Labels:</b> Show tag name, confidence, both, or neither</li>
|
|
723
|
+
<li><b>Smart Positioning:</b> Automatic adjustment when labels would go off-screen</li>
|
|
724
|
+
<li><b>Performance Optimized:</b> Direct pixel manipulation with OpenMP parallelization</li>
|
|
725
|
+
</ul>
|
|
726
|
+
|
|
727
|
+
<h3>Label Formatting</h3>
|
|
728
|
+
<p>Labels are formatted based on display options:</p>
|
|
729
|
+
<ul>
|
|
730
|
+
<li><b>Tag Only:</b> "mountain"</li>
|
|
731
|
+
<li><b>Confidence Only:</b> "98.1%"</li>
|
|
732
|
+
<li><b>Both:</b> "mountain (98.1%)"</li>
|
|
733
|
+
<li><b>Neither:</b> Box drawn without label</li>
|
|
734
|
+
</ul>
|
|
735
|
+
|
|
736
|
+
<h3>Performance</h3>
|
|
737
|
+
<ul>
|
|
738
|
+
<li><b>C++ Backend:</b> High-performance OpenCV implementation with optimizations</li>
|
|
739
|
+
<li><b>Direct Drawing:</b> Efficient rectangle and text rendering</li>
|
|
740
|
+
<li><b>Cached Colors:</b> Reuses color calculations across boxes</li>
|
|
741
|
+
<li><b>Parallel Processing:</b> OpenMP parallelization for multiple boxes</li>
|
|
742
|
+
</ul>
|
|
743
|
+
</script>
|
|
744
|
+
|
|
506
745
|
<script type="text/x-red" data-help-name="add-bbs">
|
|
507
746
|
<p><b>rosepetal-add-bbs</b> draws bounding boxes with optional labels on images for object detection visualization. This node processes arrays of bounding box objects with automatic color assignment for different classes.</p>
|
|
508
747
|
|
|
@@ -201,6 +201,8 @@ module.exports = function (RED) {
|
|
|
201
201
|
const outputFormat = config.outputFormat || 'raw';
|
|
202
202
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
203
203
|
const pngOptimize = config.pngOptimize || false;
|
|
204
|
+
const useSharpWebp = outputFormat === 'webp' && NodeUtils.hasAdvancedWebpOptions(config);
|
|
205
|
+
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
204
206
|
|
|
205
207
|
// Build class color map from configuration
|
|
206
208
|
const classColorMap = {};
|
|
@@ -213,7 +215,7 @@ module.exports = function (RED) {
|
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
/* ▸ Single call to the C++ addon --------------------------------- */
|
|
216
|
-
|
|
218
|
+
let { image: result, timing = {}, boxCount } =
|
|
217
219
|
await Cpp.addBBs(
|
|
218
220
|
baseImg,
|
|
219
221
|
boxesArray, // Pass direct array to C++
|
|
@@ -225,11 +227,15 @@ module.exports = function (RED) {
|
|
|
225
227
|
fontSize,
|
|
226
228
|
'above', // Always position labels above the box
|
|
227
229
|
labelBackground,
|
|
228
|
-
|
|
230
|
+
cppFormat,
|
|
229
231
|
outputQuality,
|
|
230
232
|
pngOptimize
|
|
231
233
|
);
|
|
232
234
|
|
|
235
|
+
if (useSharpWebp) {
|
|
236
|
+
result = await NodeUtils.encodeWebpAdvanced(result, config);
|
|
237
|
+
}
|
|
238
|
+
|
|
233
239
|
/* ▸ Write the result back to msg ---------------------------------- */
|
|
234
240
|
RED.util.setMessageProperty(msg, config.outputPath || 'payload', result);
|
|
235
241
|
|
|
@@ -292,5 +298,6 @@ module.exports = function (RED) {
|
|
|
292
298
|
});
|
|
293
299
|
}
|
|
294
300
|
|
|
295
|
-
RED.nodes.registerType('add-bbs', AddBBsNode);
|
|
301
|
+
RED.nodes.registerType('rp-add-bbs', AddBBsNode);
|
|
302
|
+
RED.nodes.registerType('add-bbs', AddBBsNode); // legacy compat
|
|
296
303
|
};
|