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.
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.
what you do on cell borders?
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.
I cant see how does it work when marker is more than in one cell.
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.
I mean “jump between cells is not big enough “
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.