我在获得准确的 aruco 姿势估计时遇到问题。AR 对象相对于相机的变换比应有的小约 2 倍。在下面的屏幕截图中,相机在真实空间中距离标记 z=0.40m,但在虚拟空间中 AR 对象仅距离 ~.20m。
我认为这可能与我从棋盘或 aruco 标记上测量的长度参数有关?
我使用了这些功能:
Aruco.estimatePoseSingleMarkers (corners, markerLength , camMatrix, distCoeffs, rvecs, tvecs);
其中markerLength = 0.122m,是穿过4x4 aruco的距离(不包括黑色边界)
private void EstimatePoseCanonicalMarker (Mat rgbMat)
{
Aruco.estimatePoseSingleMarkers (corners, markerLength, camMatrix, distCoeffs, rvecs, tvecs);
for (int i = 0; i < ids.total (); i++) {
using (Mat rvec = new Mat (rvecs, new OpenCVForUnity.CoreModule.Rect (0, i, 1, 1)))
using (Mat tvec = new Mat (tvecs, new OpenCVForUnity.CoreModule.Rect (0, i, 1, 1))) {
// In this example we are processing with RGB color image, so Axis-color correspondences are X: blue, Y: green, Z: red. (Usually X: red, Y: green, Z: blue)
Calib3d.drawFrameAxes (rgbMat, camMatrix, distCoeffs, rvec, tvec, markerLength * 0.5f);
// This example can display the ARObject on only first detected marker.
if (i == 0) {
UpdateARObjectTransform (rvec, tvec);
}
}
}
}
和:
CalcChessboardCorners (patternSize, squareSize, objectPoint, markerType);
其中 squareSize = .0245m 是棋盘上 1 个方格之间的距离(米)
private void CalcChessboardCorners (Size patternSize, float squareSize, MatOfPoint3f corners, MarkerType markerType)
{
if ((int)(patternSize.width * patternSize.height) != corners.rows ()) {
Debug.Log ("Invalid corners size.");
corners.create ((int)(patternSize.width * patternSize.height), 1, CvType.CV_32FC3);
}
const int cn = 3;
float[] cornersArr = new float[corners.rows () * cn];
int width = (int)patternSize.width;
int height = (int)patternSize.height;
switch (markerType) {
default:
case MarkerType.ChessBoard:
case MarkerType.CirclesGlid:
for (int i = 0; i < height; ++i) {
for (int j = 0; j < width; ++j) {
cornersArr [(i * width * cn) + (j * cn)] = j * squareSize;
cornersArr [(i * width * cn) + (j * cn) + 1] = i * squareSize;
cornersArr [(i * width * cn) + (j * cn) + 2] = 0;
}
}
corners.put (0, 0, cornersArr);
break;
case MarkerType.AsymmetricCirclesGlid:
for (int i = 0; i < height; ++i) {
for (int j = 0; j < width; ++j) {
cornersArr [(i * width * cn) + (j * cn)] = (2 * j + i % 2) * squareSize;
cornersArr [(i * width * cn) + (j * cn) + 1] = i * squareSize;
cornersArr [(i * width * cn) + (j * cn) + 2] = 0;
}
}
corners.put (0, 0, cornersArr);
break;
}
}
我尝试将其中一些值加倍并重新校准以查看它是否使 z 值接近 0.40m,但它似乎没有改变。这让我感觉有点不知所措。我拍了大约 50 张校准照片,它们非常多样化。我尝试在相机上捕捉一系列深度和角度。
有任何想法吗?
谢谢,如果您需要更多信息,请告诉我。