点击下方卡片,关注“ OpenCV与AI深度学习”
视觉/图像重磅干货,第一时间送达!
导读
本文将介绍使用OpenCV实现多角度模板匹配的详细步骤 + 代码。(来源公众号:OpenCV与AI深度学习)
背景介绍
熟悉OpenCV的朋友肯定都知道OpenCV自带的模板匹配matchTemplate方法是不支持旋转的,也就是说当目标和模板有角度差异时匹配常常会失败,可能目标只是轻微的旋转,匹配分数就会下降很多,导致匹配精度下降甚至匹配出错。另一个方法是matchShape(形状匹配),匹配时需要轮廓分明才容易匹配成功,但无法的到匹配角度,也不方便使用。本文介绍基于matchTemplate + 旋转 + 金字塔下采样实现多角度的模板匹配,返回匹配结果(斜矩形、角度、方向)。