Dynamic Crop¶
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 |
Enter a unique identifier for 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[Tuple[int, int, int], 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:
Reference Path Visualization
,Multi-Label Classification Model
,OpenAI
,LMM For Classification
,OCR Model
,Roboflow Dataset Upload
,Stability AI Inpainting
,Absolute Static Crop
,Trace Visualization
,Path Deviation
,Halo Visualization
,Byte Tracker
,Instance Segmentation Model
,SIFT
,SIFT Comparison
,Pixelate Visualization
,Anthropic Claude
,Email Notification
,Path Deviation
,Classification Label Visualization
,Mask Visualization
,Background Color Visualization
,Crop Visualization
,Relative Static Crop
,VLM as Classifier
,Google Gemini
,Image Contours
,Detections Filter
,Gaze Detection
,Byte Tracker
,Image Threshold
,Roboflow Custom Metadata
,Bounding Box Visualization
,Keypoint Detection Model
,YOLO-World Model
,Template Matching
,Byte Tracker
,Instance Segmentation Model
,Florence-2 Model
,Object Detection Model
,LMM
,CogVLM
,Stitch OCR Detections
,Roboflow Dataset Upload
,Camera Focus
,Identify Changes
,Keypoint Visualization
,Polygon Zone Visualization
,Model Monitoring Inference Aggregator
,Object Detection Model
,Triangle Visualization
,Local File Sink
,Single-Label Classification Model
,Ellipse Visualization
,Detections Stitch
,Identify Outliers
,Detections Classes Replacement
,Slack Notification
,Clip Comparison
,Image Blur
,Detections Transformation
,Twilio SMS Notification
,Dot Visualization
,Model Comparison Visualization
,VLM as Detector
,Dynamic Crop
,Image Slicer
,Perspective Correction
,Line Counter Visualization
,Grid Visualization
,Detections Consensus
,Time in Zone
,Webhook Sink
,Google Vision OCR
,Image Convert Grayscale
,Time in Zone
,Stitch Images
,Blur Visualization
,Bounding Rectangle
,Florence-2 Model
,CSV Formatter
,Keypoint Detection Model
,Color Visualization
,Dominant Color
,Image Preprocessing
,VLM as Detector
,Polygon Visualization
,Detections Stabilizer
,Segment Anything 2 Model
,Detection Offset
,OpenAI
,Circle Visualization
,Line Counter
,Label Visualization
,Corner Visualization
- outputs:
Multi-Label Classification Model
,Reference Path Visualization
,OpenAI
,Single-Label Classification Model
,OCR Model
,LMM For Classification
,Roboflow Dataset Upload
,Stability AI Inpainting
,Absolute Static Crop
,Trace Visualization
,Byte Tracker
,Halo Visualization
,Instance Segmentation Model
,SIFT Comparison
,SIFT
,Pixelate Visualization
,Anthropic Claude
,Classification Label Visualization
,Mask Visualization
,Background Color Visualization
,Crop Visualization
,Relative Static Crop
,VLM as Classifier
,Google Gemini
,Image Contours
,Gaze Detection
,Image Threshold
,Keypoint Detection Model
,Multi-Label Classification Model
,YOLO-World Model
,Instance Segmentation Model
,Template Matching
,Florence-2 Model
,Object Detection Model
,CogVLM
,LMM
,Roboflow Dataset Upload
,Camera Focus
,Keypoint Visualization
,Label Visualization
,Polygon Zone Visualization
,Pixel Color Count
,Object Detection Model
,Triangle Visualization
,Barcode Detection
,Single-Label Classification Model
,Clip Comparison
,Ellipse Visualization
,Detections Stitch
,Clip Comparison
,Image Blur
,Dot Visualization
,Model Comparison Visualization
,VLM as Detector
,Dynamic Crop
,Image Slicer
,VLM as Classifier
,Perspective Correction
,Line Counter Visualization
,Time in Zone
,Google Vision OCR
,Image Convert Grayscale
,Buffer
,Stitch Images
,Blur Visualization
,Florence-2 Model
,Keypoint Detection Model
,Color Visualization
,Dominant Color
,Image Preprocessing
,QR Code Detection
,CLIP Embedding Model
,VLM as Detector
,Polygon Visualization
,Detections Stabilizer
,Segment Anything 2 Model
,OpenAI
,Circle Visualization
,Bounding Box Visualization
,Corner Visualization
Input and Output Bindings¶
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[instance_segmentation_prediction
,object_detection_prediction
,keypoint_detection_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[string
,rgb_color
]): 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"
}