cv2ext.template package¶
Module contents¶
Subpackage containing tools for working with templates in images.
Functions¶
match_single()Find the best match of a template in an image.
match_multiple()Find all matches of a template in an image above a certain threshold.
- cv2ext.template.match_multiple(image: ndarray, template: ndarray, method: int = 5, threshold: float = 0.8) list[tuple[int, int, int, int]][source]¶
Find all matches of the template in the image.
- Parameters:
image (np.ndarray) – The image to search for the template in.
template (np.ndarray) – The template to search for in the image.
method (int) – The method to use for template matching. One of cv2.TM_*. Default is cv2.TM_CCOEFF_NORMED.
threshold (float) – The threshold to use for matches. Default is 0.8.
- Returns:
A list of tuples containing the x1, y1, x2, and y2 coordinates of the matches.
- Return type:
- cv2ext.template.match_single(image: ndarray, template: ndarray, method: int = 5) tuple[int, int, int, int][source]¶
Find all matches of the template in the image.
- Parameters:
image (np.ndarray) – The image to search for the template in.
template (np.ndarray) – The template to search for in the image.
method (int) – The method to use for template matching. One of cv2.TM_*. Default is cv2.TM_CCOEFF_NORMED.
- Returns:
A tuple containing the x1, y1, x2, and y2 coordinates of the match.
- Return type: