Log in or register to post comments

Unified Target Coordinates Modification

February 6, 2013 - 5:47am #1


I've been trying to modify the "Unified Target Coordinates" example; I'm trying to connect an ImageTarget to a FrameMarker instead of two ImageTargets, but I can't... I think that the FrameMarker pose matrix has something to do with that... Can anyone help me, please?

Unified Target Coordinates Modification

February 13, 2013 - 2:22am #9

You're welcome!

Unified Target Coordinates Modification

February 13, 2013 - 2:10am #8


Thank so muuuch Alessandro!! :)

Unified Target Coordinates Modification

February 13, 2013 - 2:01am #7

Hi, one problem I see with your code is that it may not work in case the Image Target is listed before the Frame Marker within the for loop (i.e. if the getTrackableResult( 0 ) is the Image Target and the getTrackableResult( 1 ) is the marker); 

this is because the mainModelViewMatrix needs to be set before computing the offset matrix;

so, I would suggest trying to do two "for loops", in the first loop you iterate over your trackable resulte so to catch the Frame Marker and set the mainModelViewMatrix to the modelview matrix of the Frame Marker (and then exit the loop via "break;")

in the second "for loop", you iterate again and basically execute the code that you already have, except that you don't need to set again the mainModelViewMatrix (which was already set in the first loop);

this approachwill ensure that the mainModelViewMatrix is correctly set regardless of the order in which the ImageTarget and the FrameMarker appear.

That's the only issue I see; for the rest it should work.


Unified Target Coordinates Modification

February 12, 2013 - 4:21pm #6

Thank you! I'm trying to get it works...

As I showed in the picture I'm triyng to get an ImageTarget as "center of the world" and a FrameMarker referred to it. But all I've got is the opposite thing; the FrameMarker as center...:

for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
        // Get the trackable:
        const QCAR::TrackableResult* trackable = state.getTrackableResult(tIdx);
        const QCAR::Trackable& t = trackable->getTrackable();
        QCAR::Matrix44F modelViewMatrix =
        if (t.isOfType(QCAR::Trackable::MARKER))
            // Make the first visible target our world center (0, 0, 0)
            // Store its modelViewMatrix and continue looking for other targets
            mainModelViewMatrix = modelViewMatrix;
            targetCenters[0].data[0] = 0.0f;
            targetCenters[0].data[1] = 0.0f;
            targetCenters[0].data[2] = 0.0f;
        else if (t.isOfType(QCAR::Trackable::IMAGE_TARGET))
            // This is another visible target
            // Find its center point in relation to the first target
            // To do this we use the matrix inverse function (SampleMath.h from the Dominoes project)
            QCAR::Matrix44F mainModelViewInverse = SampleMath::Matrix44FInverse(mainModelViewMatrix);
            QCAR::Matrix44F modelViewTranspose = SampleMath::Matrix44FTranspose(modelViewMatrix); // let's work with row-major matrices
            QCAR::Matrix44F offsetMatrix = QCAR::Tool::multiply(mainModelViewInverse, modelViewTranspose);
            // Transform a point on the second target by this offset matrix
            // (0, 0, 0) is the local center of the target
            QCAR::Vec4F position(0.0f, 0.0f, 0.0f, 1.0f);
            position = SampleMath::Vec4FTransform(position, offsetMatrix);
            // Add this position to our array
            targetCenters[1].data[0] = position.data[0];
            targetCenters[1].data[1] = position.data[1];
            targetCenters[1].data[2] = position.data[2];
            printf("%f %f %f\n",targetCenters[0].data[0],targetCenters[0].data[1],targetCenters[0].data[2]);
            printf("%f %f %f\n\n",targetCenters[1].data[0],targetCenters[1].data[1],targetCenters[1].data[2]);


If I switch the conditions to make the ImageTarget the center of the world and get the Marker referred to it; It doesn't work!!! I don't know why!


PD: The system can recognize Markers and ImageTargets simultaneously properly (2 trackers)




Unified Target Coordinates Modification

February 11, 2013 - 6:10am #5

BTW: I just realized that I'm pointing you to the same article as in a previous message; the thing is: the basic maths are all there explained int he article, then you just need to extract the position and orientation angle from those matrices.

Unified Target Coordinates Modification

February 11, 2013 - 6:07am #4

Hi, first, happy that your issue is solved.

Concerning your second question:

yes, it is possible to compute the position and orientation of a target with respect to another target (what you call the "world base" target);

the idea is to use matrix inversion and matrix multiplication, as explained for instance in this article here:


One note: your scenario will only work if the secondary markers do not completely occlude your "world base" target, so pay attention to the size and positiin of the markers that you put on top of the base target.


Unified Target Coordinates Modification

February 11, 2013 - 5:55am #3

Thanks, solved!!

I have another question; I don't know wheter it is possible to do or not; and if it´s possible how to do it...

I'm using an ImageTarget as my "world base" and several frame markers which are placed above it; I'd like to know if it es possible to get some information about the position of these markers respect to the base ImageTarget.

The information required is:

- the projection of the marker center in (X,Y) ImageTarget coordinate system (to know where the center of the marker is placed above the base image)

- the angle between the axis of both coordinate systems

In this image is explained better:


Can anyone help me please? Thanks!!


Unified Target Coordinates Modification

February 6, 2013 - 8:45am #2

Hi, have you already double-checked the instructions and code snippets provided here ?


In particular, in the following snippet:

for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)

you can LOG the pose matrix from each trackable, and see if you get values that make some sense (and, above all, you can verify that you actually get two trackables, one for the Image Target and one for the Frame Marker...)


Log in or register to post comments