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