本文整理汇总了Python中cv2.TM_CCOEFF属性的典型用法代码示例。如果您正苦于以下问题:Python cv2.TM_CCOEFF属性的具体用法?Python cv2.TM_CCOEFF怎么用?Python cv2.TM_CCOEFF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cv2
的用法示例。
在下文中一共展示了cv2.TM_CCOEFF属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_watermark_from_gray
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import TM_CCOEFF [as 别名]
def find_watermark_from_gray(self, gray_img, watermark_template_gray_img):
"""
从原图的灰度图中寻找水印位置
:param gray_img: 原图的灰度图
:param watermark_template_gray_img: 水印模板的灰度图
:return: x1, y1, x2, y2
"""
# Load the images in gray scale
method = cv2.TM_CCOEFF
# Apply template Matching
res = cv2.matchTemplate(gray_img, watermark_template_gray_img, method)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
# If the method is TM_SQDIFF or TM_SQDIFF_NORMED, take minimum
if method in [cv2.TM_SQDIFF, cv2.TM_SQDIFF_NORMED]:
x, y = min_loc
else:
x, y = max_loc
return x, y, x + self.watermark_template_w, y + self.watermark_template_h
示例2: findmatchtemplate
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import TM_CCOEFF [as 别名]
def findmatchtemplate(filepathname, befindimage):
# 从 befindimage 中找到 filepathname,(befindimage 是大图,filepathname 是小图)
img1 = cv2.imread(filepathname)
img2 = cv2.imread(befindimage)
w, h = img1.shape[:2]
v = cv2.matchTemplate(img2,img1,cv2.TM_CCOEFF)
a, b, c, top_left = cv2.minMaxLoc(v)
bot_right = top_left[0]+h, top_left[1]+w
img3 = cv2.rectangle(img2, top_left, bot_right, (155,155,0), 1)
cv2.imshow('nier', img3)
# cv2.waitKey()
# cv2.destroyAllWindows()
return top_left[0], top_left[1], w, h
示例3: other
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import TM_CCOEFF [as 别名]
def other():
scr = cv2.imread(screenFile, 0)
icon = cv2.imread(iconFile, 0)
res = cv2.matchTemplate(icon, scr, cv2.TM_CCOEFF)
minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(res)
topLeft = maxLoc
print topLeft