本文整理匯總了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