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