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