找到的图像的取向 [英] Find the orientation of an image
问题描述
我在做图案OpenCV的匹配。我有一个模式,我比较目标与功能cvMatchShapes。
它的工作原理,但我想知道目标的方位。我该怎么办呢?
I'm doing pattern matching with OpenCv. I have a model and I compare targets with the function cvMatchShapes. It works but I want to know the orientation of the target. How can I do it?
推荐答案
的边界适合的情况下旋转矩形轮廓时,不同方向180度的例子吗?
Are bounding rotated rectangle suited for case when contour orientation differs 180 degrees for example?
解决你的问题的另一种方法是计算轮廓瞬间(我想你是尤斯轮廓在cvMatchShapes,就可以计算出在太多相似的方法图像矩)的 OpenCV的轮廓时刻,从公式然后计算主轴角度:
Another way for solving your problem is to calculate contours moments (I suppose you are ussing contours in cvMatchShapes, you can compute image moments in similar way too) OpenCV Contours Moments?, then calculating principal axes angle from formula:
atan2((float)(-2)*Ixy,Ix - Iy)/2
这个角度说,大约转动。有关此问题的理论: http://farside.ph.utexas.edu /teaching/336k/newton/node67.html
This angle says about rotation. More theory about this issue: http://farside.ph.utexas.edu/teaching/336k/newton/node67.html
这篇关于找到的图像的取向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!