2

我对 ARToolKitPlus 的 iPhone 端口 VRToolkit 有一个小问题。我不需要框架的 3D 东西,只需要检测到的标记的信息。到目前为止一切正常,我坚持使用在每一帧上实时生成的标记顶点坐标。

我想通过在其边缘绘制一个简单的 CGRect 来可视化检测到的标记。我在'TrackerSingleMarkerImpl.cxx'中获取标记顶点,我主要使用某种代码:

vertexArray[0] = marker_info[k].vertex[0][0];
vertexArray[1] = marker_info[k].vertex[0][1];
vertexArray[2] = marker_info[k].vertex[1][0];
vertexArray[3] = marker_info[k].vertex[1][1];
vertexArray[4] = marker_info[k].vertex[2][0];
vertexArray[5] = marker_info[k].vertex[2][1];
vertexArray[6] = marker_info[k].vertex[3][0];
vertexArray[7] = marker_info[k].vertex[3][1];

CGRect 已成功绘制,但问题是它已完全镜像。所以水平轴和垂直轴是镜像的——当我交换 X 和 Y 时,只有垂直轴保持镜像,看起来像这样:

http://i1218.photobucket.com/albums/dd416/vyrb1/artoolkit_marker_failure.png

你知道这里可能是什么问题吗?我不需要一个确切的问题,而是问题可能出在哪里的粗略方向。我试图调整像“arGetTransMat.cxx”这样的文件,但我不确定问题是否出在生成的顶点坐标上——3D 模型在标记上的投影效果很好,但这是在 3D 空间中。我没有使用 OpenGL ES (EAGLView) 中使用的投影矩阵,因为我只需要 2D 和 CGRect。

我希望你能帮忙。提前致谢。

4

1 回答 1

0

自从我使用 ARToolKit 已经有一段时间了,即使那时我也懒惰地使用他们的 OpenGL 函数,但我认为你必须根据标记的方向来确定你的角顶点(dir是一个字段marker_info

我在 Google 上快速搜索了“ARToolKit marker_info vertex corner”并找到了这个,这似乎支持了我的预感。

// read in the detected corners from the marker info (easier to work with)
for (int i = 0; i < 4; i++) {
    corners_ar[2*i]   = corners[i][0] = marker_info[best].vertex[(4+i-dir)%4][0];
    corners_ar[2*i+1] = corners[i][1] = marker_info[best].vertex[(4+i-dir)%4][1];
}
于 2012-01-19T12:19:30.610 回答