1. 说明
本案例采用NCC的匹配+金字塔(为了加速)思想,基于OpenCV实现的多角度、多目标模板匹配(不支持尺度不变)。若研究旋转+尺度不变性的匹配,请参考本人的OpenCV专栏内的
《OpenCV实现多角度多尺度模板匹配(基于形状)》
本案例提供代码(内含详细注释)+原始图像。
2. 多目标+多角度
涉及到多角度、多目标时,整个的难度就是阶跃式的提高了一个档次。
如果目标存在旋转,为了能找到发生旋转的物体,我们可以创建多个方向的旋转对象,也就是说,将搜索空间离散化,此时,有两个可选的方式:一个是旋转搜索图像,然后用模板在旋转后的图像中搜索,二是旋转模板,用旋转后的模板在搜索图像中定位。我们说,第一种方式基本不可取,原因有三。
(1)、搜索图像一般来说都是较大的图,对其进行旋转耗时比较可观。、
(2)、实际情况需要多个角度的旋转,对原图旋转内存方面也会有过多的消耗
(3)、工业应用时,一般模