Packagecom.transmote.flar
Classpublic class FLARManager
InheritanceFLARManager Inheritance flash.events.EventDispatcher

Manager for computer vision applications using FLARToolkit ( http://www.libspark.org/wiki/saqoosha/FLARToolKit/en).

Basic usage is as follows: Pass a path to a camera parameters file and a list of FLARPatterns to the constructor. Optionally pass an IFLARSource to use as the source image for marker detection; FLARManager will by default create a FLARCameraSource that uses the first available camera. Alternatively, FLARManager can be initialized using an xml file that specifies the above and other settings.

Assign event listeners to FLARManager for MARKER_ADDED, MARKER_UPDATED, and MARKER_REMOVED FLARMarkerEvents. These FLARMarkerEvents encapsulate the FLARMarker instances that they refer to. Alternatively, it is possible to retrieve all active markers directly from FLARManager, via FLARManager.activeMarkers.

FLARMarkers are simple objects that contain information about detected markers provided by FLARToolkit. FLARManager maintains a list of active markers, and updates the list and the markers within every frame.

See also

marker/FLARMarkerEvent.html
source/FLARCameraSource.html
utils/FLARProxy.html


Public Properties
 PropertyDefined by
  activeMarkers : Vector
[read-only] Vector of all currently-active markers.
FLARManager
  adaptiveThresholding : Boolean
adaptive thresholding can result in better marker detection across a range of illumination.
FLARManager
  adaptiveThresholdingBias : Number
the direction toward which adaptive thresholding trends.
FLARManager
  adaptiveThresholdingSpeed : Number
the speed at which the threshold changes during adaptive thresholding.
FLARManager
  cameraParams : FLARParam
[read-only] FLARParam used by this FLARManager.
FLARManager
  flarSource : IFLARSource
[read-only] IFLARSource instance this FLARManager is using as the source image for marker detection.
FLARManager
  markerRemovalDelay : int
number of frames after removal that a marker will persist before dispatching a MARKER_REMOVED event.
FLARManager
  markerUpdateThreshold : Number
if a detected marker is within this distance (pixels) from an active marker, FLARManager considers the detected marker to be an update of the active marker.
FLARManager
  mirrorDisplay : Boolean
set to true to flip the camera image horizontally; this value is passed on to this.flarSource; note that if an IFLARSource is specified after mirrorDisplay is set, the 'mirrored' property of the new IFLARSource will overwrite this value.
FLARManager
  numLoadedPatterns : int
[read-only] the number of patterns loaded for detection.
FLARManager
  sampleBlurring : int
the amount of blur applied to the source image before sending to FLARToolkit for marker detection.
FLARManager
  smoother : IFLARMatrixSmoother
IFLARMatrixSmoother to use to apply smoothing to transformation matrices generated by FLARToolkit.
FLARManager
  smoothing : int
apply a smoothing algorithm to transformation matrices generated by FLARToolkit.
FLARManager
  threshold : int
pixels in source image with a brightness <= to this.threshold are candidates for marker outline detection.
FLARManager
  thresholdSourceDisplay : Boolean
display the source BitmapData used by FLARToolkit post-thresholding.
FLARManager
Public Methods
 MethodDefined by
  
FLARManager(flarConfigPath:String = "")
Constructor.
FLARManager
  
activate():Boolean
begin detecting markers once per frame.
FLARManager
  
deactivate():void
stop detecting markers.
FLARManager
  
initFromFile(flarConfigPath:String):void
load FLARManager configuration from an xml file.
FLARManager
  
initManual(cameraParamsPath:String, patterns:Vector, source:IFLARSource = null):void
the old-fashioned way to initialize FLARManager.
FLARManager
Property detail
activeMarkersproperty
activeMarkers:Vector  [read-only]

Vector of all currently-active markers.

Implementation
    public function get activeMarkers():Vector
adaptiveThresholdingproperty 
adaptiveThresholding:Boolean  [read-write]

adaptive thresholding 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. adaptive thresholding will begin at FLARManager.threshold, and vary according to FLARManager.adaptiveThresholdingStep. defaults to true. note that adaptive thresholding may cause slower performance in very dark environments. this happens because a low threshold creates an image with large black areas, and images with a lot of black can cause slowdown in FLARToolkit's labeling process (FLARLabeling_BitmapData.labeling()). in this case, adaptiveThresholding should be set to false. see the following URLs for more information: http://blog.jactionscripters.com/2009/05/18/adaptive-thresholding-experiment/comment-page-1/#comment-367 http://makc3d.wordpress.com/2009/07/03/alternative-to-adaptive-thresholding/

Implementation
    public function get adaptiveThresholding():Boolean
    public function set adaptiveThresholding(value:Boolean):void
adaptiveThresholdingBiasproperty 
adaptiveThresholdingBias:Number  [read-write]

the direction toward which adaptive thresholding trends. lower thresholds favor environments with too little light; higher thresholds favor environments with too much light. a value of -1 will adapt only toward a lower threshold. a value of +1 will adapt only toward a higher threshold. a value of 0 will adapt randomly in both directions, with no bias. the default is -0.1, as darker environments tend to be more common for viewing web applications than oversaturated environments.

Implementation
    public function get adaptiveThresholdingBias():Number
    public function set adaptiveThresholdingBias(value:Number):void
adaptiveThresholdingSpeedproperty 
adaptiveThresholdingSpeed:Number  [read-write]

the speed at which the threshold changes during adaptive thresholding. larger values may increase the speed at which the markers in uneven illumination are detected, but may also result in instability in marker detection. value must be zero or greater. the default is 0.3. a value of zero will disable adaptive thresholding.

Implementation
    public function get adaptiveThresholdingSpeed():Number
    public function set adaptiveThresholdingSpeed(value:Number):void
cameraParamsproperty 
cameraParams:FLARParam  [read-only]

FLARParam used by this FLARManager. can be used to instantiate a FLARCamera3D for use with Papervision.

Implementation
    public function get cameraParams():FLARParam
flarSourceproperty 
flarSource:IFLARSource  [read-only]

IFLARSource instance this FLARManager is using as the source image for marker detection.

Implementation
    public function get flarSource():IFLARSource
markerRemovalDelayproperty 
markerRemovalDelay:int  [read-write]

number of frames after removal that a marker will persist before dispatching a MARKER_REMOVED event. if a marker of the same pattern appears within markerUpdateThreshold pixels of the point of removal, before markerRemovalDelay frames have elapsed, the marker will be reinstated as if it was never removed. the default value is 1.

Implementation
    public function get markerRemovalDelay():int
    public function set markerRemovalDelay(value:int):void
markerUpdateThresholdproperty 
markerUpdateThreshold:Number  [read-write]

if a detected marker is within this distance (pixels) from an active marker, FLARManager considers the detected marker to be an update of the active marker. else, the detected marker is a new marker. increase this value to accommodate faster-moving markers; decrease it to accommodate more markers on-screen at once.

Implementation
    public function get markerUpdateThreshold():Number
    public function set markerUpdateThreshold(value:Number):void
mirrorDisplayproperty 
mirrorDisplay:Boolean  [read-write]

set to true to flip the camera image horizontally; this value is passed on to this.flarSource; note that if an IFLARSource is specified after mirrorDisplay is set, the 'mirrored' property of the new IFLARSource will overwrite this value.

Implementation
    public function get mirrorDisplay():Boolean
    public function set mirrorDisplay(value:Boolean):void
numLoadedPatternsproperty 
numLoadedPatterns:int  [read-only]

the number of patterns loaded for detection.

Implementation
    public function get numLoadedPatterns():int
sampleBlurringproperty 
sampleBlurring:int  [read-write]

the amount of blur applied to the source image before sending to FLARToolkit for marker detection. higher values increase framerate, but reduce detection accuracy. value must be zero or greater. the default value is 2.

Implementation
    public function get sampleBlurring():int
    public function set sampleBlurring(value:int):void
smootherproperty 
smoother:IFLARMatrixSmoother  [read-write]

IFLARMatrixSmoother to use to apply smoothing to transformation matrices generated by FLARToolkit.

Implementation
    public function get smoother():IFLARMatrixSmoother
    public function set smoother(value:IFLARMatrixSmoother):void
smoothingproperty 
smoothing:int  [read-write]

apply a smoothing algorithm to transformation matrices generated by FLARToolkit. smoothing is equal to the number of frames over which FLARManager will average transformation matrices; the larger the number, the smoother the animation, and the slower the response time between marker position/orientation changes. a value of 0 turns smoothing off.

Implementation
    public function get smoothing():int
    public function set smoothing(value:int):void
thresholdproperty 
threshold:int  [read-write]

pixels in source image with a brightness <= to this.threshold are candidates for marker outline detection. increase to increase likelihood of marker detection; increasing too high will cause engine to incorrectly detect non-existent markers. defaults to 80 (values can range from 0 to 255).

Implementation
    public function get threshold():int
    public function set threshold(value:int):void
thresholdSourceDisplayproperty 
thresholdSourceDisplay:Boolean  [read-write]

display the source BitmapData used by FLARToolkit post-thresholding. useful for debugging.

Implementation
    public function get thresholdSourceDisplay():Boolean
    public function set thresholdSourceDisplay(value:Boolean):void
Constructor detail
FLARManager()constructor
public function FLARManager(flarConfigPath:String = "")

Constructor. Initialize FLARManager by passing in a configuration file path.

Parameters
flarConfigPath:String (default = "") — path to the FLARManager configuration xml file.
Method detail
activate()method
public function activate():Boolean

begin detecting markers once per frame. this method is called automatically on initialization.

Returns
Boolean — false if FLARManager is not yet initialized; else true.
deactivate()method 
public function deactivate():void

stop detecting markers.

initFromFile()method 
public function initFromFile(flarConfigPath:String):void

load FLARManager configuration from an xml file. note, this method no longer needs to be called manually; simply passing the configuration file path into the constructor will also initialize correctly. this method is here for legacy support only.

Parameters
flarConfigPath:String — path to the FLARManager configuration xml file.
initManual()method 
public function initManual(cameraParamsPath:String, patterns:Vector, source:IFLARSource = null):void

the old-fashioned way to initialize FLARManager. the preferred method is to use an external xml configuration file, and to pass its path into the FLARManager constructor.

Parameters
cameraParamsPath:String — camera parameters filename.
 
patterns:Vector — list of FLARPatterns to detect.
 
source:IFLARSource (default = null) — IFLARSource instance to use as source image for marker detection. if null, FLARManager will create a camera capture source.