Question

I have a small problem with VRToolkit, an iPhone port of ARToolKitPlus. I don't need the 3D stuff of the framework but only the information of the detected marker. Everything works fine so far and I'm stuck with the marker vertex coordinates which are generated in real time on every frame.

I want to visualize the detected marker by drawing a simple CGRect around the edges of it. I'm getting the marker vertices in the 'TrackerSingleMarkerImpl.cxx' and I'm mainly using some sort of this code:

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

The CGRect is drawn successfully but the problem is that it's mirrored completely. So the horizontal and vertical axis are mirrored - when I swap X and Y, only the vertical axis remains mirrored which looks something like this:

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

Do you have any idea what could be the problem here? I don't need an exact question but a rough direction of where the problem could be. I tried to adjust files like 'arGetTransMat.cxx' but I'm not sure if the problem lies in the generated vertex coordinates - the projection of 3D models on the marker works perfectly well but this is in 3D space. I'm not using the projection matrix used in OpenGL ES (EAGLView) because I only need 2D and CGRect.

I hope you can help. Thanks in advance.

Was it helpful?

Solution

It's been a while since I used ARToolKit, and even then I was lazily using their OpenGL functions, but I think you have to determine your corner vertices based on the direction of the marker (dir is a field in marker_info)

I did a quick Google search for "ARToolKit marker_info vertex corner" and found this, which seems to support my hunch.

// 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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top