How to get the difference of Aruco Markers' axis-angel in the world coordinate?

时间:2017-04-09 23:35:35

标签: python-2.7 opencv coordinate-transformation aruco

I am new to opencv and Aruco. I attempted to find out the differences in axis-angles of two different Aruco markers. For example, the angle difference b/w the two (1, 0, 0) vectors of markers in the real world. In my understanding, the transform happens in the following order: local coordinate-> camera coordinate -> world coordinate. And then I get angle difference of two aruco markers because they are now both in the same world coordinate. Can someone explain how this process is done? Or is there any better way to find out the angle difference? I am coding with python and opencv

Known:

  1. Translation and rotation vectors(1x3) from estimatePoseSingleMarkers() function in aruco module. (rotation and translation vectors can be transformed to matrix(3x3) with Rodrigues() )
  2. camera Matrix(3x3) and dist_coefs matrix(1x5) from camera calibration.
  3. Using 6x6_250 aruco markers

Upate:

  1. world coordinate = camera coordinate
  2. The following is the function to draw the aruco's XYZ components. It looks like the origin or the camera is (0, 0, 0). Apply the translation and rotation matrix of aruco marker to the x, y, z components of origin gets me the x, y, z components of aruco marker. Is that right?

/** */

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);

}

1 个答案:

答案 0 :(得分:1)

从技术上讲,这是我的问题的解决方法。所以我认为ARUCO库有这个名为projectPoints的函数,它将3D objectPoints映射到2D imagePoints。

imagePoints [0]和imagePoints [1]为您提供(长度,0,0)的2D投影。通过使用arccos(np.dot(v1,v2)),您可以获得两个标记的x轴角度的差异。