【发布时间】:2019-06-19 11:53:42
【问题描述】:
我正在尝试为游戏制作机器人。基本上它从地上捡起物品,问题是这些物品有时看起来不同。角度不同,或者它们位于不同颜色的地面等。为了使一切正常,我需要多个模板。有没有办法做到这一点?如果您不明白,请在 cmets 中告诉我。到目前为止,这是我尝试过的:
files = ["bones_{}.png".format(x) for x in range(6)]
for i in range(6):
img_gray = cv2.cvtColor(imageGrab(), cv2.COLOR_BGR2GRAY)
f = str(files[i])
template = cv2.imread(f, 0)
w, h = template.shape[:: -1]
res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
threshhold = 0.70
loc = np.where( res >= threshhold)
这可行,但可能会更好。你有什么想法吗?
【问题讨论】:
标签: python opencv templates template-matching