transmote speaks…

design + art + code
  • portfolio
  • rss
  • Home
  • About
  • FLARManager: Augmented Reality in Flash
    • FLARManager intro
    • FLARManager documentation
    • FLARManager – donate
    • Inside FLARManager
      • Inside FLARManager: Getting Started
      • Inside FLARManager: 2D Marker Tracking
      • Inside FLARManager: Basic Augmented Reality
      • Inside FLARManager: Loading Collada Models
      • Inside FLARManager: Tracking Engines
      • Inside FLARManager: Customization
      • Inside FLARManager: FLARManager Miscellany
  • Contact

Inside FLARManager: Customization

<– Tracking Engines | FLARManager Miscellany –>
 
You’ve made little cubes, you’ve made sophisticated collada models, and you want to get more out of your tracking library. More fine-tuning, more control. FLARManager offers it in spades.

Read on to learn how to fully customize FLARManager to work exactly how you want it to, for your custom flash augmented reality applications.

 

Creating custom markers (FLARToolkit)

Many people have been asking about best practices for customizing FLARToolkit markers. I think squidder pretty much nailed it with this post, but i’ll provide a quick digest below.

Start with tarotaro’s most excellent online marker generator. This tool allows you to either capture printed patterns with your camera or load them from image files. Loading from a non-lossy format (like PNG or GIF) is the best option, and will give the cleanest results. I highly recommend loading an image file, rather capturing from a camera.

Make sure you select the proper resolution for your pattern. This refers to the resolution of the pattern image, and has nothing to do with the physical size of the marker. Lower pattern resolutions result in faster and more accurate marker detection. I don’t recommend you go above 16×16; performance degrades noticeably above that. FLARManager’s examples and tutorials use 8×8 patterns — I found this to be the best balance of pattern variety and appearance with performance and reliability of marker detection. Specify your chosen resolution via the ‘Marker segments’ dropdown in the marker generator.

Once you’ve created your pattern files and chosen your resolution, you need to add your new pattern file to FLARManager’s external configuration xml file (named flarConfig.xml by default). In the <trackerSettings><flarToolkitSettings><patterns> element, enter the pattern resolution as the resolution attribute. Note that *all* of the patterns specified in flarConfig.xml must have the same resolution. This is a restriction imposed by FLARToolkit. If any of the patterns are not of the same resolution as the others, FLARToolkit will throw a runtime error.

There is also a thread on the FLARToolkit forums that goes a bit more in-depth into the process of creating custom markers here.

 

Creating a custom smoother

FLARManager applies smoothing to the transformation matrices generated by the tracker, in order to ease jitter and even out jerkiness in marker motion. Smoothing is executed, by default, by FLARMatrixSmoother_Average, but developers can implement their own smoothing algorithms.

To create a custom smoothing algorithm, create a new class that implements IFLARMatrixSmoother. The interface requires three methods:

  • initFromXML accepts an object containing name-value pairs used for initialization. This method is required, but implementation can be left empty.
  • smoothMatrices is the workhorse of any custom smoothing algorithm; it is called every time a marker updates its position.
  • dispose frees the algorithm instance for garbage collection, so that a FLARManager instance can be properly disposed.

To implement a custom smoothing algorithm, create an instance of the custom smoothing class, and store it as FLARManager.smoother.

Alternatively, add a <flarManagerSettings><smoother> element to your configuration xml file. Specify the name of the new class as a className attribute of this node. (If the class resides somewhere other than com.transmote.flar.utils.smoother, a fully-qualified class name must be used.) Specify name-value pairs to be sent to initFromXML as attributes of this node. For example, FLARManager’s default setup is equivalent to adding:
<smoother className='FLARMatrixSmoother_Average'>
to the configuration xml file.

NOTE: if you choose to specify a custom smoother class via the configuration xml file, you must create a reference to the class somewhere in your project, to ensure that it is compiled in your SWF. Otherwise, instantiation will fail. For example, add:
MyCustomSmoother;
anywhere in your code.

 

Creating a custom threshold adapter

FLARManager employs an algorithm to automatically change the threshold value applied by FLARToolkit as the first step in analyzing the camera image every frame. This is called “adaptive thresholding”, and can result in better marker detection across a range of illumination. This is desirable for applications with low lighting, or in which the developer has little control over lighting conditions, such as with web applications. By default, FLARManager uses DrunkHistogramThresholdAdapter, but developers can implement their own adaptive thresholding algorithms.

NOTE: flare*tracker and flare*NFT perform adaptive thresholding internally, and the thresholdAdapter is disabled when using these tracking libraries.

