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:
Image Convert Grayscale
,Gaze Detection
,Pixelate Visualization
,SIFT
,VLM as Detector
,Stability AI Image Generation
,SIFT Comparison
,Mask Visualization
,Image Slicer
,Triangle Visualization
,Cosine Similarity
,VLM as Detector
,Polygon Zone Visualization
,Model Comparison Visualization
,Crop Visualization
,Classification Label Visualization
,Reference Path Visualization
,Twilio SMS Notification
,Bounding Box Visualization
,Image Contours
,Roboflow Custom Metadata
,Circle Visualization
,Perspective Correction
,Slack Notification
,Polygon Visualization
,VLM as Classifier
,Trace Visualization
,Webhook Sink
,Color Visualization
,Identify Changes
,Detections Consensus
,Image Threshold
,SIFT Comparison
,JSON Parser
,Absolute Static Crop
,Line Counter Visualization
,Stitch Images
,Dot Visualization
,Identify Outliers
,Dynamic Zone
,Background Color Visualization
,Model Monitoring Inference Aggregator
,Image Slicer
,Roboflow Dataset Upload
,Roboflow Dataset Upload
,Image Blur
,Email Notification
,Camera Focus
,Grid Visualization
,Blur Visualization
,Label Visualization
,Stability AI Inpainting
,Depth Estimation
,Image Preprocessing
,Ellipse Visualization
,ONVIF Control
,VLM as Classifier
,Halo Visualization
,Corner Visualization
,Camera Calibration
,Clip Comparison
,Dynamic Crop
,Relative Static Crop
,Keypoint Visualization
,Local File Sink
- outputs:
Keypoint Detection Model
,Anthropic Claude
,Detections Classes Replacement
,Florence-2 Model
,Detection Offset
,Distance Measurement
,Pixelate Visualization
,SIFT Comparison
,Object Detection Model
,Mask Visualization
,Overlap Filter
,Image Slicer
,Triangle Visualization
,Path Deviation
,Model Comparison Visualization
,Crop Visualization
,Classification Label Visualization
,Segment Anything 2 Model
,Keypoint Detection Model
,Reference Path Visualization
,Line Counter
,Twilio SMS Notification
,Bounding Box Visualization
,Roboflow Custom Metadata
,Byte Tracker
,Size Measurement
,Image Contours
,Circle Visualization
,Perspective Correction
,Slack Notification
,Pixel Color Count
,Polygon Visualization
,Detections Transformation
,Instance Segmentation Model
,Detections Merge
,Trace Visualization
,Webhook Sink
,Color Visualization
,Identify Changes
,Detections Consensus
,Image Threshold
,Detections Stitch
,SIFT Comparison
,Absolute Static Crop
,Stitch Images
,Line Counter Visualization
,Line Counter
,Detections Filter
,Dot Visualization
,Identify Outliers
,Dynamic Zone
,Instance Segmentation Model
,Background Color Visualization
,Florence-2 Model
,Model Monitoring Inference Aggregator
,Detections Stabilizer
,Stitch OCR Detections
,Image Slicer
,Roboflow Dataset Upload
,Roboflow Dataset Upload
,Time in Zone
,Image Blur
,Email Notification
,Grid Visualization
,Path Deviation
,Object Detection Model
,Blur Visualization
,Label Visualization
,Image Preprocessing
,Byte Tracker
,Ellipse Visualization
,ONVIF Control
,Byte Tracker
,Halo Visualization
,Corner Visualization
,Time in Zone
,Dynamic Crop
,Keypoint Visualization
,Velocity
,Dominant Color
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"
}