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