C# 如何从c语言中的3x3单应矩阵获得旋转、平移和剪切#
我计算了3x3单应矩阵,我需要得到旋转、平移、剪切和缩放,才能将它们用作windows8媒体元素属性中的参数 见C# 如何从c语言中的3x3单应矩阵获得旋转、平移和剪切#,c#,windows-8,transformation,homography,C#,Windows 8,Transformation,Homography,我计算了3x3单应矩阵,我需要得到旋转、平移、剪切和缩放,才能将它们用作windows8媒体元素属性中的参数 见 您可以从以下链接开始:[查找矩阵变换的旋转和倾斜][1][1]:为什么在您的输入参数中存在标准化单应矩阵2x3?@FäridAlijani在我的例子中,它是使用OpenCV(H,mask)=cv2计算的单应矩阵(H)。findHomography(ptsA,ptsB,method=cv2.RANSAC) def getComponents(normalised_homography)
您可以从以下链接开始:[查找矩阵变换的旋转和倾斜][1][1]:为什么在您的输入参数中存在标准化单应矩阵2x3?@FäridAlijani在我的例子中,它是使用OpenCV
(H,mask)=cv2计算的单应矩阵(H)。findHomography(ptsA,ptsB,method=cv2.RANSAC)
def getComponents(normalised_homography):
'''((translationx, translationy), rotation, (scalex, scaley), shear)'''
a = normalised_homography[0,0]
b = normalised_homography[0,1]
c = normalised_homography[0,2]
d = normalised_homography[1,0]
e = normalised_homography[1,1]
f = normalised_homography[1,2]
p = math.sqrt(a*a + b*b)
r = (a*e - b*d)/(p)
q = (a*d+b*e)/(a*e - b*d)
translation = (c,f)
scale = (p,r)
shear = q
theta = math.atan2(b,a)
return (translation, theta, scale, shear)