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