@rosepetal/node-red-contrib-image-tools 1.2.3 → 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/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 -71
- package/scripts/dual-register.js +267 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- 1 ▸ Runtime registration -->
|
|
4
4
|
<script type="text/javascript">
|
|
5
|
-
|
|
5
|
+
var _rpNodeCfg = {
|
|
6
6
|
|
|
7
7
|
category:'RP Image',
|
|
8
8
|
color :'#FF6B35', // Distinct orange color to differentiate from standard pink
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
|
|
33
33
|
inputs:1, outputs:1,
|
|
34
|
-
label:function(){ return this.name || "cropBB"; },
|
|
34
|
+
label:function(){ return this.name || "rp-cropBB"; },
|
|
35
35
|
|
|
36
36
|
/* ---------------- oneditprepare ---------------- */
|
|
37
37
|
oneditprepare:function(){
|
|
@@ -97,10 +97,96 @@
|
|
|
97
97
|
$('#node-input-debugEnabled').on('change', updateDebugWidthVisibility);
|
|
98
98
|
updateDebugWidthVisibility(); // Initial call
|
|
99
99
|
}
|
|
100
|
-
}
|
|
100
|
+
};
|
|
101
|
+
RED.nodes.registerType('rp-cropBB', _rpNodeCfg);
|
|
102
|
+
RED.nodes.registerType('cropBB', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
101
103
|
</script>
|
|
102
104
|
|
|
103
105
|
<!-- 2 ▸ Edit template -->
|
|
106
|
+
<script type="text/html" data-template-name="rp-cropBB">
|
|
107
|
+
<div class="form-row">
|
|
108
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
109
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<hr>
|
|
113
|
+
|
|
114
|
+
<!-- I/O Section -->
|
|
115
|
+
<div class="form-row">
|
|
116
|
+
<label for="node-input-imageInputPath"><i class="fa fa-sign-in"></i> Input from</label>
|
|
117
|
+
<input type="text" id="node-input-imageInputPath" style="width: 70%;">
|
|
118
|
+
<input type="hidden" id="node-input-imageInputPathType">
|
|
119
|
+
</div>
|
|
120
|
+
<div class="form-row">
|
|
121
|
+
<label for="node-input-bboxInputPath"><i class="fa fa-square-o"></i> Bounding Boxes</label>
|
|
122
|
+
<input type="text" id="node-input-bboxInputPath" style="width: 70%;">
|
|
123
|
+
<input type="hidden" id="node-input-bboxInputPathType">
|
|
124
|
+
</div>
|
|
125
|
+
<div class="form-row">
|
|
126
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
127
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
128
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
129
|
+
</div>
|
|
130
|
+
<div class="form-row">
|
|
131
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
132
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
133
|
+
<option value="raw">Raw (fastest)</option>
|
|
134
|
+
<option value="jpg">JPEG</option>
|
|
135
|
+
<option value="png">PNG</option>
|
|
136
|
+
<option value="webp">WebP</option>
|
|
137
|
+
</select>
|
|
138
|
+
</div>
|
|
139
|
+
<div class="form-row" id="quality-row">
|
|
140
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
141
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
142
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
146
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
147
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
148
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
149
|
+
</div>
|
|
150
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
151
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
152
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
153
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
154
|
+
</div>
|
|
155
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
156
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
157
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
158
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
161
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
162
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
163
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<!-- Debug Configuration -->
|
|
167
|
+
<div class="form-row">
|
|
168
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
169
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
170
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
171
|
+
</div>
|
|
172
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
173
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
174
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
175
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
176
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<hr>
|
|
180
|
+
|
|
181
|
+
<!-- CropBB Specific Options -->
|
|
182
|
+
<div class="form-row">
|
|
183
|
+
<label for="node-input-minConfidence"><i class="fa fa-filter"></i> Min Confidence</label>
|
|
184
|
+
<input type="text" id="node-input-minConfidence" style="width: 70%;">
|
|
185
|
+
<input type="hidden" id="node-input-minConfidenceType">
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
</script>
|
|
189
|
+
|
|
104
190
|
<script type="text/html" data-template-name="cropBB">
|
|
105
191
|
<div class="form-row">
|
|
106
192
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
@@ -186,6 +272,110 @@
|
|
|
186
272
|
</script>
|
|
187
273
|
|
|
188
274
|
<!-- 3 ▸ Help documentation -->
|
|
275
|
+
<script type="text/html" data-help-name="rp-cropBB">
|
|
276
|
+
<p>Extracts image crops from bounding boxes detected by inference models.</p>
|
|
277
|
+
|
|
278
|
+
<h3>Details</h3>
|
|
279
|
+
<p>This node takes images and their corresponding bounding box data (typically from an inferencer node)
|
|
280
|
+
and extracts each detected region as a separate image crop. Each crop is paired with its detection metadata.</p>
|
|
281
|
+
|
|
282
|
+
<h3>Inputs</h3>
|
|
283
|
+
<dl class="message-properties">
|
|
284
|
+
<dt>Image Input<span class="property-type">image | image[]</span></dt>
|
|
285
|
+
<dd>Single image or array of images in standard Rosepetal format</dd>
|
|
286
|
+
|
|
287
|
+
<dt>Bounding Boxes<span class="property-type">array</span></dt>
|
|
288
|
+
<dd>Array of detection objects with format: <code>[{raw_boxes: [[x1,y1],...], tag: "label", confidence: 0.95}, ...]</code></dd>
|
|
289
|
+
</dl>
|
|
290
|
+
|
|
291
|
+
<h3>Outputs</h3>
|
|
292
|
+
<dl class="message-properties">
|
|
293
|
+
<dt>crops<span class="property-type">array</span></dt>
|
|
294
|
+
<dd>Array of image objects with metadata. Each element is directly usable as an image with added <code>tag</code>, <code>confidence</code>, and <code>bbox</code> properties.</dd>
|
|
295
|
+
</dl>
|
|
296
|
+
|
|
297
|
+
<h3>Configuration</h3>
|
|
298
|
+
<dl class="message-properties">
|
|
299
|
+
<dt>Image Input</dt>
|
|
300
|
+
<dd>Path to image data (default: <code>msg.image</code>)</dd>
|
|
301
|
+
|
|
302
|
+
<dt>Bounding Boxes</dt>
|
|
303
|
+
<dd>Path to inference results (default: <code>msg.default</code>)</dd>
|
|
304
|
+
|
|
305
|
+
<dt>Output Format</dt>
|
|
306
|
+
<dd>Raw (fastest), JPEG, PNG, or WebP encoding</dd>
|
|
307
|
+
|
|
308
|
+
<dt>Min Confidence</dt>
|
|
309
|
+
<dd>Filter out detections below this confidence threshold (0.0-1.0)</dd>
|
|
310
|
+
|
|
311
|
+
<dt>Debug</dt>
|
|
312
|
+
<dd>Enable debug image display in Node-RED editor</dd>
|
|
313
|
+
</dl>
|
|
314
|
+
|
|
315
|
+
<h3>Example Input (Bounding Boxes)</h3>
|
|
316
|
+
<pre>[
|
|
317
|
+
{
|
|
318
|
+
"raw_boxes": [[0.1, 0.2], [0.4, 0.2], [0.4, 0.6], [0.1, 0.6]],
|
|
319
|
+
"tag": "mountain",
|
|
320
|
+
"confidence": 0.98095703125
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"raw_boxes": [[0.5, 0.1], [0.9, 0.1], [0.9, 0.4], [0.5, 0.4]],
|
|
324
|
+
"tag": "sky",
|
|
325
|
+
"confidence": 0.92
|
|
326
|
+
}
|
|
327
|
+
]</pre>
|
|
328
|
+
|
|
329
|
+
<h3>Example Output</h3>
|
|
330
|
+
<pre>[
|
|
331
|
+
{
|
|
332
|
+
data: Buffer, // Crop image data
|
|
333
|
+
width: 150,
|
|
334
|
+
height: 200,
|
|
335
|
+
channels: 3,
|
|
336
|
+
colorSpace: "RGB",
|
|
337
|
+
dtype: "uint8",
|
|
338
|
+
tag: "mountain", // Detection label
|
|
339
|
+
confidence: 0.98, // Detection confidence
|
|
340
|
+
bbox: { // Crop coordinates in pixels
|
|
341
|
+
x: 100, y: 50, width: 150, height: 200,
|
|
342
|
+
normalized: {x1: 0.1, y1: 0.2, x2: 0.4, y2: 0.6}
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
data: Buffer,
|
|
347
|
+
width: 80,
|
|
348
|
+
height: 120,
|
|
349
|
+
channels: 3,
|
|
350
|
+
colorSpace: "RGB",
|
|
351
|
+
dtype: "uint8",
|
|
352
|
+
tag: "sky",
|
|
353
|
+
confidence: 0.92,
|
|
354
|
+
bbox: {
|
|
355
|
+
x: 300, y: 200, width: 80, height: 120,
|
|
356
|
+
normalized: {x1: 0.5, y1: 0.1, x2: 0.9, y2: 0.4}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
]</pre>
|
|
360
|
+
|
|
361
|
+
<h3>Usage</h3>
|
|
362
|
+
<p>Each array element can be directly used as an image input to other nodes:</p>
|
|
363
|
+
<pre>// Access first crop directly
|
|
364
|
+
msg.payload[0] // {data, width, height, channels, colorSpace, tag, confidence, bbox}
|
|
365
|
+
|
|
366
|
+
// Use in image-out node
|
|
367
|
+
msg.payload = crops[0]; // No need for crops[0].crop
|
|
368
|
+
|
|
369
|
+
// Filter by tag
|
|
370
|
+
const mountains = crops.filter(c => c.tag === "mountain");
|
|
371
|
+
|
|
372
|
+
// Sort by confidence
|
|
373
|
+
crops.sort((a, b) => b.confidence - a.confidence);</pre>
|
|
374
|
+
|
|
375
|
+
<h3>Performance</h3>
|
|
376
|
+
<p>Uses optimized C++ backend for fast crop extraction. Multiple crops are processed in parallel for best performance.</p>
|
|
377
|
+
</script>
|
|
378
|
+
|
|
189
379
|
<script type="text/html" data-help-name="cropBB">
|
|
190
380
|
<p>Extracts image crops from bounding boxes detected by inference models.</p>
|
|
191
381
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
|
|
2
|
+
var _rpNodeCfg = {
|
|
3
3
|
category: 'RP Image',
|
|
4
4
|
color: '#DDA0DD',
|
|
5
5
|
defaults: {
|
|
@@ -178,7 +178,9 @@
|
|
|
178
178
|
$('#node-input-preset').on('change', updatePresetDescription);
|
|
179
179
|
updatePresetDescription();
|
|
180
180
|
}
|
|
181
|
-
}
|
|
181
|
+
};
|
|
182
|
+
RED.nodes.registerType('rp-image-align', _rpNodeCfg);
|
|
183
|
+
RED.nodes.registerType('image-align', Object.assign({}, _rpNodeCfg, { category: 'deprecated' }));
|
|
182
184
|
|
|
183
185
|
// Debug image display renderer (shared)
|
|
184
186
|
if (!window.debugImageRendererInitialized) {
|
|
@@ -294,6 +296,145 @@
|
|
|
294
296
|
}
|
|
295
297
|
</script>
|
|
296
298
|
|
|
299
|
+
<script type="text/x-red" data-template-name="rp-image-align">
|
|
300
|
+
<div class="form-row">
|
|
301
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
302
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<hr>
|
|
306
|
+
|
|
307
|
+
<div class="form-row">
|
|
308
|
+
<label for="node-input-referenceImagePath"><i class="fa fa-photo"></i> Reference Image</label>
|
|
309
|
+
<input type="text" id="node-input-referenceImagePath" style="width: 70%;">
|
|
310
|
+
<input type="hidden" id="node-input-referenceImagePathType">
|
|
311
|
+
</div>
|
|
312
|
+
<div class="form-row">
|
|
313
|
+
<label for="node-input-targetImagePath"><i class="fa fa-photo"></i> Target Image</label>
|
|
314
|
+
<input type="text" id="node-input-targetImagePath" style="width: 70%;">
|
|
315
|
+
<input type="hidden" id="node-input-targetImagePathType">
|
|
316
|
+
</div>
|
|
317
|
+
<div class="form-row">
|
|
318
|
+
<label for="node-input-outputPath"><i class="fa fa-sign-out"></i> Output to</label>
|
|
319
|
+
<input type="text" id="node-input-outputPath" style="width: 70%;">
|
|
320
|
+
<input type="hidden" id="node-input-outputPathType">
|
|
321
|
+
</div>
|
|
322
|
+
|
|
323
|
+
<div class="form-row">
|
|
324
|
+
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
325
|
+
<select id="node-input-outputFormat" style="width: 200px;">
|
|
326
|
+
<option value="raw">Raw (fastest)</option>
|
|
327
|
+
<option value="jpg">JPEG</option>
|
|
328
|
+
<option value="png">PNG</option>
|
|
329
|
+
<option value="webp">WebP</option>
|
|
330
|
+
</select>
|
|
331
|
+
</div>
|
|
332
|
+
<div class="form-row" id="quality-row">
|
|
333
|
+
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
334
|
+
<input type="number" id="node-input-outputQuality" min="1" max="100" value="90" style="width: 70px;">
|
|
335
|
+
<span style="margin-left: 10px; color: #666;">1-100 (JPG/WebP only)</span>
|
|
336
|
+
</div>
|
|
337
|
+
<div class="form-row" id="png-optimize-row" style="display: none;">
|
|
338
|
+
<label for="node-input-pngOptimize"><i class="fa fa-compress"></i> PNG Optimize</label>
|
|
339
|
+
<input type="checkbox" id="node-input-pngOptimize" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
340
|
+
<label for="node-input-pngOptimize" style="width:auto; margin-left:5px;">Compress PNG (slower, smaller file)</label>
|
|
341
|
+
</div>
|
|
342
|
+
<div class="form-row" id="webp-lossless-row" style="display: none;">
|
|
343
|
+
<label for="node-input-webpLossless"><i class="fa fa-lock"></i> Lossless</label>
|
|
344
|
+
<input type="checkbox" id="node-input-webpLossless" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
345
|
+
<label for="node-input-webpLossless" style="width:auto; margin-left:5px;">Encode WebP without loss</label>
|
|
346
|
+
</div>
|
|
347
|
+
<div class="form-row" id="webp-smartsubsample-row" style="display: none;">
|
|
348
|
+
<label for="node-input-webpSmartSubsample"><i class="fa fa-magic"></i> Smart Subsample</label>
|
|
349
|
+
<input type="checkbox" id="node-input-webpSmartSubsample" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
350
|
+
<label for="node-input-webpSmartSubsample" style="width:auto; margin-left:5px;">Better chroma downsampling (lossy only)</label>
|
|
351
|
+
</div>
|
|
352
|
+
<div class="form-row" id="webp-effort-row" style="display: none;">
|
|
353
|
+
<label for="node-input-webpEffort"><i class="fa fa-tachometer"></i> Effort</label>
|
|
354
|
+
<input type="number" id="node-input-webpEffort" min="0" max="6" placeholder="4" style="width: 70px;">
|
|
355
|
+
<span style="margin-left: 10px; color: #666;">0-6 (higher = smaller file, slower)</span>
|
|
356
|
+
</div>
|
|
357
|
+
|
|
358
|
+
<!-- Return Matrix Option -->
|
|
359
|
+
<div class="form-row">
|
|
360
|
+
<label for="node-input-returnMatrix"><i class="fa fa-calculator"></i> Transform Matrix</label>
|
|
361
|
+
<input type="checkbox" id="node-input-returnMatrix" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
362
|
+
<label for="node-input-returnMatrix" style="width:auto; margin-left:5px;">Return transformation matrix</label>
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
<!-- Transform Polygon Option -->
|
|
366
|
+
<div class="form-row">
|
|
367
|
+
<label for="node-input-transformPolygon"><i class="fa fa-draw-polygon"></i> Transform Polygon</label>
|
|
368
|
+
<input type="checkbox" id="node-input-transformPolygon" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
369
|
+
<label for="node-input-transformPolygon" style="width:auto; margin-left:5px;">Transform polygon coordinates</label>
|
|
370
|
+
</div>
|
|
371
|
+
<div class="form-row" id="polygon-path-row" style="display: none;">
|
|
372
|
+
<label for="node-input-polygonPath"><i class="fa fa-map-marker"></i> Polygon Path</label>
|
|
373
|
+
<input type="text" id="node-input-polygonPath" style="width: 70%;">
|
|
374
|
+
<input type="hidden" id="node-input-polygonPathType">
|
|
375
|
+
</div>
|
|
376
|
+
|
|
377
|
+
<!-- Debug Configuration -->
|
|
378
|
+
<div class="form-row">
|
|
379
|
+
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
380
|
+
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
381
|
+
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show aligned image</label>
|
|
382
|
+
</div>
|
|
383
|
+
<div class="form-row" id="debug-width-row" style="display: none;">
|
|
384
|
+
<label for="node-input-debugWidth"><i class="fa fa-arrows-h"></i> Debug Width</label>
|
|
385
|
+
<input type="text" id="node-input-debugWidth" style="width: 120px;">
|
|
386
|
+
<input type="hidden" id="node-input-debugWidthType">
|
|
387
|
+
<span style="margin-left: 10px; color: #666;">pixels</span>
|
|
388
|
+
</div>
|
|
389
|
+
|
|
390
|
+
<hr>
|
|
391
|
+
|
|
392
|
+
<div class="form-row">
|
|
393
|
+
<label for="node-input-preset"><i class="fa fa-tachometer"></i> Speed Preset</label>
|
|
394
|
+
<select id="node-input-preset" style="width: 200px;">
|
|
395
|
+
<option value="ultra-fast">Ultra Fast</option>
|
|
396
|
+
<option value="fast">Fast</option>
|
|
397
|
+
<option value="balanced">Balanced</option>
|
|
398
|
+
<option value="quality">Quality</option>
|
|
399
|
+
<option value="custom">Custom</option>
|
|
400
|
+
</select>
|
|
401
|
+
</div>
|
|
402
|
+
<div class="form-row">
|
|
403
|
+
<label></label>
|
|
404
|
+
<div id="preset-description" style="font-size: 12px; color: #666; margin-top: 5px;"></div>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
<!-- Custom Parameters (only visible when Custom preset selected) -->
|
|
408
|
+
<div id="custom-parameters" style="display: none;">
|
|
409
|
+
<div class="form-row">
|
|
410
|
+
<label for="node-input-customScale"><i class="fa fa-search"></i> Scale</label>
|
|
411
|
+
<input type="text" id="node-input-customScale" style="width: 200px;">
|
|
412
|
+
<input type="hidden" id="node-input-customScaleType">
|
|
413
|
+
<span style="margin-left: 10px; color: #666;">0.1-1.0 (image downscale factor)</span>
|
|
414
|
+
</div>
|
|
415
|
+
<div class="form-row">
|
|
416
|
+
<label for="node-input-customMaxIterations"><i class="fa fa-repeat"></i> Max Iterations</label>
|
|
417
|
+
<input type="text" id="node-input-customMaxIterations" style="width: 200px;">
|
|
418
|
+
<input type="hidden" id="node-input-customMaxIterationsType">
|
|
419
|
+
<span style="margin-left: 10px; color: #666;">1-200 (alignment iterations)</span>
|
|
420
|
+
</div>
|
|
421
|
+
<div class="form-row">
|
|
422
|
+
<label for="node-input-customTerminationEps"><i class="fa fa-bullseye"></i> Termination Eps</label>
|
|
423
|
+
<input type="text" id="node-input-customTerminationEps" style="width: 200px;">
|
|
424
|
+
<input type="hidden" id="node-input-customTerminationEpsType">
|
|
425
|
+
<span style="margin-left: 10px; color: #666;">0.000001-0.1 (convergence threshold)</span>
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<div class="form-tips">
|
|
430
|
+
<b>Flexible Paths:</b> Configure where to find reference and target images in your message.<br>
|
|
431
|
+
<b>Default:</b> <code>msg.payload.reference</code> and <code>msg.payload.target</code><br>
|
|
432
|
+
<b>Output:</b> Returns the aligned target image. Alignment info is added to <code>msg.alignment</code>.<br>
|
|
433
|
+
<b>Transform Matrix:</b> When enabled, includes transformation matrix with <code>dx</code>, <code>dy</code> translation values, 2x3 OpenCV matrix, and 3x3 homogeneous matrix.<br>
|
|
434
|
+
<b>Transform Polygon:</b> When enabled, transforms polygon coordinates using the same alignment transformation. Expects normalized coordinates (0-1 range) in the same format as add-mask node.
|
|
435
|
+
</div>
|
|
436
|
+
</script>
|
|
437
|
+
|
|
297
438
|
<script type="text/x-red" data-template-name="image-align">
|
|
298
439
|
<div class="form-row">
|
|
299
440
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
@@ -433,6 +574,123 @@
|
|
|
433
574
|
</div>
|
|
434
575
|
</script>
|
|
435
576
|
|
|
577
|
+
<script type="text/x-red" data-help-name="rp-image-align">
|
|
578
|
+
<p>Aligns images using ultra-fast ECC (Enhanced Correlation Coefficient) algorithm with OpenCV backend for maximum performance.</p>
|
|
579
|
+
|
|
580
|
+
<h3>Details</h3>
|
|
581
|
+
<p>This node performs image alignment by finding the transformation needed to align a target image with a reference image. It uses OpenCV's ECC algorithm optimized for speed with configurable precision levels. The aligned target image is returned as output.</p>
|
|
582
|
+
|
|
583
|
+
<h3>Properties</h3>
|
|
584
|
+
<dl class="message-properties">
|
|
585
|
+
<dt>Reference Image <span class="property-type">string</span></dt>
|
|
586
|
+
<dd>Path to reference image in message. Defaults to <code>msg.payload.reference</code>.</dd>
|
|
587
|
+
<dt>Target Image <span class="property-type">string</span></dt>
|
|
588
|
+
<dd>Path to target image in message. Defaults to <code>msg.payload.target</code>.</dd>
|
|
589
|
+
<dt>Output to <span class="property-type">string</span></dt>
|
|
590
|
+
<dd>Location where aligned image will be stored. Defaults to <code>msg.payload</code>.</dd>
|
|
591
|
+
<dt>Output Format <span class="property-type">string</span></dt>
|
|
592
|
+
<dd>Output format: <code>raw</code> (fastest), <code>jpg</code>, <code>png</code>, or <code>webp</code>.</dd>
|
|
593
|
+
<dt>Speed Preset <span class="property-type">string</span></dt>
|
|
594
|
+
<dd>Alignment speed/quality balance: <code>ultra-fast</code>, <code>fast</code>, <code>balanced</code>, or <code>quality</code>.</dd>
|
|
595
|
+
<dt>Transform Polygon <span class="property-type">boolean</span></dt>
|
|
596
|
+
<dd>When enabled, transforms polygon coordinates from the specified path using the alignment transformation.</dd>
|
|
597
|
+
<dt>Polygon Path <span class="property-type">string</span></dt>
|
|
598
|
+
<dd>Path to polygon coordinates in message. Expected format: array of [x, y] pairs with normalized values (0-1 range).</dd>
|
|
599
|
+
</dl>
|
|
600
|
+
|
|
601
|
+
<h3>Inputs</h3>
|
|
602
|
+
<dl class="message-properties">
|
|
603
|
+
<dt>Images <span class="property-type">object</span></dt>
|
|
604
|
+
<dd>Both images must be in standard format: <code>{data: Buffer, width: number, height: number, channels: number, colorSpace: string}</code>. Images can be located anywhere in the message using the configurable paths.</dd>
|
|
605
|
+
</dl>
|
|
606
|
+
|
|
607
|
+
<h3>Outputs</h3>
|
|
608
|
+
<dl class="message-properties">
|
|
609
|
+
<dt>payload <span class="property-type">object|Buffer</span></dt>
|
|
610
|
+
<dd>Aligned target image in specified output format.</dd>
|
|
611
|
+
<dt>alignment <span class="property-type">object</span></dt>
|
|
612
|
+
<dd>Alignment information:
|
|
613
|
+
<ul>
|
|
614
|
+
<li><code>success</code>: boolean indicating alignment success</li>
|
|
615
|
+
<li><code>timing</code>: processing timing breakdown</li>
|
|
616
|
+
<li><code>preset</code>: speed preset used</li>
|
|
617
|
+
<li><code>transformMatrix</code>: (optional) transformation matrix when enabled:
|
|
618
|
+
<ul>
|
|
619
|
+
<li><code>dx</code>: horizontal translation in pixels</li>
|
|
620
|
+
<li><code>dy</code>: vertical translation in pixels</li>
|
|
621
|
+
<li><code>matrix2x3</code>: OpenCV 2x3 matrix format [a, b, dx, c, d, dy]</li>
|
|
622
|
+
<li><code>matrix3x3</code>: standard 3x3 homogeneous matrix [a, b, dx, c, d, dy, 0, 0, 1]</li>
|
|
623
|
+
<li><code>transform</code>: alias for matrix3x3 (backward compatibility)</li>
|
|
624
|
+
</ul>
|
|
625
|
+
</li>
|
|
626
|
+
<li><code>originalPolygon</code>: (optional) original polygon coordinates when Transform Polygon is enabled</li>
|
|
627
|
+
<li><code>transformedPolygon</code>: (optional) transformed polygon coordinates in same normalized format (0-1 range)</li>
|
|
628
|
+
</ul>
|
|
629
|
+
</dd>
|
|
630
|
+
</dl>
|
|
631
|
+
|
|
632
|
+
<h3>Speed Presets</h3>
|
|
633
|
+
<ul>
|
|
634
|
+
<li><strong>Ultra Fast:</strong> Maximum speed, basic accuracy (scale: 0.2, iterations: 10)</li>
|
|
635
|
+
<li><strong>Fast:</strong> Good speed, decent accuracy (scale: 0.3, iterations: 20)</li>
|
|
636
|
+
<li><strong>Balanced:</strong> Balanced speed and accuracy (scale: 0.5, iterations: 30)</li>
|
|
637
|
+
<li><strong>Quality:</strong> Best accuracy, slower processing (scale: 0.7, iterations: 50)</li>
|
|
638
|
+
<li><strong>Custom:</strong> Manual parameter control:
|
|
639
|
+
<ul>
|
|
640
|
+
<li><code>Scale</code>: Image downscale factor (0.1-1.0) - smaller values = faster processing</li>
|
|
641
|
+
<li><code>Max Iterations</code>: Maximum alignment iterations (1-200) - more iterations = better accuracy</li>
|
|
642
|
+
<li><code>Termination Eps</code>: Convergence threshold (0.000001-0.1) - smaller values = stricter convergence</li>
|
|
643
|
+
</ul>
|
|
644
|
+
</li>
|
|
645
|
+
</ul>
|
|
646
|
+
|
|
647
|
+
<h3>Algorithm Details</h3>
|
|
648
|
+
<p>Uses OpenCV's <code>findTransformECC</code> with <code>MOTION_TRANSLATION</code> for ultra-fast translation-only alignment:</p>
|
|
649
|
+
<ul>
|
|
650
|
+
<li>Images are downscaled for speed (configurable scale factor)</li>
|
|
651
|
+
<li>ECC alignment finds optimal translation transform</li>
|
|
652
|
+
<li>Transform is scaled back to full resolution and applied</li>
|
|
653
|
+
<li>Target image dimensions are adjusted to match reference</li>
|
|
654
|
+
</ul>
|
|
655
|
+
|
|
656
|
+
<h3>Flexible Input Configuration</h3>
|
|
657
|
+
<p>Configure where to find images in your message using the path settings:</p>
|
|
658
|
+
<ul>
|
|
659
|
+
<li><strong>Default:</strong> <code>msg.payload.reference</code> and <code>msg.payload.target</code></li>
|
|
660
|
+
<li><strong>Custom paths:</strong> <code>msg.referenceImage</code> and <code>msg.targetToAlign</code></li>
|
|
661
|
+
<li><strong>Flow context:</strong> <code>flow.template</code> and <code>msg.sample</code></li>
|
|
662
|
+
<li><strong>Global context:</strong> <code>global.baseImage</code> and <code>msg.testImage</code></li>
|
|
663
|
+
</ul>
|
|
664
|
+
|
|
665
|
+
<h3>Usage Examples</h3>
|
|
666
|
+
<pre><code>// Default structure (payload.reference & payload.target)
|
|
667
|
+
msg.payload = {
|
|
668
|
+
reference: { data: Buffer, width: 800, height: 600, channels: 3, colorSpace: "BGR" },
|
|
669
|
+
target: { data: Buffer, width: 800, height: 600, channels: 3, colorSpace: "BGR" }
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
// Custom paths (configure: referenceImage & targetImage)
|
|
673
|
+
msg.referenceImage = { data: Buffer, width: 800, height: 600, channels: 3, colorSpace: "BGR" };
|
|
674
|
+
msg.targetImage = { data: Buffer, width: 800, height: 600, channels: 3, colorSpace: "BGR" };
|
|
675
|
+
|
|
676
|
+
// Mixed sources (configure: flow.template & payload)
|
|
677
|
+
flow.set("template", referenceImageObject);
|
|
678
|
+
msg.payload = targetImageObject;</code></pre>
|
|
679
|
+
|
|
680
|
+
<h3>Common Workflows</h3>
|
|
681
|
+
<ul>
|
|
682
|
+
<li><strong>Quality Control:</strong> Image-in → Image-align → comparison analysis</li>
|
|
683
|
+
<li><strong>Template Matching:</strong> Template + samples → Image-align → feature extraction</li>
|
|
684
|
+
<li><strong>Multi-camera Calibration:</strong> Reference view + other views → Image-align → unified coordinate system</li>
|
|
685
|
+
</ul>
|
|
686
|
+
|
|
687
|
+
<h3>Performance</h3>
|
|
688
|
+
<p>Optimized for real-time processing with sub-50ms typical processing times. Uses downscaled alignment for speed while maintaining accuracy for most use cases.</p>
|
|
689
|
+
|
|
690
|
+
<h3>Error Handling</h3>
|
|
691
|
+
<p>If alignment fails, the target image is resized to match reference dimensions and returned. Check <code>msg.alignment.success</code> for alignment status.</p>
|
|
692
|
+
</script>
|
|
693
|
+
|
|
436
694
|
<script type="text/x-red" data-help-name="image-align">
|
|
437
695
|
<p>Aligns images using ultra-fast ECC (Enhanced Correlation Coefficient) algorithm with OpenCV backend for maximum performance.</p>
|
|
438
696
|
|