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