旋转矩阵openCV [英] Rotation matrix openCV

查看:306
本文介绍了旋转矩阵openCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何找到框架中一组要素的旋转矩阵. 我会更具体.我有2个具有20个要素的框架,比方说第1帧和第2帧.我可以估计两个框架中要素的位置.例如,假设某个帧1的特征位于位置(x,y),而我确切地知道它在哪里,那么就说(x',y').

我的问题是要素已移动并且可能已旋转,所以我想知道如何计算旋转矩阵,我知道2D的旋转矩阵:

但是我不知道如何计算角度,以及如何做到这一点?我在OpenCV中尝试了一个函数,该函数为cv2DRotationMatrix();,但是如上所述的问题,我不知道如何计算旋转矩阵的角度,另一个问题是它给出2 * 3矩阵,所以它不起作用如果我将这个20 * 2矩阵作为参数,(20是要素数量,2是(x,y)中的位置),然后将其乘以2 * 3,这就是函数的结果,那么我将获得20 * 3的矩阵,这似乎不太现实,因为我正在使用2D.
所以我该怎么做?再具体一点,请教我如何计算在矩阵中使用角度?

解决方案

我不确定我是否理解您的问题,但是如果您想找出由任意变换产生的旋转角度...

一个简单的技巧是将点[0 0]和[1 0]转换,并将射线的角度从第一个转换点转换为第二个点.

o = M • [0 0]
x = M • [1 0]
d = x - o
θ = atan2(d.y, d.x)

这不考虑偏斜和其他非正交变换,因为角度"的概念含糊其词.

I would like to know how to find the rotation matrix for a set of features in a frame. I will be more specific. I have 2 frames with 20 features, let's say frame 1 and frame 2. I could estimate the location of the features in both frames. For example let say a certain frame 1 feature at location (x, y) and I know exactly where it is so let's say (x',y').

My question is that the features are moved and probably rotated so I wanna know how to compute the rotation matrix, I know the rotation matrix for 2D:

But I don't know how to compute the angle, and how to do that? I tried a function in OpenCV which is cv2DRotationMatrix(); but the problem which as I mentioned above I don't know how to compute the angle for the rotation matrix and another problem which it gives 2*3 matrix, so it won't work out cause if I will take this 20*2 matrix, (20 is the number of features and 2 are the location in (x,y)) and multiply it by the matrix by 2*3 which is the results from the function then I will get 20*3 matrix which it doesn't seem to be realistic cause I'm working with 2D.
So what should I do? To be more specific again, show me how to compute the angle to use it in the matrix?

解决方案

I'm not sure I've understood your question, but if you want to find out the angle of rotation resulting from an arbitrary transform...

A simple hack is to transform the points [0 0] and [1 0] and getting the angle of the ray from the first transformed point to the second.

o = M • [0 0]
x = M • [1 0]
d = x - o
θ = atan2(d.y, d.x)

This doesn't consider skew and other non-orthogonal transforms, for which the notion of "angle" is vague.

这篇关于旋转矩阵openCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