简单试水
This commit is contained in:
parent
e949d13f0b
commit
b853036dc3
@ -6,14 +6,14 @@ from PIL.Image import Image
|
|||||||
import utils.matplotlib
|
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 = cv2.cvtColor(np.asarray(src), cv2.COLOR_RGB2BGR)
|
||||||
src_gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
|
src_gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
|
||||||
tmpl = cv2.imread(tmpl)
|
tmpl = cv2.imread(tmpl)
|
||||||
tmpl_gray = cv2.cvtColor(tmpl, cv2.COLOR_BGR2GRAY)
|
tmpl_gray = cv2.cvtColor(tmpl, cv2.COLOR_BGR2GRAY)
|
||||||
found = None
|
found = None
|
||||||
tmp_r = 0
|
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比例缩放图像,并保持其宽高比
|
# 根据scale比例缩放图像,并保持其宽高比
|
||||||
resized = imutils.resize(src_gray, width=int(src_gray.shape[1] * scale))
|
resized = imutils.resize(src_gray, width=int(src_gray.shape[1] * scale))
|
||||||
r = src_gray.shape[1] / float(resized.shape[1])
|
r = src_gray.shape[1] / float(resized.shape[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user