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