@rosepetal/node-red-contrib-image-tools 1.2.3 → 1.3.1
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 +14 -6
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +219 -3
- package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +2 -1
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +258 -3
- package/node-red-contrib-image-tools/nodes/blend/add-mask.js +2 -1
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +183 -3
- package/node-red-contrib-image-tools/nodes/blend/add-masks.js +2 -1
- package/node-red-contrib-image-tools/nodes/blend/blend.html +308 -3
- package/node-red-contrib-image-tools/nodes/blend/blend.js +2 -1
- 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 +375 -3
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/concat.html +222 -5
- package/node-red-contrib-image-tools/nodes/mix/concat.js +2 -1
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +284 -3
- package/node-red-contrib-image-tools/nodes/mix/mosaic.js +2 -1
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +193 -3
- package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +2 -1
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +260 -2
- package/node-red-contrib-image-tools/nodes/specialized/image-align.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/color-convert.html +144 -5
- package/node-red-contrib-image-tools/nodes/transform/color-convert.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/crop.html +213 -5
- package/node-red-contrib-image-tools/nodes/transform/crop.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/draw.html +128 -3
- package/node-red-contrib-image-tools/nodes/transform/draw.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/filter.html +344 -3
- package/node-red-contrib-image-tools/nodes/transform/filter.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/padding.html +292 -5
- package/node-red-contrib-image-tools/nodes/transform/padding.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/resize.html +177 -3
- package/node-red-contrib-image-tools/nodes/transform/resize.js +2 -1
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +140 -5
- package/node-red-contrib-image-tools/nodes/transform/rotate.js +2 -1
- package/package.json +71 -45
- package/scripts/dual-register.js +297 -0
- package/node-red-contrib-image-tools/package.json +0 -58
package/install.sh
CHANGED
|
@@ -107,15 +107,23 @@ main() {
|
|
|
107
107
|
exit 1
|
|
108
108
|
fi
|
|
109
109
|
|
|
110
|
-
print_step "Installing
|
|
111
|
-
cd "$SCRIPT_DIR
|
|
110
|
+
print_step "Installing dependencies..."
|
|
111
|
+
cd "$SCRIPT_DIR"
|
|
112
112
|
if npm install; then
|
|
113
|
-
print_success "
|
|
113
|
+
print_success "Dependencies installed successfully."
|
|
114
114
|
else
|
|
115
|
-
print_error "Failed to install
|
|
115
|
+
print_error "Failed to install dependencies."
|
|
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 "================================================="
|
|
@@ -128,13 +136,13 @@ main() {
|
|
|
128
136
|
echo
|
|
129
137
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
130
138
|
print_info "Installing into Node-RED..."
|
|
131
|
-
(cd "$NODE_RED_DIR" && npm install "$SCRIPT_DIR
|
|
139
|
+
(cd "$NODE_RED_DIR" && npm install "$SCRIPT_DIR")
|
|
132
140
|
print_success "Successfully installed in Node-RED."
|
|
133
141
|
print_info "Please restart your Node-RED instance to see the new nodes."
|
|
134
142
|
else
|
|
135
143
|
print_info "Skipping automatic installation."
|
|
136
144
|
print_info "You can install it later by running this command:"
|
|
137
|
-
print_info " cd ~/.node-red && npm install $SCRIPT_DIR
|
|
145
|
+
print_info " cd ~/.node-red && npm install $SCRIPT_DIR"
|
|
138
146
|
fi
|
|
139
147
|
fi
|
|
140
148
|
}
|
|
@@ -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',
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
classColorMappings:{value:[]}
|
|
32
32
|
},
|
|
33
33
|
inputs:1,outputs:1,
|
|
34
|
-
label:function(){return this.name||"add-bbs";},
|
|
34
|
+
label:function(){return this.name||"rp-add-bbs";},
|
|
35
35
|
oneditprepare:function(){
|
|
36
36
|
const node = this;
|
|
37
37
|
let classMappingIndex = 0;
|
|
@@ -286,7 +286,9 @@
|
|
|
286
286
|
|
|
287
287
|
this.classColorMappings = mappings;
|
|
288
288
|
}
|
|
289
|
-
}
|
|
289
|
+
};
|
|
290
|
+
RED.nodes.registerType('rp-add-bbs', _rpNodeCfg);
|
|
291
|
+
RED.nodes.registerType('add-bbs', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
290
292
|
|
|
291
293
|
// Debug image display renderer - shared across all image processing nodes
|
|
292
294
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -398,6 +400,134 @@
|
|
|
398
400
|
}
|
|
399
401
|
</script>
|
|
400
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
|
+
|
|
401
531
|
<script type="text/x-red" data-template-name="add-bbs">
|
|
402
532
|
<div class="form-row">
|
|
403
533
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
@@ -526,6 +656,92 @@
|
|
|
526
656
|
|
|
527
657
|
</script>
|
|
528
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
|
+
|
|
529
745
|
<script type="text/x-red" data-help-name="add-bbs">
|
|
530
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>
|
|
531
747
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- nodes/blend/add-mask.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-mask',
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
fillColor:{value:"#ffffff"} // Default white for polygon fill
|
|
25
25
|
},
|
|
26
26
|
inputs:1,outputs:1,
|
|
27
|
-
label:function(){return this.name||"add-mask";},
|
|
27
|
+
label:function(){return this.name||"rp-add-mask";},
|
|
28
28
|
oneditprepare:function(){
|
|
29
29
|
/* path typedInputs */
|
|
30
30
|
$("#node-input-imagePath").typedInput({
|
|
@@ -106,7 +106,9 @@
|
|
|
106
106
|
$('#node-input-debugEnabled').data('debug-enabled', enabled);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
}
|
|
109
|
+
};
|
|
110
|
+
RED.nodes.registerType('rp-add-mask', _rpNodeCfg);
|
|
111
|
+
RED.nodes.registerType('add-mask', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
110
112
|
|
|
111
113
|
// Debug image display renderer - shared across all image processing nodes
|
|
112
114
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -218,6 +220,96 @@
|
|
|
218
220
|
}
|
|
219
221
|
</script>
|
|
220
222
|
|
|
223
|
+
<script type="text/x-red" data-template-name="rp-add-mask">
|
|
224
|
+
<div class="form-row">
|
|
225
|
+
<label><i class="fa fa-picture-o"></i> Image</label>
|
|
226
|
+
<input type="text" id="node-input-imagePath" style="width:70%;">
|
|
227
|
+
<input type="hidden" id="node-input-imagePathType">
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<div class="form-row">
|
|
231
|
+
<label><i class="fa fa-draw-polygon"></i> Polygon Path</label>
|
|
232
|
+
<input type="text" id="node-input-polygonPath" style="width:70%;">
|
|
233
|
+
<input type="hidden" id="node-input-polygonPathType">
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<div class="form-row">
|
|
237
|
+
<label><i class="fa fa-sign-out"></i> Output</label>
|
|
238
|
+
<input type="text" id="node-input-outputPath" style="width:70%;">
|
|
239
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div class="form-row">
|
|
243
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
244
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
245
|
+
<option value="raw">Raw (fastest)</option>
|
|
246
|
+
<option value="jpg">JPEG</option>
|
|
247
|
+
<option value="png">PNG</option>
|
|
248
|
+
<option value="webp">WebP</option>
|
|
249
|
+
</select>
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<div class="form-row" id="quality-row">
|
|
253
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
254
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
255
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
259
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
260
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
261
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
262
|
+
</div>
|
|
263
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
264
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
265
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
266
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
269
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
270
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
271
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
272
|
+
</div>
|
|
273
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
274
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
275
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
276
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
<!-- Debug Configuration -->
|
|
280
|
+
<div class="form-row">
|
|
281
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
282
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
283
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
284
|
+
</div>
|
|
285
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
286
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
287
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
288
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
289
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<hr/>
|
|
293
|
+
|
|
294
|
+
<div class="form-row">
|
|
295
|
+
<label for="node-input-maskStrength"><i class="fa fa-adjust"></i> Mask Strength</label>
|
|
296
|
+
<input type="range" id="node-input-maskStrength" min="0" max="100" value="50" style="width: 200px;">
|
|
297
|
+
<span id="strength-value" style="margin-left: 10px; font-weight: bold;">50%</span>
|
|
298
|
+
<div style="margin-top: 5px; font-size: 11px; color: #666;" id="strength-label">
|
|
299
|
+
Balanced mask application
|
|
300
|
+
</div>
|
|
301
|
+
<div style="margin-top: 5px; font-size: 10px; color: #999;">
|
|
302
|
+
0% = No mask effect | 50% = Balanced | 100% = Full mask effect
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
|
|
306
|
+
<div class="form-row">
|
|
307
|
+
<label for="node-input-fillColor"><i class="fa fa-eyedropper"></i> Fill Color</label>
|
|
308
|
+
<input type="color" id="node-input-fillColor" value="#ffffff" style="width: 60px; height: 30px;">
|
|
309
|
+
<span style="margin-left: 10px; color: #666;">Color to fill polygon mask</span>
|
|
310
|
+
</div>
|
|
311
|
+
</script>
|
|
312
|
+
|
|
221
313
|
<script type="text/x-red" data-template-name="add-mask">
|
|
222
314
|
<div class="form-row">
|
|
223
315
|
<label><i class="fa fa-picture-o"></i> Image</label>
|
|
@@ -308,6 +400,169 @@
|
|
|
308
400
|
</div>
|
|
309
401
|
</script>
|
|
310
402
|
|
|
403
|
+
<script type="text/x-red" data-help-name="rp-add-mask">
|
|
404
|
+
<p><b>rosepetal-add-mask</b> applies a polygon-based mask to a base image using weighted blending with configurable mask strength and fill color. This node generates masks from polygon coordinates (from object detection results) and blends them with the original image.</p>
|
|
405
|
+
|
|
406
|
+
<h3>Details</h3>
|
|
407
|
+
<p>This node performs high-performance polygon-based blending using OpenCV. A binary mask is generated from polygon coordinates using OpenCV's fillPoly function, then applied to the base image as blending weights. The polygon coordinates are expected to be normalized (0-1 range) and are automatically scaled to match the image dimensions.</p>
|
|
408
|
+
|
|
409
|
+
<h3>Properties</h3>
|
|
410
|
+
<dl class="message-properties">
|
|
411
|
+
<dt>Image <span class="property-type">string</span></dt>
|
|
412
|
+
<dd>Message property path containing the base image to which the mask will be applied. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
413
|
+
|
|
414
|
+
<dt>Polygon Path <span class="property-type">string</span></dt>
|
|
415
|
+
<dd>Message property path containing the polygon coordinates array. Expected format: array of [x, y] coordinate pairs with normalized values (0.0-1.0 range). Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
416
|
+
|
|
417
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
418
|
+
<dd>Message property path where the masked image will be stored. Supports <code>msg</code>, <code>flow</code>, or <code>global</code> context via TypedInput.</dd>
|
|
419
|
+
|
|
420
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
421
|
+
<dd>Format for the output image: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
422
|
+
|
|
423
|
+
<dt>Quality <span class="property-type">number</span></dt>
|
|
424
|
+
<dd>Compression quality (1-100) for JPEG and WebP formats. Only visible when JPG or WebP is selected.</dd>
|
|
425
|
+
|
|
426
|
+
<dt>Mask Strength <span class="property-type">number</span></dt>
|
|
427
|
+
<dd>Intensity of mask application from 0% to 100%. Controls how strongly the mask affects the final result.</dd>
|
|
428
|
+
|
|
429
|
+
<dt>Fill Color <span class="property-type">color</span></dt>
|
|
430
|
+
<dd>Color to fill the polygon mask (default: white #ffffff). This becomes the mask color for blending with the original image.</dd>
|
|
431
|
+
</dl>
|
|
432
|
+
|
|
433
|
+
<h3>Inputs</h3>
|
|
434
|
+
<p>Requires a base image and polygon coordinates from the specified message property paths:</p>
|
|
435
|
+
<ul>
|
|
436
|
+
<li><b>Base Image:</b> From the path specified in "Image" field (default: <code>msg.payload.image</code>)</li>
|
|
437
|
+
<li><b>Polygon Coordinates:</b> From the path specified in "Polygon Path" field (default: <code>msg.payload.default.masks[0].mask[0]</code>)</li>
|
|
438
|
+
</ul>
|
|
439
|
+
|
|
440
|
+
<p>The base image should follow the standard format:</p>
|
|
441
|
+
<pre>{
|
|
442
|
+
data: Buffer, // Raw pixel data or encoded file buffer
|
|
443
|
+
width: number, // Image width in pixels
|
|
444
|
+
height: number, // Image height in pixels
|
|
445
|
+
channels: number, // Channel count (1=grayscale, 3=RGB, 4=RGBA)
|
|
446
|
+
colorSpace: string, // "GRAY", "RGB", "RGBA", "BGR", "BGRA"
|
|
447
|
+
dtype: string // "uint8", "uint16", "float32"
|
|
448
|
+
}</pre>
|
|
449
|
+
<p>File buffers (JPEG, PNG, WebP, BMP) are automatically detected and decoded.</p>
|
|
450
|
+
|
|
451
|
+
<p>The polygon coordinates should be an array of [x, y] coordinate pairs:</p>
|
|
452
|
+
<pre>[
|
|
453
|
+
[0.30859375, 0.5797164440155029],
|
|
454
|
+
[0.314453125, 0.5797164440155029],
|
|
455
|
+
[0.31640625, 0.5818142294883728],
|
|
456
|
+
// ... more coordinate pairs
|
|
457
|
+
]</pre>
|
|
458
|
+
<p>All coordinates must be normalized to 0.0-1.0 range (percentage of image dimensions).</p>
|
|
459
|
+
|
|
460
|
+
<h3>Outputs</h3>
|
|
461
|
+
<p>Produces a single masked image in the specified format:</p>
|
|
462
|
+
<ul>
|
|
463
|
+
<li><b>Raw format:</b> Complete image object with pixel data and metadata</li>
|
|
464
|
+
<li><b>Encoded formats (JPG/PNG/WebP):</b> File buffer ready for storage or transmission</li>
|
|
465
|
+
</ul>
|
|
466
|
+
<p>Output dimensions match the input image dimensions. The generated mask is automatically sized to match the base image.</p>
|
|
467
|
+
|
|
468
|
+
<h3>Masking Behavior</h3>
|
|
469
|
+
<h4>Polygon-to-Mask Conversion Process</h4>
|
|
470
|
+
<ol>
|
|
471
|
+
<li><b>Coordinate Scaling:</b> Converts normalized coordinates (0-1) to pixel coordinates</li>
|
|
472
|
+
<li><b>Mask Generation:</b> Uses OpenCV fillPoly to create binary mask from polygon</li>
|
|
473
|
+
<li><b>Color Application:</b> Fills polygon area with the specified fill color</li>
|
|
474
|
+
<li><b>Blending:</b> Applies the mask as blending weights scaled by mask strength</li>
|
|
475
|
+
</ol>
|
|
476
|
+
|
|
477
|
+
<h4>Mathematical Formula</h4>
|
|
478
|
+
<p>The masking operation uses weighted blending:</p>
|
|
479
|
+
<pre>pixel_coords = polygon_coords × [image_width, image_height]
|
|
480
|
+
binary_mask = fillPoly(pixel_coords, fill_color)
|
|
481
|
+
blend_weights = mask_strength × normalized_mask
|
|
482
|
+
result = image × (1 - blend_weights) + mask_color × blend_weights</pre>
|
|
483
|
+
|
|
484
|
+
<h3>Automatic Image Processing</h3>
|
|
485
|
+
<h4>Dimension Handling</h4>
|
|
486
|
+
<ul>
|
|
487
|
+
<li><b>Same Size:</b> Direct processing with no resizing</li>
|
|
488
|
+
<li><b>Different Sizes:</b> Both images resized to max(width1, width2) × max(height1, height2)</li>
|
|
489
|
+
<li><b>Aspect Ratio:</b> Preserved during resize operations to prevent distortion</li>
|
|
490
|
+
</ul>
|
|
491
|
+
|
|
492
|
+
<h4>Color Space Conversion</h4>
|
|
493
|
+
<ul>
|
|
494
|
+
<li><b>Automatic Detection:</b> Color spaces detected from image metadata or inferred from channel count</li>
|
|
495
|
+
<li><b>Smart Conversion:</b> Images converted to compatible format for processing</li>
|
|
496
|
+
<li><b>Quality Preservation:</b> Lossless conversions maintain image quality throughout processing</li>
|
|
497
|
+
</ul>
|
|
498
|
+
|
|
499
|
+
<h3>Examples</h3>
|
|
500
|
+
<h4>Logo Watermarking</h4>
|
|
501
|
+
<p>Apply a logo with transparent background:</p>
|
|
502
|
+
<ul>
|
|
503
|
+
<li>Image: Main content</li>
|
|
504
|
+
<li>Mask: Logo with black background</li>
|
|
505
|
+
<li>Background Color: Black (#000000)</li>
|
|
506
|
+
<li>Mask Strength: 80-90% for strong branding</li>
|
|
507
|
+
<li>Tolerance: 5-15% for clean edges</li>
|
|
508
|
+
</ul>
|
|
509
|
+
|
|
510
|
+
<h4>Artistic Overlays</h4>
|
|
511
|
+
<p>Create artistic effects with texture masks:</p>
|
|
512
|
+
<ul>
|
|
513
|
+
<li>Image: Photo or artwork</li>
|
|
514
|
+
<li>Mask: Texture or pattern with background</li>
|
|
515
|
+
<li>Background Color: Dominant background color</li>
|
|
516
|
+
<li>Mask Strength: 30-60% for subtle effects</li>
|
|
517
|
+
<li>Tolerance: 20-40% for smooth blending</li>
|
|
518
|
+
</ul>
|
|
519
|
+
|
|
520
|
+
<h4>Selective Enhancement</h4>
|
|
521
|
+
<p>Apply effects to specific image regions:</p>
|
|
522
|
+
<ul>
|
|
523
|
+
<li>Image: Original photo</li>
|
|
524
|
+
<li>Mask: Region selector (white areas to enhance)</li>
|
|
525
|
+
<li>Background Color: Black (#000000)</li>
|
|
526
|
+
<li>Mask Strength: 70-100% for strong effects</li>
|
|
527
|
+
<li>Tolerance: 5-10% for precise control</li>
|
|
528
|
+
</ul>
|
|
529
|
+
|
|
530
|
+
<h3>Node Interactions</h3>
|
|
531
|
+
<ul>
|
|
532
|
+
<li><b>Upstream:</b> Works with <code>image-in</code>, <code>array-in</code>, or any nodes producing image/mask pairs</li>
|
|
533
|
+
<li><b>Downstream:</b> Connect to image writers, further processing nodes, or display components</li>
|
|
534
|
+
<li><b>Chaining:</b> Can be chained for complex multi-layer masking effects</li>
|
|
535
|
+
<li><b>Flow Integration:</b> Supports flow and global context for cross-node data sharing</li>
|
|
536
|
+
</ul>
|
|
537
|
+
|
|
538
|
+
<h3>Error Handling</h3>
|
|
539
|
+
<ul>
|
|
540
|
+
<li><b>Missing Images:</b> Clear warnings when either input image is missing or invalid</li>
|
|
541
|
+
<li><b>Dimension Mismatch:</b> Automatic resizing with performance-optimized interpolation</li>
|
|
542
|
+
<li><b>Color Space Issues:</b> Intelligent conversion with format preservation</li>
|
|
543
|
+
<li><b>Memory Management:</b> Efficient processing of large images with automatic cleanup</li>
|
|
544
|
+
<li><b>Parameter Validation:</b> Range checking for all numeric parameters</li>
|
|
545
|
+
</ul>
|
|
546
|
+
|
|
547
|
+
<h3>Performance</h3>
|
|
548
|
+
<ul>
|
|
549
|
+
<li><b>C++ Backend:</b> High-performance OpenCV implementation with SIMD optimizations</li>
|
|
550
|
+
<li><b>Memory Efficient:</b> Minimal memory allocation with intelligent buffer reuse</li>
|
|
551
|
+
<li><b>Parallel Processing:</b> Multi-threaded operations for large images</li>
|
|
552
|
+
<li><b>Status Timing:</b> Real-time metrics showing conversion, processing, and encoding times</li>
|
|
553
|
+
<li><b>Optimized Builds:</b> Compiled with <code>-O3</code>, <code>-march=native</code> for maximum performance</li>
|
|
554
|
+
</ul>
|
|
555
|
+
|
|
556
|
+
<h3>Advanced Features</h3>
|
|
557
|
+
<ul>
|
|
558
|
+
<li><b>Live Preview:</b> Debug mode shows masked result in real-time</li>
|
|
559
|
+
<li><b>Color Precision:</b> Advanced color matching with configurable tolerance</li>
|
|
560
|
+
<li><b>Batch Processing:</b> Efficient handling of multiple image/mask pairs</li>
|
|
561
|
+
<li><b>Context Integration:</b> Full support for flow and global context storage</li>
|
|
562
|
+
<li><b>Format Flexibility:</b> Seamless conversion between raw and encoded formats</li>
|
|
563
|
+
</ul>
|
|
564
|
+
</script>
|
|
565
|
+
|
|
311
566
|
<script type="text/x-red" data-help-name="add-mask">
|
|
312
567
|
<p><b>rosepetal-add-mask</b> applies a polygon-based mask to a base image using weighted blending with configurable mask strength and fill color. This node generates masks from polygon coordinates (from object detection results) and blends them with the original image.</p>
|
|
313
568
|
|