简单试水

This commit is contained in:
shikong 2023-09-14 03:00:32 +08:00
parent e949d13f0b
commit b853036dc3

View File

@ -6,14 +6,14 @@ from PIL.Image import Image
import utils.matplotlib
def match_resize(src: Image, tmpl: str, similarity=0.9, step=20, fast=False):
def match_resize(src: Image, tmpl: str, similarity=0.9, step=10, fast=False):
src = cv2.cvtColor(np.asarray(src), cv2.COLOR_RGB2BGR)
src_gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
tmpl = cv2.imread(tmpl)
tmpl_gray = cv2.cvtColor(tmpl, cv2.COLOR_BGR2GRAY)
found = None
tmp_r = 0
for scale in np.linspace(0.2, 1.0, step)[::-1]:
for scale in np.linspace(0.2, 2, step)[::-1]:
# 根据scale比例缩放图像并保持其宽高比
resized = imutils.resize(src_gray, width=int(src_gray.shape[1] * scale))
r = src_gray.shape[1] / float(resized.shape[1])