Android ARToolkit – The location of the marker
I’m using ARToolkit for Android and trying to write a text on the detected markup. I want to do this with a simple TextView. So I only use ARToolkit to find the markup.
But how can I find the correct location of the marker in my camera preview (I need coordinates) so I can put the TextView on the marker?
Thanks in advance!
Both comments are correct, ARToolkit returns a projection matrix and a transformation matrix. Both are designed to work with OpenGL, not with the standard Android View. The projection matrix is applied to the camera and the transformation is applied to the object (pose matrix).
If you only want to display text, I recommend that you use a Unity plugin and then use Unity UI components to add Canvas and text attached to markup. These components have been designed as 3D objects (if you do, remember to set the Canvas to “world space”.)
You have other options:
a) Render text into textures and draw it on the Quad, which you can do based on an example with a cube.
b) Use matrices
for some matrix calculations and use transformation matrices (Android classes) to apply transformations to the position and rotation of the TextView. Although possible, the mathematics involved is quite complex. If you want it to just float and look at the camera, setTranslationX, Y, and Z are enough.
c) Link a 3D engine with text rendering capabilities to ARToolkit. I’ve done it with jPCT-AE. While this is doable, it takes a lot of work. I plan to write it down soon.