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