gpt4 book ai didi

opencv - 使用旋转矩阵opencv

转载 作者:太空宇宙 更新时间:2023-11-03 21:28:17 25 4
gpt4 key购买 nike

我有一个来自 opencv 中的函数 Core.Rodrigues 的旋转矩阵。我想通过这个旋转矩阵围绕原点旋转一个位于 (0, 0, 1) 的点。我该怎么做才能获得该点的新位置?

   Mat rmat= new Mat();
Calib3d.Rodrigues(rvec, rmat); //rvec is the rotation vector from solvepnp
double[] p= {0, 0, 1};
Scalar scalar= new Scalar(p);
Mat point= new Mat(1, 3, CvType.CV_64F, scalar);
Mat newpoint= new Mat();
Mat empty= new Mat();
Core.gemm(point, rmat, 1, empty, 0, newpoint);

newpoint 的结果是 0, 0, 0,当我知道那是错误的

如有任何帮助,我们将不胜感激。

最佳答案

绕原点旋转一个点的方法是将它与旋转矩阵预乘。我不熟悉 Core.gemm。这是一种更透明的方法。

Mat rmat= new Mat();
Calib3d.Rodrigues(rvec, rmat); //rvec is the rotation vector from solvepnp
Matx33f rotation_matrix = rmat;
Matx31f original_point(0,0,1);
Matx31f rotated_point = rotation_matrix*original_point;

这应该更容易调试。检查存储在 rotation_matrix 中的值,确保它们被初始化为合理的值(可以在调试器中看到 Matx 的内容)。您可以查看这些值并自己进行乘法以仔细检查是否愿意。这个过程应该是完全透明的。

关于opencv - 使用旋转矩阵opencv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11704221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com