To create a custom adaptive thresholding algorithm, create a new class that implements IThresholdAdapter. The interface requires five methods:

  • initFromXML accepts an object containing name-value pairs used for initialization. this method is required, but implementation can be left empty.
  • calculateThreshold is the workhorse of any custom adaptive thresholding algorithm. It can either calculate a new threshold to pass into the tracker, or apply thresholding directly to the BitmapData source instead of allowing the tracker to do so. If it directly modifies the source, this method should return -1 to signal the tracker to skip its internal thresholding.
  • resetCalculations is called when marker confidence levels increase (e.g. when a new marker is detected).
  • runsEveryFrame determines the frequency at which calculateThreshold will be called.
  • dispose frees the algorithm instance for garbage collection, so that a FLARManager instance can be properly disposed.

To implement a custom adaptive thresholding algorithm, create an instance of the custom adaptive thresholding class, and store it as FLARManager.thresholdAdapter. Alternatively, add a <flarManagerSettings><thresholdAdapter> element to your configuration xml file. Specify the name of the new class as a className attribute of this element. (If the class resides somewhere other than com.transmote.flar.utils.threshold, a fully-qualified class name must be used.) Specify name-value pairs to be sent to initFromXML as attributes of this node. For example, FLARManager’s default setup is equivalent to adding:
<thresholdAdapter className='DrunkHistogramThresholdAdapter'>
to the configuration xml file.

Note that if you choose to specify a custom threshold adapter class via the configuration xml file, you must create a reference to the class somewhere in your project, to ensure that it is compiled in your SWF. Otherwise, instantiation will fail. For example, add:
MyCustomThresholdAdapter;
anywhere in your code.

 
 
<– Tracking Engines | FLARManager Miscellany –>



Comments rss
Comments rss

17 responses

[...] Inside FLARManager: Customization [...]

FLARManager v0.6 (augmented reality in Flash) | transmote speaks... | 2009/09/23 | 2:04 am

[...] Inside FLARManager: Customization [...]

[...] the FLAR Manager instructions on customization or the

Histogram Based Bias for FLARM Auto Threshold Class « M@ Blog | 2009/10/08 | 2:00 pm

[...] the FLAR Manager instructions on customization or the alternative process outlined in my prior [...]

Hi Eric, I'm doing some tests with the flar manager but

am | 2010/03/01 | 5:16 am

Hi Eric,

I’m doing some tests with the flar manager but I notice that the app wasn’t snapping to the marker. After setting the debugging flarManager.thresholdSourceDisplay = true I noticed that the threshold is constantly flickering. I guess this have to do with the automatic threshold, can you detail a little more how could I tweak the values so the adjustment is smother? I’ve tried to set the speed from 0.1 till 2, but it didn’t get better. I find this flickering really weird don’t know if it have something to do with my webcam (imac 8.1).

Thanks,
am

@am -- yes, the threshold continuously changes while no marker

ericsoco | 2010/03/01 | 12:20 pm

@am — yes, the threshold continuously changes while no marker is detected. once a marker is detected, threshold adapting pauses. the intent is to vary the threshold until marker detection, at which point it is a relatively safe assumption that the threshold is at a good level for detection.

re: “the app wasn’t snapping to the marker”, do you mean your object was not appearing at the location of the detected marker? it should be. there are a number of potential problems with your setup, but without more information it’s hard to diagnose.

Eric, Thanks for the reply. I figure out that I had

am | 2010/03/02 | 10:35 am

Eric,
Thanks for the reply. I figure out that I had too much light in the room, notice that once the app was working better in the end of the day, when the sun goes down. How could I change the settings so the threshold gives more “black”?

@am -- you can change values in DrunkHistogramThresholdAdapter.calculateBias() if you

ericsoco | 2010/03/02 | 2:24 pm

@am — you can change values in DrunkHistogramThresholdAdapter.calculateBias() if you want the thresholding to lean more towards darkness.

I would like to position the web cam on the

thirdrow | 2010/03/29 | 9:41 pm

I would like to position the web cam on the stage, but for the life of me can’t figure it out. I’ve tried just about every variation I can think off, but keep getting “1119: Access of possibly undefined property x through a reference with static type com.transmote.flar:FLARManager.

@thirdrow -- FLARManager does not extend DisplayObject. you want

ericsoco | 2010/03/29 | 10:12 pm

@thirdrow — FLARManager does not extend DisplayObject. you want to use flarManager.flarSource instead. be sure you also set the position of the container of your objects drawn over the markers (e.g. your papervision Scene3D) accordingly.

