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:
Google Vision OCR,Label Visualization,LMM For Classification,Blur Visualization,Background Color Visualization,Contrast Equalization,Bounding Box Visualization,Keypoint Visualization,Stability AI Outpainting,Reference Path Visualization,Image Slicer,Detections Filter,Pixelate Visualization,Single-Label Classification Model,CSV Formatter,SAM 3,Seg Preview,Byte Tracker,Overlap Filter,Image Preprocessing,SAM 3,Color Visualization,SIFT Comparison,Object Detection Model,Path Deviation,Detections Combine,Email Notification,Anthropic Claude,Dominant Color,Circle Visualization,Image Contours,Object Detection Model,Polygon Zone Visualization,Ellipse Visualization,Line Counter,Clip Comparison,Email Notification,Moondream2,VLM as Classifier,Model Monitoring Inference Aggregator,OCR Model,Absolute Static Crop,Depth Estimation,Path Deviation,LMM,Time in Zone,Morphological Transformation,Roboflow Dataset Upload,Gaze Detection,Detections Consensus,Crop Visualization,OpenAI,Image Convert Grayscale,VLM as Detector,SAM 3,Florence-2 Model,CogVLM,Roboflow Custom Metadata,Classification Label Visualization,Byte Tracker,Keypoint Detection Model,Stitch OCR Detections,Bounding Rectangle,Segment Anything 2 Model,Keypoint Detection Model,Time in Zone,Camera Calibration,Polygon Visualization,YOLO-World Model,PTZ Tracking (ONVIF).md),Detection Offset,Detections Classes Replacement,Icon Visualization,Detections Transformation,Identify Changes,Triangle Visualization,Template Matching,Roboflow Dataset Upload,Anthropic Claude,Model Comparison Visualization,Corner Visualization,Florence-2 Model,Google Gemini,Google Gemini,EasyOCR,VLM as Detector,Line Counter Visualization,Grid Visualization,Halo Visualization,Stability AI Image Generation,Identify Outliers,QR Code Generator,Dynamic Zone,Time in Zone,Twilio SMS Notification,Relative Static Crop,Dot Visualization,Detections Stitch,Llama 3.2 Vision,Image Blur,Velocity,Slack Notification,Byte Tracker,OpenAI,Local File Sink,Instance Segmentation Model,Multi-Label Classification Model,Image Slicer,OpenAI,Stability AI Inpainting,Dynamic Crop,Camera Focus,Detections Stabilizer,Webhook Sink,Image Threshold,Instance Segmentation Model,Perspective Correction,Mask Visualization,Trace Visualization,Detections Merge,OpenAI,Stitch Images,SIFT - outputs:
Label Visualization,Blur Visualization,Background Color Visualization,Contrast Equalization,Reference Path Visualization,Detections Filter,Stability AI Outpainting,Image Slicer,Pixelate Visualization,Single-Label Classification Model,Clip Comparison,Perception Encoder Embedding Model,Seg Preview,Overlap Filter,Image Preprocessing,Color Visualization,SIFT Comparison,Dominant Color,Circle Visualization,Object Detection Model,QR Code Detection,Moondream2,VLM as Classifier,Model Monitoring Inference Aggregator,OCR Model,Absolute Static Crop,Path Deviation,LMM,Time in Zone,Morphological Transformation,Gaze Detection,Detections Consensus,Crop Visualization,OpenAI,Florence-2 Model,Barcode Detection,Classification Label Visualization,Byte Tracker,Segment Anything 2 Model,Time in Zone,YOLO-World Model,PTZ Tracking (ONVIF).md),Detection Offset,Icon Visualization,Detections Transformation,Distance Measurement,VLM as Detector,Line Counter Visualization,Halo Visualization,Size Measurement,Dynamic Zone,Time in Zone,Detections Stitch,Llama 3.2 Vision,Image Blur,Velocity,OpenAI,Byte Tracker,Multi-Label Classification Model,Image Slicer,OpenAI,Dynamic Crop,Pixel Color Count,Mask Visualization,Detections Merge,Stitch Images,SIFT,Google Vision OCR,LMM For Classification,Keypoint Visualization,Bounding Box Visualization,SAM 3,Byte Tracker,SAM 3,Qwen2.5-VL,Object Detection Model,Path Deviation,Detections Combine,Anthropic Claude,Image Contours,Polygon Zone Visualization,Ellipse Visualization,Line Counter,Email Notification,Clip Comparison,Depth Estimation,Roboflow Dataset Upload,Image Convert Grayscale,SAM 3,CogVLM,VLM as Detector,Multi-Label Classification Model,Roboflow Custom Metadata,Buffer,Keypoint Detection Model,Stitch OCR Detections,Bounding Rectangle,Keypoint Detection Model,Line Counter,Polygon Visualization,CLIP Embedding Model,Camera Calibration,Detections Classes Replacement,Triangle Visualization,Template Matching,Roboflow Dataset Upload,Anthropic Claude,Model Comparison Visualization,Corner Visualization,Florence-2 Model,Google Gemini,Google Gemini,EasyOCR,SmolVLM2,Stability AI Image Generation,Relative Static Crop,Dot Visualization,Instance Segmentation Model,Stability AI Inpainting,Single-Label Classification Model,Camera Focus,Detections Stabilizer,Instance Segmentation Model,VLM as Classifier,Perspective Correction,Image Threshold,OpenAI,Trace 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]): 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[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.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"
}