Motion Detection¶
Class: MotionDetectionBlockV1
Source: inference.core.workflows.core_steps.classical_cv.motion_detection.v1.MotionDetectionBlockV1
This block uses background subtraction to detect motion in a video. The block draws the contours of the detected motion, as well as outputs the bounding boxes as an object detection. Two flags are provided for use in workflows - one to indicate motion, and an alarm to indicate when the motion changed from no motion to motion detected. Additionally a zone can be provided to limit the scope of the motion detection to a specific area of the video frame.
Motion detection is extremely useful for generating alerts and file uploads. Additionally, inference can be conditionally run based on motion detection to save compute resources.
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/motion_detection@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
minimum_contour_area |
int |
Motion in areas smaller than this in square pixels will not be counted as motion.. | ✅ |
morphological_kernel_size |
int |
The size of the kernel in pixels used for morphological operations to combine contours.. | ✅ |
threshold |
int |
The threshold value for the squared Mahalanobis distance for background subtraction. Smaller values increase sensitivity to motion. Recommended values are 8-32.. | ✅ |
history |
int |
The number of previous frames to use for background subtraction. Larger values make the model less sensitive to quick changes in the background, smaller values allow for more adaptation.. | ✅ |
detection_zone |
Union[List[Any], str] |
An optional polygon zone in a format [[x1, y1], [x2, y2], [x3, y3], ...]; each zone must consist of more than 3 points. | ✅ |
suppress_first_detections |
bool |
Suppress motion detections until the background history is fully initialized.. | ✅ |
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 Motion Detection in version v1.
- inputs:
QR Code Generator,Image Convert Grayscale,Google Gemini,Dynamic Crop,SIFT Comparison,Blur Visualization,SIFT,Bounding Box Visualization,Stability AI Outpainting,Identify Changes,Camera Focus,Slack Notification,Keypoint Visualization,Trace Visualization,Polygon Visualization,Pixel Color Count,Ellipse Visualization,Model Comparison Visualization,Anthropic Claude,Dimension Collapse,OpenAI,Local File Sink,Triangle Visualization,Polygon Zone Visualization,Halo Visualization,Distance Measurement,Stability AI Image Generation,VLM as Detector,Florence-2 Model,Circle Visualization,Email Notification,Google Gemini,Motion Detection,Clip Comparison,Camera Focus,Anthropic Claude,Perspective Correction,VLM as Classifier,Reference Path Visualization,Corner Visualization,Color Visualization,Twilio SMS/MMS Notification,Image Slicer,OpenAI,Camera Calibration,Image Blur,Line Counter,Buffer,VLM as Detector,Dot Visualization,Roboflow Custom Metadata,Image Threshold,Model Monitoring Inference Aggregator,Morphological Transformation,Label Visualization,Background Color Visualization,Classification Label Visualization,Roboflow Dataset Upload,Mask Visualization,Dynamic Zone,Detections List Roll-Up,Pixelate Visualization,Absolute Static Crop,Line Counter,PTZ Tracking (ONVIF).md),Size Measurement,Detections Consensus,Webhook Sink,Grid Visualization,Contrast Equalization,Image Preprocessing,Google Gemini,Relative Static Crop,Stability AI Inpainting,Image Contours,Line Counter Visualization,Stitch Images,Template Matching,Crop Visualization,JSON Parser,OpenAI,Llama 3.2 Vision,Icon Visualization,Clip Comparison,SIFT Comparison,Depth Estimation,Twilio SMS Notification,VLM as Classifier,Florence-2 Model,Background Subtraction,Identify Outliers,Image Slicer,Roboflow Dataset Upload,Email Notification - outputs:
Detections Combine,Detections Stitch,Seg Preview,Byte Tracker,YOLO-World Model,Google Gemini,Velocity,Dynamic Crop,Blur Visualization,Detection Offset,Bounding Box Visualization,Slack Notification,Keypoint Visualization,Trace Visualization,Instance Segmentation Model,Polygon Visualization,Cache Set,Ellipse Visualization,Model Comparison Visualization,OpenAI,Anthropic Claude,Triangle Visualization,Polygon Zone Visualization,SAM 3,Halo Visualization,Distance Measurement,Byte Tracker,Time in Zone,Path Deviation,VLM as Detector,Florence-2 Model,Single-Label Classification Model,Circle Visualization,Email Notification,Detections Stabilizer,Motion Detection,Google Gemini,Clip Comparison,Camera Focus,Detections Classes Replacement,Anthropic Claude,Detections Filter,Object Detection Model,Instance Segmentation Model,Perspective Correction,VLM as Classifier,Reference Path Visualization,Twilio SMS/MMS Notification,Color Visualization,Corner Visualization,Multi-Label Classification Model,OpenAI,Stitch OCR Detections,Line Counter,Buffer,Detections Transformation,VLM as Detector,SAM 3,Roboflow Custom Metadata,Dot Visualization,Model Monitoring Inference Aggregator,Label Visualization,Background Color Visualization,Time in Zone,Classification Label Visualization,Byte Tracker,Keypoint Detection Model,Roboflow Dataset Upload,Path Deviation,Mask Visualization,Dynamic Zone,Detections List Roll-Up,Pixelate Visualization,PTZ Tracking (ONVIF).md),Line Counter,Keypoint Detection Model,Detections Consensus,Size Measurement,Webhook Sink,Grid Visualization,Google Gemini,Stability AI Inpainting,Template Matching,Line Counter Visualization,Crop Visualization,OpenAI,Llama 3.2 Vision,Icon Visualization,Clip Comparison,SIFT Comparison,Gaze Detection,Twilio SMS Notification,Single-Label Classification Model,VLM as Classifier,Time in Zone,Florence-2 Model,LMM For Classification,SAM 3,Object Detection Model,Multi-Label Classification Model,Segment Anything 2 Model,Detections Merge,Roboflow Dataset Upload,Overlap Filter,Email Notification
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Motion Detection in version v1 has.
Bindings
-
input
image(image): The input image for this step..minimum_contour_area(integer): Motion in areas smaller than this in square pixels will not be counted as motion..morphological_kernel_size(integer): The size of the kernel in pixels used for morphological operations to combine contours..threshold(integer): The threshold value for the squared Mahalanobis distance for background subtraction. Smaller values increase sensitivity to motion. Recommended values are 8-32..history(integer): The number of previous frames to use for background subtraction. Larger values make the model less sensitive to quick changes in the background, smaller values allow for more adaptation..detection_zone(Union[list_of_values,zone]): An optional polygon zone in a format [[x1, y1], [x2, y2], [x3, y3], ...]; each zone must consist of more than 3 points.suppress_first_detections(boolean): Suppress motion detections until the background history is fully initialized..
-
output
motion(boolean): Boolean flag.alarm(boolean): Boolean flag.detections(object_detection_prediction): Prediction with detected bounding boxes in form of sv.Detections(...) object.motion_zones(list_of_values): List of values of any type.
Example JSON definition of step Motion Detection in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/motion_detection@v1",
"image": "$inputs.image",
"minimum_contour_area": 200,
"morphological_kernel_size": 3,
"threshold": 16,
"history": 30,
"detection_zone": "<block_does_not_provide_example>",
"suppress_first_detections": true
}