G.L G.L - 3 years ago 130
Android Question

2D Position of marker

Hi there I'm using ARToolKit v6 to render marker based on nft jpg image it works very well but..
I need to get position of marker in screen(view) and then add a custom textView there is that possible ? how to get 2d position of marker based on projectionMatrix and modelViewMatrix ?

Or can I draw a text or image instead of Cube ?


public void draw() {


boolean show = false;
for (int trackableUID : trackableUIDs) {
if (ARToolKit.getInstance().queryMarkerVisible(trackableUIDs.get(trackableUID))) {
float[] projectionMatrix = ARToolKit.getInstance().getProjectionMatrix();
float[] modelViewMatrix = ARToolKit.getInstance().queryMarkerTransformation(trackableUIDs.get(trackableUID));
Log.i("INFOOOOO", projectionMatrix.toString());
Log.i("INFOOOOO", modelViewMatrix.toString());
cube.draw(projectionMatrix, modelViewMatrix);
show = true;

Answer Source

@sturner thanks so much , I found a solution below is the code if someone is looking for solution

            final float[] projectionMatrix = ARToolKit.getInstance().getProjectionMatrix();
            final float[] modelViewMatrix = ARToolKit.getInstance().queryMarkerTransformation(trackableUIDs.get(trackableUID));

            if (view == null) {
                view = new int[4];
                view[0] = 0;
                view[1] = 0;
                view[2] = ARTrackingActivity.width;
                view[3] = ARTrackingActivity.height;

            int i = GLU.gluProject(0, 0, 0, modelViewMatrix, 0, projectionMatrix, 0, view, 0, floats, 0);
            if (i == GLES20.GL_TRUE) {
               // draw the object in screen
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download