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
  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
  isActive : Boolean
true if this FLARManager instance is active and currently processing 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
  minimumLabelSize : Number
provides direct access to FLARLabeling_BitmapData.minimumLabelSize, which is the minimum size (widtheight) a dark area of the source image must be in order to become a candidate for marker outline detection.
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
  thresholdAdapter : IThresholdAdapter
IFLARThresholdAdapter used to automate threshold changes.
FLARManager
  thresholdSourceDisplay : Boolean
display the source BitmapData used by FLARToolkit post-thresholding.
FLARManager
  verbose : Boolean
if true, FLARManager will output configuration changes to the console.
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
  
dispose():void
halts all processes and frees this instance for garbage collection.
FLARManager
  
initFromFile(flarConfigPath:String):void
load FLARManager configuration from an xml file.
FLARManager
  
initFromXML(flarConfigXML:XML):void
init from an XML object in Flash.
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
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
isActiveproperty 
isActive:Boolean  [read-write]

true if this FLARManager instance is active and currently processing marker detection.

Implementation
    public function get isActive():Boolean
    public function set isActive(value:Boolean):void
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
minimumLabelSizeproperty 
minimumLabelSize:Number  [read-write]

provides direct access to FLARLabeling_BitmapData.minimumLabelSize, which is the minimum size (widtheight) a dark area of the source image must be in order to become a candidate for marker outline detection. higher values result in faster performance, but poorer marker detection at smaller sizes (as they appear on-screen). defaults to 100.

Implementation
    public function get minimumLabelSize():Number
    public function set minimumLabelSize(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
thresholdAdapterproperty 
thresholdAdapter:IThresholdAdapter  [read-write]

IFLARThresholdAdapter used to automate threshold changes. 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. 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, thresholdAdapter should be set to null. the default threshold adapter is DrunkWalkThresholdAdapter, but developers can implement their own algorithms for adaptive thresholding. to do so, implement the IThresholdAdapter interface.

Implementation
    public function get thresholdAdapter():IThresholdAdapter
    public function set thresholdAdapter(value:IThresholdAdapter):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
verboseproperty 
verbose:Boolean  [read-write]

if true, FLARManager will output configuration changes to the console.

Implementation
    public function get verbose():Boolean
    public function set verbose(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. removes all currently-active markers. enterframe loop continues, to update video.

dispose()method 
public function dispose():void

halts all processes and frees this instance for garbage collection.

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.
initFromXML()method 
public function initFromXML(flarConfigXML:XML):void

init from an XML object in Flash. this can be useful when dynamically generating an XML file at runtime, such as via a middleware request.

Parameters
flarConfigXML:XML
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.