@rosepetal/node-red-contrib-image-tools 1.1.3

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.
Files changed (131) hide show
  1. package/.gitattributes +6 -0
  2. package/.github/workflows/build-prebuild.yml +326 -0
  3. package/LICENSE +13 -0
  4. package/README.md +161 -0
  5. package/artifacts/darwin-arm64/package.json +25 -0
  6. package/artifacts/linux-arm64/package.json +26 -0
  7. package/artifacts/linux-x64/package.json +26 -0
  8. package/artifacts/linuxmusl-x64/package.json +26 -0
  9. package/assets/flow_time_example.gif +0 -0
  10. package/assets/nodes/io/array-in-demo.gif +0 -0
  11. package/assets/nodes/io/array-out-demo.gif +0 -0
  12. package/assets/nodes/io/array-select-demo.gif +0 -0
  13. package/assets/nodes/io/image-in-demo.gif +0 -0
  14. package/assets/nodes/mix/concat-demo.gif +0 -0
  15. package/assets/nodes/mix/mosaic-demo.gif +0 -0
  16. package/assets/nodes/transform/crop-demo.gif +0 -0
  17. package/assets/nodes/transform/filter-demo.gif +0 -0
  18. package/assets/nodes/transform/padding-demo.gif +0 -0
  19. package/assets/nodes/transform/resize-demo.gif +0 -0
  20. package/assets/nodes/transform/rotate-demo.gif +0 -0
  21. package/docs/nodes/blend/add-mask.md +275 -0
  22. package/docs/nodes/blend/add-masks.md +284 -0
  23. package/docs/nodes/blend/blend.md +248 -0
  24. package/docs/nodes/io/array-in.md +119 -0
  25. package/docs/nodes/io/array-out.md +150 -0
  26. package/docs/nodes/io/array-select.md +157 -0
  27. package/docs/nodes/io/image-in.md +131 -0
  28. package/docs/nodes/io/image-out.md +179 -0
  29. package/docs/nodes/io/queue.md +57 -0
  30. package/docs/nodes/io/save-file.md +30 -0
  31. package/docs/nodes/mix/advanced-mosaic.md +108 -0
  32. package/docs/nodes/mix/concat.md +127 -0
  33. package/docs/nodes/mix/mosaic.md +146 -0
  34. package/docs/nodes/specialized/cropBB.md +271 -0
  35. package/docs/nodes/specialized/image-align.md +426 -0
  36. package/docs/nodes/transform/crop.md +132 -0
  37. package/docs/nodes/transform/draw.md +77 -0
  38. package/docs/nodes/transform/filter.md +84 -0
  39. package/docs/nodes/transform/padding.md +133 -0
  40. package/docs/nodes/transform/resize.md +158 -0
  41. package/docs/nodes/transform/rotate.md +121 -0
  42. package/docs/nodes/util/block-detect.md +46 -0
  43. package/install.sh +144 -0
  44. package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
  45. package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
  46. package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
  47. package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
  48. package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
  49. package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
  50. package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
  51. package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
  52. package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
  53. package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
  54. package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
  55. package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
  56. package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
  57. package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
  58. package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
  59. package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
  60. package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
  61. package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
  62. package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
  63. package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
  64. package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
  65. package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
  66. package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
  67. package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
  68. package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
  69. package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
  70. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
  71. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
  72. package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
  73. package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
  74. package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
  75. package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
  76. package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
  77. package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
  78. package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
  79. package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
  80. package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
  81. package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
  82. package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
  83. package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
  84. package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
  85. package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
  86. package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
  87. package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
  88. package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
  89. package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
  90. package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
  91. package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
  92. package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
  93. package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
  94. package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
  95. package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
  96. package/node-red-contrib-image-tools/package.json +64 -0
  97. package/npm/darwin-arm64/lib/.gitkeep +1 -0
  98. package/npm/darwin-arm64/package.json +25 -0
  99. package/npm/darwin-x64/lib/.gitkeep +1 -0
  100. package/npm/darwin-x64/package.json +25 -0
  101. package/npm/linux-arm64/lib/.gitkeep +1 -0
  102. package/npm/linux-arm64/package.json +26 -0
  103. package/npm/linux-x64/lib/.gitkeep +1 -0
  104. package/npm/linux-x64/package.json +26 -0
  105. package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
  106. package/npm/linuxmusl-x64/package.json +26 -0
  107. package/npm/win32-x64/lib/.gitkeep +1 -0
  108. package/npm/win32-x64/package.json +25 -0
  109. package/package.json +74 -0
  110. package/rosepetal-image-engine/binding.gyp +153 -0
  111. package/rosepetal-image-engine/package.json +19 -0
  112. package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
  113. package/rosepetal-image-engine/src/add-mask.cpp +240 -0
  114. package/rosepetal-image-engine/src/add-masks.cpp +638 -0
  115. package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
  116. package/rosepetal-image-engine/src/blend.cpp +200 -0
  117. package/rosepetal-image-engine/src/concat.cpp +329 -0
  118. package/rosepetal-image-engine/src/crop.cpp +139 -0
  119. package/rosepetal-image-engine/src/draw.cpp +414 -0
  120. package/rosepetal-image-engine/src/filter.cpp +230 -0
  121. package/rosepetal-image-engine/src/filters/kernels.h +171 -0
  122. package/rosepetal-image-engine/src/image-align.cpp +551 -0
  123. package/rosepetal-image-engine/src/main.cpp +36 -0
  124. package/rosepetal-image-engine/src/mosaic.cpp +373 -0
  125. package/rosepetal-image-engine/src/padding.cpp +124 -0
  126. package/rosepetal-image-engine/src/resize.cpp +210 -0
  127. package/rosepetal-image-engine/src/rotate.cpp +177 -0
  128. package/rosepetal-image-engine/src/utils.h +563 -0
  129. package/rosepetal-image-engine/test-formats.js +119 -0
  130. package/scripts/build-opencv-static.ps1 +166 -0
  131. package/scripts/build-opencv-static.sh +147 -0
