Template Matching¶
Class: TemplateMatchingBlockV1
Source: inference.core.workflows.core_steps.classical_cv.template_matching.v1.TemplateMatchingBlockV1
Apply Template Matching to an image. Block is based on OpenCV library function called cv2.matchTemplate(...)
that searches for a template image within a larger image. This is often used in computer vision tasks where
you need to find a specific object or pattern in a scene, like detecting logos, objects, or
specific regions in an image.
Please take into account the following characteristics of block: * it tends to produce overlapping and duplicated predictions, hence we added NMS which can be disabled * block may find very large number of matches in some cases due to simplicity of methods being used - in that cases NMS may be computationally intractable and should be disabled
Output from the block is in a form of sv.Detections objects which can be nicely paired with other blocks accepting this kind of input (like visualization blocks).
Type identifier¶
Use the following identifier in step "type"
field: roboflow_core/template_matching@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.. | ❌ |
matching_threshold |
float |
The threshold value for template matching.. | ✅ |
apply_nms |
bool |
Flag to decide if NMS should be applied at the output detections.. | ✅ |
nms_threshold |
float |
The threshold value NMS procedure (if to be applied).. | ✅ |
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 Template Matching
in version v1
.
- inputs:
Grid Visualization
,Image Blur
,Image Preprocessing
,Image Slicer
,Dynamic Crop
,Absolute Static Crop
,Roboflow Dataset Upload
,Color Visualization
,Corner Visualization
,Depth Estimation
,Stability AI Outpainting
,Keypoint Visualization
,PTZ Tracking (ONVIF)
.md),Trace Visualization
,Clip Comparison
,Email Notification
,Model Comparison Visualization
,Mask Visualization
,Image Slicer
,Model Monitoring Inference Aggregator
,Detections Consensus
,Image Threshold
,Contrast Equalization
,Morphological Transformation
,Classification Label Visualization
,Relative Static Crop
,Camera Calibration
,Dynamic Zone
,Blur Visualization
,Stitch Images
,Roboflow Dataset Upload
,JSON Parser
,Triangle Visualization
,Perspective Correction
,SIFT
,Icon Visualization
,Label Visualization
,Stability AI Image Generation
,Ellipse Visualization
,SIFT Comparison
,VLM as Detector
,Line Counter Visualization
,SIFT Comparison
,Slack Notification
,Local File Sink
,Image Convert Grayscale
,Roboflow Custom Metadata
,Gaze Detection
,Twilio SMS Notification
,Background Color Visualization
,VLM as Classifier
,QR Code Generator
,Identify Changes
,Polygon Zone Visualization
,VLM as Detector
,Polygon Visualization
,Camera Focus
,Dot Visualization
,Cosine Similarity
,Identify Outliers
,Circle Visualization
,Bounding Box Visualization
,Image Contours
,Halo Visualization
,Reference Path Visualization
,VLM as Classifier
,Pixelate Visualization
,Webhook Sink
,Stability AI Inpainting
,Crop Visualization
- outputs:
Grid Visualization
,Image Blur
,Image Preprocessing
,Image Slicer
,Instance Segmentation Model
,Dynamic Crop
,Time in Zone
,Roboflow Dataset Upload
,Absolute Static Crop
,Color Visualization
,Corner Visualization
,Stability AI Outpainting
,Keypoint Visualization
,Keypoint Detection Model
,PTZ Tracking (ONVIF)
.md),Trace Visualization
,Keypoint Detection Model
,Email Notification
,Time in Zone
,Model Comparison Visualization
,Mask Visualization
,Model Monitoring Inference Aggregator
,Image Slicer
,Size Measurement
,Detections Consensus
,Image Threshold
,Line Counter
,Detections Filter
,Path Deviation
,Morphological Transformation
,Velocity
,Classification Label Visualization
,Time in Zone
,Path Deviation
,Dynamic Zone
,Florence-2 Model
,Blur Visualization
,Stitch Images
,Roboflow Dataset Upload
,Triangle Visualization
,Perspective Correction
,Icon Visualization
,Detections Transformation
,Label Visualization
,Stitch OCR Detections
,Object Detection Model
,Pixel Color Count
,Ellipse Visualization
,SIFT Comparison
,Detections Stabilizer
,Byte Tracker
,Line Counter Visualization
,Florence-2 Model
,Line Counter
,Overlap Filter
,Distance Measurement
,Byte Tracker
,SIFT Comparison
,Slack Notification
,Detection Offset
,Detections Combine
,Roboflow Custom Metadata
,Twilio SMS Notification
,Background Color Visualization
,QR Code Generator
,Segment Anything 2 Model
,Identify Changes
,Anthropic Claude
,Detections Stitch
,Byte Tracker
,Polygon Visualization
,Dot Visualization
,Detections Classes Replacement
,Instance Segmentation Model
,Identify Outliers
,Circle Visualization
,Bounding Box Visualization
,Image Contours
,Object Detection Model
,Dominant Color
,Halo Visualization
,Reference Path Visualization
,Detections Merge
,Pixelate Visualization
,Webhook Sink
,Stability AI Inpainting
,Crop Visualization
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Template Matching
in version v1
has.
Bindings
-
input
image
(image
): The input image for this step..template
(image
): The template image for this step..matching_threshold
(float
): The threshold value for template matching..apply_nms
(boolean
): Flag to decide if NMS should be applied at the output detections..nms_threshold
(float_zero_to_one
): The threshold value NMS procedure (if to be applied)..
-
output
predictions
(object_detection_prediction
): Prediction with detected bounding boxes in form of sv.Detections(...) object.number_of_matches
(integer
): Integer value.
Example JSON definition of step Template Matching
in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/template_matching@v1",
"image": "$inputs.image",
"template": "$inputs.template",
"matching_threshold": 0.8,
"apply_nms": "$inputs.apply_nms",
"nms_threshold": "$inputs.nms_threshold"
}