Dynamic Crop¶
Class: DynamicCropBlockV1
Source: inference.core.workflows.core_steps.transformations.dynamic_crop.v1.DynamicCropBlockV1
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@v1to 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¶
Compatible Blocks
Check what blocks you can connect to Dynamic Crop in version v1.
- inputs:
Blur Visualization,Line Counter Visualization,Moondream2,Detections Stitch,Velocity,Instance Segmentation Model,LMM,Line Counter,Time in Zone,Instance Segmentation Model,Dominant Color,Dynamic Crop,Multi-Label Classification Model,Circle Visualization,Camera Calibration,Absolute Static Crop,Webhook Sink,Mask Visualization,Google Gemini,Ellipse Visualization,Single-Label Classification Model,Identify Outliers,Anthropic Claude,Email Notification,Color Visualization,Keypoint Detection Model,Image Preprocessing,EasyOCR,OCR Model,Detections Classes Replacement,Detections Consensus,Llama 3.2 Vision,SAM 3,OpenAI,SAM 3,OpenAI,Roboflow Custom Metadata,Twilio SMS Notification,Trace Visualization,Florence-2 Model,Depth Estimation,Perspective Correction,Dynamic Zone,Grid Visualization,Stability AI Outpainting,Contrast Equalization,VLM as Detector,Google Gemini,CSV Formatter,QR Code Generator,Polygon Zone Visualization,Reference Path Visualization,Detections Transformation,PTZ Tracking (ONVIF).md),Stability AI Inpainting,Roboflow Dataset Upload,Stitch OCR Detections,Bounding Box Visualization,Image Slicer,Corner Visualization,Polygon Visualization,Local File Sink,CogVLM,Detections Merge,Slack Notification,Path Deviation,Relative Static Crop,Detections Combine,Triangle Visualization,Pixelate Visualization,Model Monitoring Inference Aggregator,Icon Visualization,Overlap Filter,Background Color Visualization,Classification Label Visualization,Time in Zone,Keypoint Visualization,Camera Focus,Background Subtraction,Dot Visualization,Object Detection Model,Email Notification,Crop Visualization,Stitch Images,Time in Zone,Object Detection Model,Template Matching,VLM as Detector,Florence-2 Model,LMM For Classification,Bounding Rectangle,Image Contours,Keypoint Detection Model,OpenAI,Roboflow Dataset Upload,YOLO-World Model,SAM 3,Halo Visualization,Detections Filter,Model Comparison Visualization,SIFT Comparison,Path Deviation,Motion Detection,Byte Tracker,Clip Comparison,Morphological Transformation,Seg Preview,Google Vision OCR,Segment Anything 2 Model,Byte Tracker,VLM as Classifier,Stability AI Image Generation,Byte Tracker,Detections Stabilizer,Image Blur,Image Threshold,Identify Changes,Image Slicer,Detection Offset,OpenAI,Anthropic Claude,Label Visualization,Image Convert Grayscale,SIFT,Gaze Detection - outputs:
Velocity,Line Counter,Multi-Label Classification Model,Instance Segmentation Model,Multi-Label Classification Model,Dynamic Crop,Camera Calibration,Single-Label Classification Model,Anthropic Claude,Image Preprocessing,EasyOCR,Detections Classes Replacement,QR Code Detection,OpenAI,Line Counter,Florence-2 Model,Depth Estimation,Dynamic Zone,VLM as Detector,Contrast Equalization,Polygon Zone Visualization,Reference Path Visualization,Roboflow Dataset Upload,Stitch OCR Detections,Image Slicer,Polygon Visualization,CogVLM,Path Deviation,Relative Static Crop,Detections Combine,Background Color Visualization,Keypoint Visualization,Camera Focus,Size Measurement,Dot Visualization,Pixel Color Count,Object Detection Model,Object Detection Model,Time in Zone,Florence-2 Model,LMM For Classification,Image Contours,Single-Label Classification Model,Keypoint Detection Model,Roboflow Dataset Upload,YOLO-World Model,Halo Visualization,Detections Filter,Model Comparison Visualization,CLIP Embedding Model,SIFT Comparison,Distance Measurement,Path Deviation,Motion Detection,Byte Tracker,VLM as Classifier,Clip Comparison,Seg Preview,VLM as Classifier,Segment Anything 2 Model,Byte Tracker,Detections Stabilizer,Image Blur,SmolVLM2,Anthropic Claude,Image Convert Grayscale,Moondream2,Line Counter Visualization,Blur Visualization,Detections Stitch,LMM,Instance Segmentation Model,Time in Zone,Dominant Color,Circle Visualization,Absolute Static Crop,Mask Visualization,Google Gemini,Ellipse Visualization,Email Notification,Color Visualization,Keypoint Detection Model,OCR Model,Detections Consensus,Llama 3.2 Vision,OpenAI,SAM 3,SAM 3,Roboflow Custom Metadata,Trace Visualization,Perspective Correction,Perception Encoder Embedding Model,Stability AI Outpainting,Google Gemini,Detections Transformation,PTZ Tracking (ONVIF).md),Stability AI Inpainting,Bounding Box Visualization,Corner Visualization,Detections Merge,Triangle Visualization,Pixelate Visualization,Model Monitoring Inference Aggregator,Icon Visualization,Overlap Filter,Time in Zone,Classification Label Visualization,Background Subtraction,Crop Visualization,Stitch Images,Qwen2.5-VL,VLM as Detector,Template Matching,Bounding Rectangle,OpenAI,Barcode Detection,SAM 3,Clip Comparison,Morphological Transformation,Google Vision OCR,Buffer,Stability AI Image Generation,Byte Tracker,Image Threshold,Image Slicer,OpenAI,Detection Offset,Label Visualization,SIFT,Gaze Detection
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[object_detection_prediction,keypoint_detection_prediction,instance_segmentation_prediction]): Detection model output containing bounding boxes for cropping..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.predictions(Union[object_detection_prediction,instance_segmentation_prediction,keypoint_detection_prediction]): Prediction with detected bounding boxes in form of sv.Detections(...) object ifobject_detection_predictionor Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object ifinstance_segmentation_predictionor Prediction with detected bounding boxes and detected keypoints in form of sv.Detections(...) object ifkeypoint_detection_prediction.
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"
}