@@ -0,0 +1,146 @@
1
+ # Mosaic Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `mosaic` node provides manual positioning of multiple images on a canvas with precise coordinate control. It creates composite images by placing images at specific positions, supporting both normalized (0-1) and pixel coordinates for flexible layout creation.
6
+
7
+ **Real-World Applications:**
8
+ - **Custom Layouts**: Create precise image arrangements with exact positioning
9
+ - **Template-Based Designs**: Position images according to predefined layout templates
10
+ - **Overlay Compositions**: Layer images at specific positions for complex compositions
11
+ - **Dashboard Assembly**: Position charts and data visualizations with pixel precision
12
+ - **Print Design**: Create exact layouts for brochures, posters, and marketing materials
13
+
14
+ ![Mosaic Demo](../../../assets/nodes/mix/mosaic-demo.gif)
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Image Array**: Array of image objects to position on canvas
20
+ - **Position Configuration**: Position mappings defined in node configuration
21
+ - **Canvas Parameters**: Canvas dimensions and background settings
22
+
23
+ ### Outputs
24
+ - **Composite Image**: Single image with positioned elements on canvas
25
+ - **Fixed Canvas Size**: Canvas dimensions as configured
26
+ - **Format Options**: Raw image object or encoded file formats
27
+
28
+ ## Configuration Options
29
+
30
+ ### Input/Output Paths
31
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
32
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
33
+
34
+ ### Canvas Configuration
35
+
36
+ #### Canvas Dimensions
37
+ - **Canvas Width**: Width of output canvas in pixels
38
+ - **Canvas Height**: Height of output canvas in pixels
39
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
40
+
41
+ #### Background Settings
42
+ - **Background Color**: Color for empty canvas areas
43
+ - **Default**: Black
44
+ - **Formats**: RGB (`rgb(255,0,0)`)
45
+
46
+ ### Positioning System
47
+
48
+ #### Coordinate System
49
+ - **Normalized Mode**: Values from 0.0 to 1.0 (relative to canvas dimensions)
50
+ - **Pixel Mode**: Absolute pixel coordinates
51
+
52
+ #### Position Configuration
53
+ - **Position Mappings**: Array of position configurations in node editor
54
+ - **Array Index**: Which image from input array to position
55
+ - **X/Y Coordinates**: Position on canvas (normalized or pixel)
56
+ - **Per-Image Control**: Individual positioning for each image
57
+
58
+ ### Output Format Options
59
+ - **Raw**: Standard image object (fastest for processing chains)
60
+ - **JPEG**: Compressed with quality control
61
+ - **PNG**: Lossless with transparency support
62
+ - **WebP**: Modern format with excellent compression
63
+
64
+ ## Performance Notes
65
+
66
+ ### C++ Backend Processing
67
+ - **Optimized Canvas Composition**: Efficient positioning and placement on fixed canvas
68
+ - **Memory Management**: Pre-allocated canvas with optimal memory usage
69
+ - **Batch Placement**: All images positioned in single C++ operation
70
+ - **Coordinate Validation**: Automatic bounds checking and position validation
71
+
72
+ ### Position Processing
73
+ - **Coordinate Transformation**: Efficient conversion between normalized and pixel coordinates
74
+ - **Bounds Checking**: Automatic validation of positions within canvas boundaries
75
+ - **Layer Management**: Proper handling of image placement order and overlaps
76
+
77
+ ## Real-World Examples
78
+
79
+ ### Custom Dashboard Layout
80
+ ```javascript
81
+ // In function node: set specific positions for dashboard elements
82
+
83
+ { arrayIndex: 0, x: 0, y: 0 } // Chart at top-left
84
+ { arrayIndex: 1, x: 400, y: 0 } // KPI at top-right
85
+ { arrayIndex: 2, x: 0, y: 300 } // Graph at bottom-left
86
+ { arrayIndex: 3, x: 400, y: 300 } // Table at bottom-right
87
+
88
+ ```
89
+ ```
90
+ [Dashboard Elements] → [Function: Set Positions] → [Mosaic: 800x600 canvas] → [Dashboard]
91
+ ```
92
+
93
+ ### Template-Based Layout
94
+ ```javascript
95
+ // Predefined layout template positions
96
+
97
+ { arrayIndex: 0, x: 0.1, y: 0.1 } // Normalized coordinates
98
+ { arrayIndex: 1, x: 0.6, y: 0.1 } // 10% and 60% from left
99
+ { arrayIndex: 2, x: 0.1, y: 0.6 } // 10% and 60% from top
100
+
101
+ ```
102
+ ```
103
+ [Content Images] → [Function: Apply Template] → [Mosaic: Normalized coords] → [Layout]
104
+ ```
105
+
106
+ ### Overlay Composition
107
+ ```
108
+ [Base Image] → [Array-In: pos=0] ┐
109
+ [Logo Overlay] → [Array-In: pos=1] ├→ [Function: Set Positions] → [Mosaic: Canvas] → [Branded Image]
110
+ [Text Overlay] → [Array-In: pos=2] ┘
111
+ ```
112
+ Position logos and text overlays at specific coordinates.
113
+
114
+ ### Print Layout Design
115
+ ```javascript
116
+ // Precise positioning for print layout
117
+ canvasWidth = 1200; // Print width
118
+ canvasHeight = 1800; // Print height
119
+ { arrayIndex: 0, x: 100, y: 100 } // Header image
120
+ { arrayIndex: 1, x: 100, y: 400 } // Content image
121
+ { arrayIndex: 2, x: 100, y: 1200 } // Footer image
122
+
123
+ ```
124
+
125
+ ## Common Issues & Troubleshooting
126
+
127
+ ### Position Configuration Errors
128
+ - **Issue**: Images not appearing or positioned incorrectly
129
+ - **Solution**: Verify arrayIndex values match input array length
130
+ - **Validation**: Check that positions array contains valid coordinates
131
+
132
+ ### Coordinate System Confusion
133
+ - **Issue**: Images appearing in wrong locations
134
+ - **Solution**: Verify normalized vs. pixel coordinate mode matches your values
135
+ - **Normalized**: Use 0-1 values for relative positioning
136
+ - **Pixel**: Use absolute coordinates within canvas bounds
137
+
138
+ ### Canvas Size Problems
139
+ - **Issue**: Images clipped or positioned outside visible area
140
+ - **Solution**: Ensure canvas dimensions accommodate all positioned images
141
+ - **Planning**: Calculate required canvas size based on image positions and sizes
142
+
143
+ ### Position Array Mismatches
144
+ - **Issue**: ArrayIndex references non-existent images
145
+ - **Result**: Images ignored with warnings logged
146
+ - **Solution**: Validate arrayIndex values against input array length
@@ -0,0 +1,271 @@
1
+ # CropBB Node (Crop Bounding Boxes)
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `cropBB` node is specialized for AI/ML workflows, extracting image crops from object detection bounding box results. It processes detection data and extracts individual objects or regions of interest from images, making it essential for computer vision pipelines.
6
+
7
+ **Real-World Applications:**
8
+ - **Object Detection Workflows**: Extract detected objects from AI analysis results
9
+ - **Quality Control Systems**: Crop defective areas identified by inspection AI
10
+ - **Security/Surveillance**: Extract detected persons or objects from camera feeds
11
+ - **Medical Imaging**: Extract abnormalities or regions of interest from diagnostic scans
12
+ - **E-commerce Automation**: Extract product images from catalog photos using AI detection
13
+
14
+ *[PLACEHOLDER - Add GIF showing AI detection results being converted to individual cropped objects]*
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Images**: Single image or array of images to crop from
20
+ - **Detection Data**: Bounding box detection results from AI/ML inference
21
+ - **Confidence Filtering**: Minimum confidence threshold for including detections
22
+
23
+ ### Detection Data Format
24
+ The node expects detection results in this format:
25
+ ```javascript
26
+ [
27
+ {
28
+ "box": [[x1,y1], [x2,y1], [x2,y2], [x1,y2]], // Normalized 0-1 coordinates
29
+ "confidence": 0.97,
30
+ "class_name": "person",
31
+ "class_tag": 3
32
+ },
33
+ // ... more detections
34
+ ]
35
+ ```
36
+
37
+ ### Outputs
38
+ ```javascript
39
+ [
40
+ {
41
+ crop: ImageObject, // Cropped image
42
+ tag: {
43
+ label: "person", // Detection class name
44
+ confidence: 0.97, // Detection confidence
45
+ bbox: { // Bounding box information
46
+ x: 150, y: 100, // Pixel coordinates
47
+ width: 200, height: 300,
48
+ normalized: { x1: 0.1, y1: 0.2, x2: 0.3, y2: 0.5 }
49
+ }
50
+ }
51
+ },
52
+ // ... more crops
53
+ ]
54
+ ```
55
+
56
+ ## Configuration Options
57
+
58
+ ### Input Paths
59
+ - **Image Input Path**: Location of source images (default: `msg.images`)
60
+ - **Bounding Box Input Path**: Location of detection data (default: `msg.default`)
61
+ - **Path Sources**: `msg.*`, `flow.*`, `global.*`
62
+
63
+ ### Output Configuration
64
+ - **Output Path**: Where to store crop results (default: `msg.payload`)
65
+ - **Output Format**: Raw, JPEG, PNG, or WebP
66
+ - **Quality Settings**: Compression settings for encoded formats
67
+
68
+ ### Detection Filtering
69
+
70
+ #### Minimum Confidence
71
+ - **Range**: 0.0 to 1.0 (0% to 100%)
72
+ - **Default**: 0.5 (50% confidence)
73
+ - **Purpose**: Filter out low-confidence detections
74
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
75
+
76
+ #### Class Filtering
77
+ - **Specific Classes**: Only crop detections of specified classes
78
+ - **Class Names**: Filter by class_name field (e.g., "person", "car")
79
+ - **Class Tags**: Filter by numeric class_tag field
80
+
81
+ ### Processing Options
82
+
83
+ #### Coordinate Handling
84
+ - **Normalized Input**: Handles 0-1 coordinate format (standard)
85
+ - **Pixel Conversion**: Automatically converts to pixel coordinates
86
+ - **Bounds Clipping**: Ensures crops stay within image boundaries
87
+ - **Validation**: Checks for valid box formats and dimensions
88
+
89
+ #### Output Format Options
90
+ - **Raw**: Standard image objects (fastest for processing chains)
91
+ - **JPEG**: Compressed crops with quality control
92
+ - **PNG**: Lossless crops preserving quality
93
+ - **WebP**: Modern format with excellent compression
94
+
95
+ ## Performance Notes
96
+
97
+ ### C++ Backend Processing
98
+ - **Parallel Cropping**: Multiple crops extracted simultaneously
99
+ - **Memory Efficient**: Direct region extraction without full image copying
100
+ - **Bounds Checking**: Automatic coordinate validation and clipping
101
+ - **Batch Processing**: Optimized for multiple detections per image
102
+
103
+ ### Detection Processing
104
+ - **Format Validation**: Robust parsing of various detection formats
105
+ - **Coordinate Conversion**: Efficient normalized-to-pixel coordinate conversion
106
+ - **Confidence Filtering**: Fast threshold-based filtering before cropping
107
+ - **Error Handling**: Graceful handling of malformed detection data
108
+
109
+ ## Real-World Examples
110
+
111
+ ### Object Detection Pipeline
112
+ ```
113
+ [Image] → [AI Detection Model] → [CropBB: confidence=0.7] → [Individual Objects]
114
+ ```
115
+ Extract all detected objects with 70%+ confidence from AI analysis.
116
+
117
+ ### Quality Control System
118
+ ```
119
+ [Product Image] → [Defect Detection AI] → [CropBB: class="defect"] → [Defect Crops] → [Analysis]
120
+ ```
121
+ Extract defective areas for detailed quality analysis.
122
+
123
+ ### Security Surveillance
124
+ ```
125
+ [Camera Feed] → [Person Detection] → [CropBB: class="person", confidence=0.8] → [Person Crops] → [Recognition]
126
+ ```
127
+ Extract detected persons for facial recognition processing.
128
+
129
+ ### Medical Imaging Analysis
130
+ ```
131
+ [Medical Scan] → [Anomaly Detection] → [CropBB: confidence=0.9] → [Suspicious Regions] → [Specialist Review]
132
+ ```
133
+ Extract high-confidence anomalies for medical specialist review.
134
+
135
+ ### E-commerce Automation
136
+ ```
137
+ [Catalog Photo] → [Product Detection] → [CropBB: class="product"] → [Product Crops] → [Individual Listings]
138
+ ```
139
+ Automatically extract individual products from multi-product photos.
140
+
141
+ ## Common Issues & Troubleshooting
142
+
143
+ ### No Crops Generated
144
+ - **Issue**: Node outputs empty array despite detection data
145
+ - **Causes**: Confidence threshold too high, incorrect data format, missing detection data
146
+ - **Solution**: Lower confidence threshold, verify detection format, check input paths
147
+
148
+ ### Malformed Detection Data
149
+ - **Issue**: Node warns about invalid box format
150
+ - **Cause**: Detection data doesn't match expected 4-corner format
151
+ - **Solution**: Verify AI model output format, transform data if needed
152
+
153
+ ### Poor Crop Quality
154
+ - **Issue**: Crops appear pixelated or low quality
155
+ - **Cause**: Source image resolution too low for detection boxes
156
+ - **Solution**: Use higher resolution source images or adjust detection model
157
+
158
+ ### Coordinate Issues
159
+ - **Issue**: Crops appear in wrong locations or are empty
160
+ - **Cause**: Coordinate system mismatch between detection model and expectations
161
+ - **Solution**: Verify detection model uses normalized 0-1 coordinates
162
+
163
+ ### Memory Usage
164
+ - **Issue**: High memory usage with many detections
165
+ - **Optimization**: Process images in smaller batches, use appropriate output formats
166
+ - **Monitoring**: Monitor crop count and source image sizes
167
+
168
+ ## Integration Patterns
169
+
170
+ ### Computer Vision Pipeline
171
+ ```
172
+ Image → AI Detection → CropBB → Individual Analysis → Results Aggregation
173
+ ```
174
+ Standard computer vision workflow for object analysis.
175
+
176
+ ### Quality Inspection System
177
+ ```
178
+ Product → Defect Detection → CropBB → Defect Classification → Pass/Fail Decision
179
+ ```
180
+ Automated quality control with defect analysis.
181
+
182
+ ### Surveillance Processing
183
+ ```
184
+ Video Frame → Object Detection → CropBB → Tracking/Recognition → Alert System
185
+ ```
186
+ Security surveillance with object tracking.
187
+
188
+ ### Medical Analysis Workflow
189
+ ```
190
+ Medical Image → AI Analysis → CropBB → Specialist Review → Diagnosis Support
191
+ ```
192
+ Medical imaging analysis with region extraction.
193
+
194
+ ## Advanced Usage
195
+
196
+ ### Dynamic Confidence Adjustment
197
+ ```javascript
198
+ // In function node before cropBB:
199
+ // Adjust confidence based on detection class
200
+ msg.detections.forEach(det => {
201
+ if (det.class_name === 'person') {
202
+ det.useConfidence = 0.8; // High confidence for people
203
+ } else if (det.class_name === 'vehicle') {
204
+ det.useConfidence = 0.6; // Medium confidence for vehicles
205
+ } else {
206
+ det.useConfidence = 0.5; // Default confidence
207
+ }
208
+ });
209
+ ```
210
+
211
+ ### Detection Filtering and Sorting
212
+ ```javascript
213
+ // Filter and sort detections before cropping
214
+ msg.detections = msg.detections
215
+ .filter(det => det.confidence > 0.7)
216
+ .filter(det => ['person', 'car', 'truck'].includes(det.class_name))
217
+ .sort((a, b) => b.confidence - a.confidence); // Sort by confidence descending
218
+ ```
219
+
220
+ ### Crop Size Validation
221
+ ```javascript
222
+ // Filter out crops that would be too small
223
+ msg.detections = msg.detections.filter(det => {
224
+ const box = det.box;
225
+ const width = (box[2][0] - box[0][0]) * msg.image.width;
226
+ const height = (box[2][1] - box[0][1]) * msg.image.height;
227
+ return width > 50 && height > 50; // Minimum 50x50 pixels
228
+ });
229
+ ```
230
+
231
+ ### Multi-Class Processing
232
+ ```javascript
233
+ // Process different classes with different settings
234
+ const personDetections = msg.detections.filter(d => d.class_name === 'person');
235
+ const vehicleDetections = msg.detections.filter(d => d.class_name === 'vehicle');
236
+
237
+ msg.personCropSettings = { confidence: 0.8, outputFormat: 'png' };
238
+ msg.vehicleCropSettings = { confidence: 0.6, outputFormat: 'jpg' };
239
+ ```
240
+
241
+ ## Best Practices
242
+
243
+ ### Detection Data Quality
244
+ - Ensure AI models output consistent coordinate formats
245
+ - Validate detection data before processing
246
+ - Handle edge cases (empty detections, malformed data)
247
+ - Monitor detection confidence distributions
248
+
249
+ ### Performance Optimization
250
+ - Use appropriate confidence thresholds to reduce processing load
251
+ - Process images at appropriate resolutions for your detection models
252
+ - Use raw format for processing chains, encoded formats for final output
253
+ - Consider batch processing for large image sets
254
+
255
+ ### Quality Control
256
+ - Implement validation checks for crop dimensions
257
+ - Monitor crop quality and adjust source image resolution if needed
258
+ - Set appropriate confidence thresholds for your use case
259
+ - Test with representative data sets
260
+
261
+ ### Error Handling
262
+ - Implement fallback behavior for missing detection data
263
+ - Handle coordinate validation errors gracefully
264
+ - Log processing statistics for monitoring and optimization
265
+ - Provide meaningful error messages for debugging
266
+
267
+ ### Integration Strategy
268
+ - Design detection data format standards for your pipeline
269
+ - Implement confidence threshold tuning based on performance metrics
270
+ - Consider storage and processing requirements for crop outputs
271
+ - Plan for scalability with large detection volumes