Custom Marker

Jan 25, 2011 at 7:00 AM



I have created sample application using the SLARToolkit. I have created custom marker as per the steps mentioned in the documents but still it is identifying the default marker. How to modify the code so that it will recognize only the custom marker and not the default marker?




Jan 25, 2011 at 9:17 AM

The algorithm detects all black rectangles regardless the pattern inside it. However, you can check for a certain pattern in the MarkersDetected event.

This is how you would load your custom marker and initialize the ArDetector.

myMarker = Marker.LoadFromResource("data/myMarker_L_16x16segments_80width.pat", 16, 16, 80.0, "L");
ArDetector = new CaptureSourceMarkerDetector(captureSource, 1, 4000, new List<Marker> { myMarker });

In the event handler you can test for your marker in the returned e.DetectionResults:

var myMarkerResult = detectedResults.FirstOrDefault(r => r.Marker == myMarker);


Just look and understand the SLARToolkit sample and you will see how it's used there.

- Rene Schulte

Jan 25, 2011 at 9:41 AM

Hi Rene,

I have created custom marker and added following code to initilize the marker.

 markerHitched = Marker.LoadFromResource("data/hitched_marker_new_80Width.pat", 16, 16, 80.0,"hitched");         
 ArDetector = new CaptureSourceMarkerDetector(captureSource, 1, 4000, new List<Marker> { markerHitched });

In the event handler added following code , but it is still identifying the other markers.

var resultL = detectedResults.FirstOrDefault(r => r.Marker == markerHitched);
         if (resultL != null)
             ApplyTransformation(GrdARContent1, resultL.Transformation);

Can you please help me to sort this issue?

Jan 25, 2011 at 10:17 AM

What do you mean by "identifying"? 

Jan 25, 2011 at 10:24 AM


Following line should match the custom marker with the detected marker.

var resultL = detectedResults.FirstOrDefault(r => r.Marker == markerHitched);

But, when I am running application and just moving my hand in front of the camera it goes into result != null statement. This means it is identifying all the marker regardless of the custom marker.


Jan 25, 2011 at 11:01 AM

I see. Seems like a false positive was detected in your hand. This can happen, you should try it with different real markers. 

There's the Confidence property of the DetectionResult class. It tells you how good the pattern match was. It should be > 0.5. The XML help for the property says:

/// The confidence / quality  of the result (Is this really the marker?). The maximum value is 1. 

You can change your code to this:

if (resultL != null)
    if(resultL.Confidence > 0.5)
         ApplyTransformation(GrdARContent1, resultL.Transformation);

You might have to try different values as threshold.

Jan 25, 2011 at 11:41 AM

Thank you Rene for your help.

It is working with the resultL.Confidence property.  I am trying to set the exact value of the resultL.Confidence.




May 29, 2011 at 6:14 AM
Edited May 29, 2011 at 6:37 AM

Hello, i'm needing some help in here, and your case is preatty much what I want, I tryed to run this source but, my application coudn't find this methods FirstOrDefault and ApplyTransformation. And the object GrdARContent1.


Does anybody knows what is it?

Mar 26, 2012 at 9:13 PM

Hey dadoshinoda, Have you tried to put all the using statements??, something similar happend to me and that worked =)