2

我是opencv和Aruco的新手。我试图找出两个不同 Aruco 标记的轴角差异。例如,现实世界中标记的两个 (1, 0, 0) 向量之间的角度差。据我了解,变换按以下顺序进行:局部坐标-> 相机坐标-> 世界坐标。然后我得到两个 aruco 标记的角度差,因为它们现在都在同一个世界坐标中。有人可以解释这个过程是如何完成的吗?或者有没有更好的方法来找出角度差异?我正在用 python 和 opencv 编码

已知:

  1. 来自 aruco 模块中的 estimatePoseSingleMarkers() 函数的平移和旋转向量 (1x3)。(可以使用 Rodrigues() 将旋转和平移向量转换为矩阵(3x3))
  2. 来自相机校准的相机矩阵(3x3)和 dist_coefs 矩阵(1x5)。
  3. 使用 6x6_250 aruco 标记

更新:

  1. 世界坐标=相机坐标
  2. 下面是绘制 aruco 的 XYZ 组件的函数。看起来原点或相机是 (0, 0, 0)。将 aruco 标记的平移和旋转矩阵应用于原点的 x、y、z 分量,得到 aruco 标记的 x、y、z 分量。那正确吗?

/** */

void drawAxis(InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs,
          InputArray _rvec, InputArray _tvec, float length) {

CV_Assert(_image.getMat().total() != 0 &&
          (_image.getMat().channels() == 1 || _image.getMat().channels() == 3));
CV_Assert(length > 0);

// project axis points
vector< Point3f > axisPoints;
axisPoints.push_back(Point3f(0, 0, 0));
axisPoints.push_back(Point3f(length, 0, 0));
axisPoints.push_back(Point3f(0, length, 0));
axisPoints.push_back(Point3f(0, 0, length));
vector< Point2f > imagePoints;
projectPoints(axisPoints, _rvec, _tvec, _cameraMatrix, _distCoeffs, imagePoints);

// draw axis lines
line(_image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), 3);
line(_image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), 3);
line(_image, imagePoints[0], imagePoints[3], Scalar(255, 0, 0), 3);

}

4

1 回答 1

1

Technically it's a work around to my question. So I figured ARUCO library has this function called projectPoints which maps the 3D objectPoints into 2D imagePoints.

imagePoints[0] and imagePoints[1] gives you the 2D projection of (length, 0, 0). By using arccos(np.dot(v1,v2)), you can get the difference in x-axis angle of the two markers.

于 2017-04-10T04:37:44.267 回答