OpenCV - 如何检测和测量两帧之间的角度?
我正在尝试理解和使用 OpenCV。我想知道是否可以找到并测量两个框架之间的角度。
我解释说:凸轮是固定的,框架可以绕中心旋转,不会移动。现在我设法手动旋转,我希望能够比较帧并返回角度。例如:
double getRotation(Image img1, Image img2) {
//Compare the frames
//Return the value
}
然后我按照该角度旋转。
I'm trying to understand and use OpenCV. I wanted to know if it is possible to find and measure an angle between two frames.
I explain : The cam is fix and the frames could rotate around the center and won't move. For now I managed to rotate manually and I would like to be able to compare frames and return the angle. For instance :
double getRotation(Image img1, Image img2) {
//Compare the frames
//Return the value
}
and then I rotate following that angle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您能够检测帧上的静态对象(例如背景),那么您可能会在背景上找到名为 good_features_to_track (
cvGoodFeaturesToTrack
) 的点,并使用optical_flow (cvCalcOpticalFlowPyrLK
) 跟踪这些点>)。如果旋转仅在“xy”平面上,您可以使用
cvGetAffineTransform
检测旋转。由于只允许旋转(不允许平移和缩放),因此使用由
cvGetAffineTransform
获得的变换矩阵来确定旋转角度并不困难。该矩阵看起来像(参见 wikipedia):其中 \theta 是旋转角度
If you're able to detect static objects, e. g. background, on the frames then you may find points called good_features_to_track (
cvGoodFeaturesToTrack
) on the background and track this points using optical_flow (cvCalcOpticalFlowPyrLK
).If rotation is only on 'xy' plain you're able to detect rotation using
cvGetAffineTransform
.Since only rotation is allowed (no translation and scaling) it's not difficult to determine an angle of rotation using transformation matrix, obtained by
cvGetAffineTransform
. That matrix looks like (see wikipedia):Where \theta is the rotation angle
好吧,这可能非常棘手,一个更简单的解决方案可能是找到框架的霍夫线。当然,您需要确定可以在两个帧之间跟踪的最佳且稳定的线在哪里,一旦可用,您就可以找到两个帧之间的角度。安德烈提出的寻找角度的建议也应该可用。
Well this might be very tricky, just a simpler solution might be to find the hough lines of the frames. Of course you would need to determined where the best and stable lines are which you can track between the two frames, once that is available, you can then find the angle between the two frames. What Andrey has suggested for finding the angles should be usable as well.