

{"id":120188,"date":"2024-04-05T18:00:52","date_gmt":"2024-04-05T12:30:52","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=120188"},"modified":"2024-04-05T18:53:50","modified_gmt":"2024-04-05T13:23:50","slug":"opencv-template-matching","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/","title":{"rendered":"OpenCV Template Matching"},"content":{"rendered":"<p>Unlock the hidden potential of images with OpenCV&#8217;s template matching! In the world of computer vision, the ability to seamlessly find a needle in a haystack of pixels is a superpower.<\/p>\n<p>Join us as we dive into the captivating realm of template matching, where patterns emerge, objects reveal themselves, and OpenCV becomes the key to unraveling visual mysteries.<\/p>\n<h2>Understanding Template Matching: Revealing the Visual Puzzle<\/h2>\n<p>Imagine you&#8217;re searching for a specific item in a cluttered room. Your brain effortlessly identifies the object by recognizing its shape, color, and features, allowing you to pick it out from the surroundings.<\/p>\n<p>Template matching, a powerful technique in the realm of computer vision, mimics this innate human ability to identify patterns within images. Just as you can spot a familiar face in a crowd, template matching enables machines to locate specific patterns within larger images.<\/p>\n<p>At its core, template matching involves taking a smaller reference image (the template) and searching for instances of that template within a larger target image. This technique finds its applications in a wide array of fields, from object detection and medical imaging to quality control in manufacturing processes. Understanding how template matching works and harnessing its capabilities can lead to breakthroughs in various industries.<\/p>\n<p>The concept is deceptively simple: by sliding the template across the target image and comparing pixel values, we can determine areas where the template&#8217;s pattern closely matches the content of the target. However, beneath this simplicity lies a complexity that arises from variations in scale, rotation, lighting, and noise.<\/p>\n<p>This article will peel back the layers, exploring not only the fundamentals of template matching but also how OpenCV, a leading computer vision library, equips us to perform this task efficiently and accurately.<\/p>\n<p>A metric is computed to indicate how &#8220;good&#8221; or &#8220;bad&#8221; the match is at each (x, y)-location. To assess how &#8220;similar&#8221; the pixel intensities of the two patches are, we often utilize the normalized correlation coefficient :<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Template-Matching-formula.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-126027 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Template-Matching-formula.webp\" alt=\"Template Matching formula\" width=\"700\" height=\"149\" \/><\/a><\/p>\n<p>In the following sections, we&#8217;ll delve into the mechanisms behind template matching, explore the suite of tools OpenCV offers, and discover how to tackle challenges like scale variation and noise.<\/p>\n<p>By the end of this journey, you&#8217;ll be armed with the knowledge to unlock the potential of template matching and add it to your arsenal of computer vision techniques. So, let&#8217;s embark on this visual adventure and uncover the secrets of template matching together.<\/p>\n<h3>What is Template Matching in OpenCV?<\/h3>\n<p>Template matching in OpenCV is a technique used for finding a specific template image within a larger target image. This method is widely employed in computer vision to identify patterns, objects, or specific regions of interest within an image. OpenCV provides a set of functions and methods that allow you to perform template matching efficiently and accurately.<\/p>\n<p>The basic idea behind template matching in OpenCV involves sliding the template image over the target image and calculating a similarity score at each position. This similarity score indicates how closely the template matches the content of the target image at that particular position. The position with the highest similarity score corresponds to the location where the template best matches the target image.<\/p>\n<p>OpenCV&#8217;s cv2.matchTemplate() function is the cornerstone of template matching. This function takes the template image and the target image as inputs and returns a result matrix. Each element of this result matrix corresponds to a position in the target image and contains a value that indicates the degree of similarity between the template and the content of the target image at that position.<\/p>\n<p><strong>Different methods can be used to calculate the similarity score, and OpenCV offers several options such as:<\/strong><\/p>\n<p><strong>1. Normalized Cross-Correlation (`cv2.TM_CCORR_NORMED`):<\/strong> This method computes the cross-correlation between the template and the target image while normalizing the pixel values. The resulting matrix will have peaks at positions where the template best matches the target image.<\/p>\n<p><strong>2. Sum of Squared Differences (`cv2.TM_SQDIFF`):<\/strong> This method calculates the sum of squared differences between the template and the target image. The lower the value, the better the match. This method is often used with the minimum value being the best match.<\/p>\n<p><strong>3. Correlation Coefficient (`cv2.TM_CCOEFF`):<\/strong> This method calculates the correlation coefficient between the template and the target image. A higher value indicates a better match, with 1 being a perfect match.<\/p>\n<p>These methods offer flexibility in choosing the most suitable approach based on the specific application and the nature of the images involved.<\/p>\n<p>Overall, template matching in OpenCV provides a powerful tool for various tasks, including object detection, pattern recognition, and image analysis. However, it&#8217;s important to note that template matching might have limitations when dealing with scale variation, rotation, and complex scenes. In such cases, additional techniques or algorithms might be required to enhance the accuracy of the results.<\/p>\n<h3>Unlocking the Art of Visual Recognition: Exploring Template Matching with Varied Match Modes<\/h3>\n<h4>1. cv2.TM_SQDIFF:<\/h4>\n<p>The best match is determined using this mode&#8217;s sum of squared differences. The match will be better if the score is lower.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimport numpy as np\r\n\r\n# Load the original image, template image, and convert to grayscale\r\noriginal_image = cv2.imread(r\"C:\\Users\\satchit\\Desktop\\DataFlair\\OpenCv Template Matching\\traffic-street-img.jpg\",cv2.IMREAD_GRAYSCALE)\r\ntemplate_image = cv2.imread(r\"C:\\Users\\satchit\\Desktop\\DataFlair\\OpenCv Template Matching\\Template_image.png\",cv2.IMREAD_GRAYSCALE)\r\n\r\n# Perform template matching using cv2.TM_SQDIFF\r\nresult = cv2.matchTemplate(original_image, template_image, cv2.TM_SQDIFF)\r\nmin_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)\r\ntop_left = min_loc\r\nbottom_right = (top_left[0] + template_image.shape[1], top_left[1] + template_image.shape[0])\r\n\r\n# Create a copy of the original image for visualization\r\nmatched_image = original_image.copy()\r\ncv2.rectangle(matched_image, top_left, bottom_right, (0, 255, 0), 2)\r\n# Display the images\r\ncv2.imshow('Original Image', original_image)\r\ncv2.imshow('Template Image', template_image)\r\ncv2.imshow('Matched Image (TM_SQDIFF)', matched_image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()<\/pre>\n<p><strong>TM_SQDIFF:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Varied-Match-Modes-SQDIFF.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-126028 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Varied-Match-Modes-SQDIFF.webp\" alt=\"Varied Match Modes SQDIFF\" width=\"997\" height=\"903\" \/><\/a><\/p>\n<h4>2. cv2.TM_CCORR:<\/h4>\n<p>This mode calculates the cross-correlation between the template and the target image. The higher the score, the better the match.<\/p>\n<p><strong>Use the same Libraries and path from above code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># Perform template matching using cv2.TM_CCORR\r\nresult = cv2.matchTemplate(original_image, template_image, cv2.TM_CCORR)\r\nmin_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)\r\ntop_left = max_loc\r\nbottom_right = (top_left[0] + template_image.shape[1], top_left[1] + template_image.shape[0])\r\n\r\n# Create a copy of the original image for visualization\r\nma\r\ntched_image = original_image.copy()\r\ncv2.rectangle(matched_image, top_left, bottom_right, (0, 255, 0), 2)\r\n\r\n# Display the images\r\ncv2.imshow('Original Image', original_image)\r\ncv2.imshow('Template Image', template_image)\r\ncv2.imshow('Matched Image (TM_CCORR)', matched_image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()<\/pre>\n<h4>3. cv2.TM_CCOEFF:<\/h4>\n<p>This mode calculates the correlation coefficient between the template and the target image. The higher the score, the better the match.<\/p>\n<p><strong>Use the same Libraries and path from above code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># Perform template matching using cv2.TM_CCOEFF\r\nresult = cv2.matchTemplate(original_image, template_image, cv2.TM_CCOEFF)\r\nmin_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)\r\ntop_left = max_loc\r\nbottom_right = (top_left[0] + template_image.shape[1], top_left[1] + template_image.shape[0])\r\n\r\n# Create a copy of the original image for visualization\r\nmatched_image = original_image.copy()\r\ncv2.rectangle(matched_image, top_left, bottom_right, (0, 255, 0), 2)\r\n\r\n# Display the images\r\ncv2.imshow('Original Image', original_image)\r\ncv2.imshow('Template Image', template_image)\r\ncv2.imshow('Matched Image (TM_CCOEFF)', matched_image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()<\/pre>\n<p>These examples demonstrate how to perform template matching using different match modes in OpenCV.<\/p>\n<h3>Multi-Object Discovery: Unveiling the Power of OpenCV Template Matching with Multiple Targets<\/h3>\n<p>Certainly, performing template matching with multiple objects involves iterating over regions of the target image and applying the template matching process to each region.<\/p>\n<p><strong> Here&#8217;s an example code that demonstrates how to perform template matching with multiple objects using OpenCV:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimport numpy as np\r\n\r\n# Load the original image, template image, and convert to grayscale\r\noriginal_image = cv2.imread(r\"C:\/Users\/sanji\/Desktop\/DataFlair\/OpenCv Template Matching\/wildlife-leopard.jpg\",cv2.IMREAD_GRAYSCALE)\r\ntemplate_image = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\OpenCv Template Matching\\leopard templeate.png\",cv2.IMREAD_GRAYSCALE)\r\n\r\n# Get the dimensions of the template\r\ntemplate_height, template_width = template_image.shape\r\n\r\n# Perform template matching using TM_CCOEFF_NORMED\r\nresult = cv2.matchTemplate(original_image, template_image, cv2.TM_CCOEFF_NORMED)\r\n\r\n# Define a threshold for considering matches\r\nthreshold = 0.7\r\n\r\n# Find all locations where the result exceeds the threshold\r\nlocations = np.where(result &gt;= threshold)\r\n\r\n# Create a copy of the original image for visualization\r\nmatched_image = original_image.copy()\r\n\r\n# Iterate over matched locations\r\nfor loc in zip(*locations[::-1]):\r\n    top_left = loc\r\n    bottom_right = (top_left[0] + template_width, top_left[1] + template_height)\r\n    cv2.rectangle(matched_image, top_left, bottom_right, (0, 255, 0), 2)\r\n\r\n# Display the images\r\ncv2.imshow('Original Image', original_image)\r\ncv2.imshow('Template Image', template_image)\r\ncv2.imshow('Matched Image', matched_image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()<\/pre>\n<p><strong>Original Image:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Multi-Object-Discovery-original.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-126029 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Multi-Object-Discovery-original.webp\" alt=\"Multi Object Discovery original\" width=\"998\" height=\"907\" \/><\/a><\/p>\n<p><strong>Template Image:\u00a0<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/template-matching.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-134069 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/template-matching.webp\" alt=\"template matching\" width=\"17\" height=\"18\" \/><\/a><\/p>\n<p><strong>Matched Image:<\/strong> Here, multiple similar shaped Spots are marked up,<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Multi-Object-Discovery-matched.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-126030 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Multi-Object-Discovery-matched.webp\" alt=\"Multi Object Discovery matched\" width=\"997\" height=\"916\" \/><\/a><\/p>\n<p>In this code, the cv2.matchTemplate function is used with cv2.TM_CCOEFF_NORMED to perform template matching. The code then finds all locations where the result exceeds a predefined threshold (0.7 in this case) to consider them as matches. It iterates over these matched locations and draws rectangles around each match on the copy of the original image for visualization.<\/p>\n<h3>Scaling New Heights: Unveiling the Magic of Multi-Scale Template Matching with OpenCV<\/h3>\n<p>Applying template matching with multiple scales involves resizing the template and target image at different scales and performing template matching on each scale.<\/p>\n<p><strong> Here&#8217;s an example code that demonstrates how to perform multi-scale template matching using OpenCV:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimport numpy as np\r\n\r\n# Load the original image, template image, and convert to grayscale\r\noriginal_image = cv2.imread(r\"C:\\Users\\satchit\\Desktop\\DataFlair\\OpenCv Template Matching\\walking-dog.jpg\",cv2.IMREAD_GRAYSCALE)\r\ntemplate_image = cv2.imread(r\"C:\\Users\\satchit\\Desktop\\DataFlair\\OpenCv Template Matching\\walking_dog_template.png\",cv2.IMREAD_GRAYSCALE)\r\n\r\n# Define a list of scales to consider\r\nscales = [0.5, 1.0, 1.5]\r\n\r\n# Create a copy of the original image for visualization\r\nmatched_image = original_image.copy()\r\n\r\n# Iterate over each scale\r\nfor scale in scales:\r\n    # Resize the template image based on the current scale\r\n    scaled_template = cv2.resize(template_image, None, fx=scale, fy=scale)\r\n\r\n    # Perform template matching using TM_CCOEFF_NORMED\r\n    result = cv2.matchTemplate(original_image, scaled_template, cv2.TM_CCOEFF_NORMED)\r\n\r\n    # Define a threshold for considering matches\r\n    threshold = 0.7\r\n\r\n    # Find all locations where the result exceeds the threshold\r\n    locations = np.where(result &gt;= threshold)\r\n\r\n    # Iterate over matched locations\r\n    for loc in zip(*locations[::-1]):\r\n        top_left = loc\r\n        bottom_right = (top_left[0] + scaled_template.shape[1], top_left[1] + scaled_template.shape[0])\r\n        cv2.rectangle(matched_image, top_left, bottom_right, (0, 255, 0), 2)\r\n\r\n# Display the images\r\ncv2.imshow('Original Image', original_image)\r\ncv2.imshow('Template Image', template_image)\r\ncv2.imshow('Matched Image (Multi-Scale)', matched_image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()<\/pre>\n<p><strong>Template Image:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Scaling-New-Heights-template.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-126031 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Scaling-New-Heights-template.webp\" alt=\"Scaling New Heights template\" width=\"262\" height=\"236\" \/><\/a><\/p>\n<p><strong>Matched Image:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Scaling-New-Heights-matched.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-126032 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Scaling-New-Heights-matched.webp\" alt=\"Scaling New Heights matched\" width=\"800\" height=\"700\" \/><\/a><\/p>\n<p>In this code, the scales list defines the scales at which the template image will be resized. For each scale, the template image is resized using cv2.resize, and template matching is performed using `cv2.matchTemplate` with cv2.TM_CCOEFF_NORMED. The code then finds matches above a predefined threshold and draws rectangles around the matches on the copy of the original image for visualization.<\/p>\n<h3>Unveiling the Boundaries: Exploring the Limitations of Template Matching in OpenCV<\/h3>\n<p><strong>1. Scale and Rotation Sensitivity:<\/strong> Template matching struggles with objects that vary in scale or are rotated, leading to inaccurate matches.<\/p>\n<p><strong>2. Background Variations:<\/strong> Significant differences between the template and target image background can result in false positives.<\/p>\n<p><strong>3. Partial Occlusion:<\/strong> Template matching may fail when the template is partially occluded in the target image.<\/p>\n<p><strong>4. Complex Scenes:<\/strong> In cluttered or complex scenes, template matching can yield multiple false positives or struggle to find the correct match.<\/p>\n<p><strong>5. Computational Demands:<\/strong> It can be computationally intensive, particularly for large images or templates, impacting real-time applications.<\/p>\n<p><strong>6. Limited Robustness:<\/strong> Template matching is less robust in handling complex scenes, variations in appearance, and noisy images.<\/p>\n<h3>Summary<\/h3>\n<p>In the realm of computer vision, OpenCV&#8217;s template matching stands as a versatile tool for pattern recognition. This technique holds the power to uncover hidden correlations within images, but it&#8217;s crucial to recognize its limitations for optimal results. While sensitive to scale, rotation, and background variations, template matching might encounter challenges in complex scenes, occlusion, and computational efficiency.<\/p>\n<p>This insight guides us to leverage this method judiciously, exploring alternatives when necessary and complementing it with other strategies. Embracing these limitations equips us with a comprehensive understanding, enabling more informed and effective template matching in diverse visual applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unlock the hidden potential of images with OpenCV&#8217;s template matching! In the world of computer vision, the ability to seamlessly find a needle in a haystack of pixels is a superpower. Join us as&#46;&#46;&#46;<\/p>\n","protected":false},"author":86671,"featured_media":135345,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27755],"tags":[31028,31058,29991,31061,31059,31063,31062,31060],"class_list":["post-120188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opencv-tutorials","tag-learn-opencv","tag-opencv-template-matching","tag-opencv-tutorials","tag-template-matching","tag-template-matching-in-opencv","tag-template-matching-using-opencv","tag-template-matching-with-opencv","tag-what-is-template-matching"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OpenCV Template Matching - DataFlair<\/title>\n<meta name=\"description\" content=\"Template matching in OpenCV is a technique used for finding a specific template image within a larger target image.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OpenCV Template Matching - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Template matching in OpenCV is a technique used for finding a specific template image within a larger target image.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-05T12:30:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-05T13:23:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2024\/04\/opencv-template-matching-scaled.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1338\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OpenCV Template Matching - DataFlair","description":"Template matching in OpenCV is a technique used for finding a specific template image within a larger target image.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/","og_locale":"en_US","og_type":"article","og_title":"OpenCV Template Matching - DataFlair","og_description":"Template matching in OpenCV is a technique used for finding a specific template image within a larger target image.","og_url":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2024-04-05T12:30:52+00:00","article_modified_time":"2024-04-05T13:23:50+00:00","og_image":[{"width":2560,"height":1338,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2024\/04\/opencv-template-matching-scaled.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49"},"headline":"OpenCV Template Matching","datePublished":"2024-04-05T12:30:52+00:00","dateModified":"2024-04-05T13:23:50+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/"},"wordCount":1390,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2024\/04\/opencv-template-matching-scaled.webp","keywords":["learn opencv","opencv template matching","opencv tutorials","template matching","template matching in opencv","template matching using opencv","template matching with opencv","what is template matching"],"articleSection":["OpenCV Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/","url":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/","name":"OpenCV Template Matching - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2024\/04\/opencv-template-matching-scaled.webp","datePublished":"2024-04-05T12:30:52+00:00","dateModified":"2024-04-05T13:23:50+00:00","description":"Template matching in OpenCV is a technique used for finding a specific template image within a larger target image.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/opencv-template-matching\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2024\/04\/opencv-template-matching-scaled.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2024\/04\/opencv-template-matching-scaled.webp","width":2560,"height":1338,"caption":"opencv template matching"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/opencv-template-matching\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"OpenCV Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/opencv-tutorials\/"},{"@type":"ListItem","position":3,"name":"OpenCV Template Matching"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49","name":"TechVidvan Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","caption":"TechVidvan Team"},"description":"TechVidvan Team provides high-quality content &amp; courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.","url":"https:\/\/data-flair.training\/blogs\/author\/test001\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/86671"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=120188"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120188\/revisions"}],"predecessor-version":[{"id":135346,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120188\/revisions\/135346"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/135345"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=120188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=120188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=120188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}