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