Rotation and scale invariant template matching in OpenCV [duplicate]

别等时光非礼了梦想. 提交于 2019-12-03 03:35:31
krzych

Try the easiest method first.

If I understand you correctly you have some model - black shape over white background. You can treat it as blob - find it's mass center and rotation by computing principal axes angle - look there.

Then you must segment out shapes from other images. Then try to find the best corresponding shape with matchShapes() function - see there how to use it.

matchShapes() function makes scale and rotation invariant matching. The smallest match shapes result the better match.

Extending your question you can find mass center and rotation of best matching blob and find rotation, scale and displacement between your model and matched image.

This is quite a complex subject. You generally have options such as Generalized Hough Transform and Normalized Grayscale Correlation to deal with template matching. Problem is they are not scale or rotation invariant in their simplest expression. You need to focus on problem at the time, the generalized solution is complex. I recommend simple template matching first. Then add "hacks" for rotation and scale. For rotation you can downscale (low res. matching) and template match with rotated models. This can also deal with scale.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!