Dynamic Crop¶
Version v1
¶
Create dynamic crops from an image based on detections from detections-based model.
This is useful when placed after an ObjectDetection block as part of a multi-stage workflow. For example, you could use an ObjectDetection block to detect objects, then the DynamicCropBlock block to crop objects, then an OCR block to run character recognition on each of the individual cropped regions.
In addition, for instance segmentation predictions (which provide segmentation mask for each
bounding box) it is possible to remove background in the crops, outside of detected instances.
To enable that functionality, set mask_opacity
to positive value and optionally tune
background_color
.
Type identifier¶
Use the following identifier in step "type"
field: roboflow_core/dynamic_crop@v1
to add the block as
as step in your workflow.
Properties¶
Name | Type | Description | Refs |
---|---|---|---|
name |
str |
The unique name of this step.. | ❌ |
mask_opacity |
float |
For instance segmentation, mask_opacity can be used to control background removal. Opacity 1.0 removes the background, while 0.0 leaves the crop unchanged.. | ✅ |
background_color |
Union[Any, str] |
For background removal based on segmentation mask, new background color can be selected. Can be a hex string (like '#431112') RGB string (like '(128, 32, 64)') or a RGB tuple (like (18, 17, 67)).. | ✅ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow
runtime. See Bindings for more info.
Available Connections¶
Check what blocks you can connect to Dynamic Crop
in version v1
.
- inputs:
Color Visualization
,Detections Filter
,Detections Consensus
,Image Contours
,Path deviation
,Image Preprocessing
,Mask Visualization
,Dot Visualization
,Corner Visualization
,Model Comparison Visualization
,Image Slicer
,Byte Tracker
,Detection Offset
,Keypoint Detection Model
,Image Blur
,Label Visualization
,Time in zone
,Relative Static Crop
,Polygon Visualization
,Camera Focus
,Detections Classes Replacement
,Dynamic Crop
,YOLO-World Model
,Halo Visualization
,Segment Anything 2 Model
,Crop Visualization
,Image Threshold
,SIFT
,Google Vision OCR
,Circle Visualization
,SIFT Comparison
,VLM as Detector
,Path deviation
,Byte Tracker
,Object Detection Model
,Stability AI Inpainting
,Image Convert Grayscale
,Line Counter Visualization
,Absolute Static Crop
,Background Color Visualization
,Perspective Correction
,Detections Transformation
,Detections Stitch
,Dominant Color
,Bounding Box Visualization
,Polygon Zone Visualization
,Template Matching
,Ellipse Visualization
,Pixelate Visualization
,Time in zone
,Triangle Visualization
,Instance Segmentation Model
,Bounding Rectangle
,Stitch Images
,Blur Visualization
- outputs:
Color Visualization
,Image Contours
,Image Preprocessing
,Mask Visualization
,Dot Visualization
,Corner Visualization
,Model Comparison Visualization
,Image Slicer
,Keypoint Detection Model
,Image Blur
,OCR Model
,Label Visualization
,Time in zone
,Relative Static Crop
,Florence-2 Model
,Camera Focus
,Clip Comparison
,Polygon Visualization
,Image Convert Grayscale
,Dynamic Crop
,YOLO-World Model
,Halo Visualization
,LMM For Classification
,Segment Anything 2 Model
,Crop Visualization
,Image Threshold
,Multi-Label Classification Model
,QR Code Detection
,Google Vision OCR
,SIFT
,Clip Comparison
,LMM
,Roboflow Dataset Upload
,Barcode Detection
,OpenAI
,Circle Visualization
,SIFT Comparison
,VLM as Detector
,Google Gemini
,CogVLM
,Anthropic Claude
,Object Detection Model
,Pixel Color Count
,Stability AI Inpainting
,OpenAI
,Absolute Static Crop
,Background Color Visualization
,Perspective Correction
,Detections Stitch
,Line Counter Visualization
,Dominant Color
,Template Matching
,Bounding Box Visualization
,Polygon Zone Visualization
,Ellipse Visualization
,Pixelate Visualization
,Triangle Visualization
,Roboflow Dataset Upload
,Instance Segmentation Model
,Single-Label Classification Model
,VLM as Classifier
,Stitch Images
,Blur Visualization
The available connections depend on its binding kinds. Check what binding kinds
Dynamic Crop
in version v1
has.
Bindings
-
input
images
(image
): The input image for this step..predictions
(Union[object_detection_prediction
,keypoint_detection_prediction
,instance_segmentation_prediction
]): The output of a detection model describing the bounding boxes that will be used to crop the image..mask_opacity
(float_zero_to_one
): For instance segmentation, mask_opacity can be used to control background removal. Opacity 1.0 removes the background, while 0.0 leaves the crop unchanged..background_color
(Union[rgb_color
,string
]): For background removal based on segmentation mask, new background color can be selected. Can be a hex string (like '#431112') RGB string (like '(128, 32, 64)') or a RGB tuple (like (18, 17, 67))..
-
output
crops
(image
): Image in workflows.
Example JSON definition of step Dynamic Crop
in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/dynamic_crop@v1",
"images": "$inputs.image",
"predictions": "$steps.my_object_detection_model.predictions",
"mask_opacity": "<block_does_not_provide_example>",
"background_color": "#431112"
}