so....based on Lee's tutorial for FLARManager, he adds the FLARManager,

thirdrow | 2010/03/30 | 6:25 am

so….based on Lee’s tutorial for FLARManager, he adds the FLARManager, under the initFLAR function and then adds the child to a Sprite object – I’ve tried:
fm.flarSource, Sprite.fm.flarSource, flarSource, and flarManager.flarSource with the .x=10; and as you know, none of that works.

I am totally new to this stuff, having never worked in Flex or even AS to this level, but I’ve managed to get this working where I’m just using the markers as a trigger to play videos that I’m adding onto the stage (think tour videos of college labs based on whether they are new or returning students) so I’m not adding any 3D objects as of yet.

Thank you for your response – this is really important work that you are doing.

Marker detection problems: I have a set of markers which get

Ram | 2010/11/11 | 3:25 am

Marker detection problems:
I have a set of markers which get detected fine and the models appear over it but at times when I bring my hand or other objects into the camera’s field of view, the models seem to appear in a disoriented fashion..( which should not be the case ).. Has anyone faced such an issue…. My custom marker has curved shapes in it…( probably that could be the reason..

Could anyone point me to marker design guidelines… ( I have seen the custom marker creation guidelines in this site but it does not talk about the design aspect )

Thanks,
Ram

We are doing an installation... and we need to convert

blue | 2011/03/24 | 1:46 pm

We are doing an installation… and we need to convert 5000 FLAR png files to .pat format. Is there any other way to do this other than tarotaro’s online generator? Any help would be greatly appreciated.

@blue -- i don't know a better way, but you

ericsoco | 2011/03/25 | 2:39 pm

@blue — i don’t know a better way, but you could write your own program to generate .pat files from .png files, wouldn’t be that difficult.
is this 5000 patterns for one FLARManager/Toolkit application? if so, you’re going to run into trouble; FLARToolkit won’t be able to handle that many markers.

Hi Eric! First of all - thanks for you fantastic effort

Emil | 2011/03/29 | 1:36 am

Hi Eric!

First of all – thanks for you fantastic effort in the AR community!

I have a question. I’m running a Flar Manager AR app in a pretty bright room. How exactly do I change the value in DrunkHistogramThresholdAdapter.calculateBias() so it better suits my needs? I’m looking at the function in DrunkHistogramThresholdAdapter.as but don’t know which values to tweak. Or am I looking in the wrong place?

Many thanx!

@Emil -- DHTA calculates bias on its own, based on

ericsoco | 2011/03/29 | 3:15 pm

@Emil — DHTA calculates bias on its own, based on the current histogram of the video feed. DrunkWalkThresholdAdapter allows you to manually set the bias; if you want to do that, use DWTA instead of DHTA.

Hi Eric, Thanks for the reply. Yes, we are planning to

blue | 2011/04/03 | 8:49 pm

Hi Eric,

Thanks for the reply. Yes, we are planning to use all 5000 in one application. We have since lowered it down to 1500. Will this still be an issue? Also, I was examining your flar markers and your pat files. Your pat files only contains the numbers 0 and 255. I think this is the reason it reads so well when using it. Question is, how did you generate your png’s? I tried using illustrator but it is still not as crisp as yours.

@blue -- i have more to say on this thread,

ericsoco | 2011/04/04 | 9:24 am

@blue — i have more to say on this thread, but might be best to continue this conversation on the FLARManager forum. i’m trying to phase out my blog as a place for q&a, it’s just too messy.

please repost the thread to-date there and i’ll follow up.

hi, can I ask something about on how to compile the

alvin | 2011/09/19 | 5:20 pm

hi,

can I ask something about on how to compile the tarotaro’s marker generator?

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Additional comments powered by BackType

Recent Posts

  • Nest 0.2 – Scenegraph and Event Model for Processing/Java
  • ‘flip’ on the Great Wall
  • FLARManager v1.1 – Augmented Reality in Flash
  • pecha kucha, 2011.01.11
  • Alternativa3D version 7 support, ARToolworks forum

Tags

3d actionscript Add new tag AR as3 augmented reality camera Capabilities clibinit computer vision digital elastic event handler exhibit exploratorium fiducial flar flare flarmanager flartoolkit flash flash player forum garbage collection generative grid interactive Keyboard marker memory mesh mirror natural feature tracking NFT notes papervision presentation reflection slides sputnik to see tracking video video mirror webcam


If FLARManager has helped you out, please help FLARManager!







Serious ADHD Likely!
rss Comments rss design by jide