Which marker is lost in the layout of markers?

Apr 18, 2011 at 4:21 PM

Do we have a way (function/attributes) to know which marker is lost among the layout of markers?

Let say I have 4 markers in the custom marker layout generated from Markerlayout tool, how do I know which marker is lost during the tracking?

Many thanks

Apr 18, 2011 at 8:51 PM

Well, I think i got it from one of ohan's post in this forum at http://goblinxna.codeplex.com/discussions/237183.



Apr 19, 2011 at 12:02 AM

Each MarkerNode has an IsFound or something like that.


Do know which individual marker node is missing (not detected), you'd need to create a markerNode using the IDs (identification numbers) for each marker..so for 4 markers you'd need 4 marker nodes.


In your update() method, check the isFound (or found or whatever)

Apr 19, 2011 at 3:14 AM

// Load ALVAR marker IDs from XML file
var alvarMarkerIds = GetDataFromXml(xmlFileName, out scale, out Dimensions);

// Register ALVAR marker IDs with tracker and get tracker IDs
int[] trackerIds = new int[alvarMarkerIds.Length];
for (var i = 0; i < alvarMarkerIds.Length; i++)
   trackerIds[i] = (int)tracker.AssociateMarker(alvarMarkerIds[i]);

// Count found markers using LINQ
var foundMarkerCount = trackerIds.Sum(t => tracker.FindMarker(t) ? 1 : 0);

// Convert to percentage
var multiMarkerFoundPercentage = (float) foundMarkerCount/trackerIds.Length;

// Function to load ALVAR markerIds from an ALVAR XML config file
private static int[] GetDataFromXml(string filename, out float scale, out Vector4 dimensions)
    var list = new List<int>();
    var corners = new List<Vector3>();
    var reader =
        new XmlTextReader(filename)
            WhitespaceHandling = WhitespaceHandling.Significant

    while (reader.Read())
        if (reader.NodeType != XmlNodeType.Element) continue;

        if (reader.Name.Equals("marker"))
            if (!reader.HasAttributes) continue;


                if (!reader.Name.Equals("index")) continue;

            while (reader.MoveToNextAttribute());

        else if (reader.Name.Equals("corner"))
            if (!reader.HasAttributes) continue;

            var v = new Vector3();


                if (reader.Name.Equals("x"))
                    v.X = float.Parse(reader.Value);
                else if (reader.Name.Equals("y"))
                    v.Y = float.Parse(reader.Value);
                else if (reader.Name.Equals("z"))
                    v.Z = float.Parse(reader.Value);
            while (reader.MoveToNextAttribute());



    var minX = corners.Min(v => v.X);
    var minY = corners.Min(v => v.Y);
    var maxX = corners.Max(v => v.X);
    var maxY = corners.Max(v => v.Y);
    var width = maxX - minX;
    var height = maxY - minY;

    var singleMarker = corners.GetRange(0, 4);

    scale = singleMarker.Max(v => v.X) - singleMarker.Min(v => v.X);

    dimensions = new Vector4((maxX + minX)/2, (maxY + minY)/2, width, height);

    return list.ToArray();