OpenCV - 如何检测和测量两帧之间的角度?

发布于 2024-11-04 18:41:40 字数 249 浏览 9 评论 0原文

我正在尝试理解和使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流殇 2024-11-11 18:41:40

如果您能够检测帧上的静态对象(例如背景),那么您可能会在背景上找到名为 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):

enter image description here

Where \theta is the rotation angle

或十年 2024-11-11 18:41:40

好吧,这可能非常棘手,一个更简单的解决方案可能是找到框架的霍夫线。当然,您需要确定可以在两个帧之间跟踪的最佳且稳定的线在哪里,一旦可用,您就可以找到两个帧之间的角度。安德烈提出的寻找角度的建议也应该可用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文