Alternative to adaptive thresholding

As cool as it is, adaptive thresholding generates too much redundant data. The only alternative implemented before seems to be the method called automatic thresholding, suggested by ARToolKitPlus folks:

ARToolKitPlus can do dynamic thresholding by looking at the marker content (pattern) and taking the average between the darkest and brightest pixels. If no marker is found the threshold value is randomized.

From this description alone, it is clear that there will be frames with marker undetected even though it is clearly visible in the image, so I thought, until now, that this method has to be quite bad. It turns out, however, that this method actually works very well and the number of lost frames is very small. In practice, you don’t even have to find pixel values range, it suffices to assume that current good threshold value lies close to last known one.

On code side, you no longer need to write or import some fancy filter classes, all you have to do is to modify your fixed thresholding main loop just a bit:

private var threshold:Number = 0.5;
private var confidence:Number = 0, confidenceThreshold:Number = 0.5;
private function onEnterFrame (e:Event):void {
	videoSnapshot.draw (video);

	if (confidence < confidenceThreshold) {
		// randomize threshold
		threshold *= 0.8;
		threshold += 0.2 * Math.random ();

	confidence = 0;
	if (detector.detectMarkerLite (raster, 255 * threshold)) {
		confidence = detector.getConfidence ();

		detector.getTransformMatrix (result);
		stuff.setTransformMatrix (result);

	scene.render ();

If you’re sandy fan, you can play with this method using this stub code.


11 Responses to “Alternative to adaptive thresholding”

  1. 1 mirror2image July 18, 2009 at 11:23

    But that “dynamic thresholding” is adaptive thresholding too, and not very sophisticated at it. In my tracker I divide screen on cells and use adaptive thresholding for each cell.

  2. 3 mirror2image July 18, 2009 at 11:52

    They overlap. Threshold still jump from cell to cell, producing considerable amount of artifacts, but because I don’t need actual correct picture as output, only markers extracted that doesn’t bother me.

  3. 5 mirror2image July 18, 2009 at 12:06

    Works perfectly well, jump between cells in to big enough to screw marker shape. Thresholding artifacts never a problem. Sometimes, in especially bad lighting conditions adaptation is not strong enough and thresholding just is not extracting shape, or shape is deformed, problem just out of scope for adaptive thresholding. Edge detection could help here. But there is no sense to do edge detection for marker tracking. If one use edge detection one can go for markerless tracking as well.

  4. 7 makc3d October 30, 2009 at 04:01

    I thought I would add to this post this info: while 0.2 easing you see there was added to fight occasional flartoolkit hick-ups, it is slowing down adaptation in practice, and it is better to simply set random threshold instead.

  1. 1 Sandy FLARToolKit Starter Kit « Dorking around 3D in Flash Trackback on July 3, 2009 at 16:31
  2. 2 Weekly Shared Items – 6. July, 2009 | TOXIN LABS - weblog of a german design student from wuerzburg Trackback on July 6, 2009 at 06:12
  3. 3 transmote speaks… » FLARManager v0.5 (for FLARToolkit) Trackback on July 19, 2009 at 03:25
  4. 4 Meet qtrack « ¿noʎ ǝɹɐ ʍoɥ 'ʎǝɥ Trackback on December 29, 2010 at 21:06

Ask a Question

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Old stuff

July 2009
« Jun   Aug »

Oh, btw…


%d bloggers like this: