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

Manager for computer vision applications using object-tracking / augmented reality libraries like FLARToolkit and Flare/NFT.

Basic usage is as follows: Instantiate an IFLARTrackerManager to communicate with the tracking library of your choice. Pass it into the FLARManager constructor, along with a reference to the application Stage and the path to the xml configuration file (by default, flarConfig.xml). For more information about the xml configuration file, please see the online documentation.

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. Use FLARMarker's properties along with the appropriate matrix conversion methods in the com.transmote.flar.utils.geom package to transform display objects to align with detected markers.

FLARMarker instances contain information about objects detected by the selected tracking library. FLARManager maintains a list of active markers, and updates the list and the markers within every frame.

See also

com.transmote.flar.marker.FLARMarkerEvent
com.transmote.flar.source.FLARCameraSource
com.transmote.flar.source.FLARProxy


Public Properties
 PropertyDefined By
  activeMarkers : Vector.<FLARMarker>
[read-only] Vector of all currently-active markers.
FLARManager
  adaptiveSmoothingCenter : Number
Adaptive smoothing reduces jitter in marker transformation matrices for markers with little motion, while maintaining responsiveness for markers with fast motion.
FLARManager
  flarCameraSource : FLARCameraSource
[read-only] Reference to FLARCameraSource used in this application.
FLARManager
  flarSource : IFLARSource
[read-only] IFLARSource instance FLARManager is using as the source image for marker detection.
FLARManager
  inverted : Boolean
Set to true to detect inverted (white border) markers.
FLARManager
  isActive : Boolean
true if this FLARManager instance is active and currently performing marker detection.
FLARManager
  markerExtrapolation : Boolean
If true, FLARManager will extrapolate the position of a FLARMarker from its velocity when last detected.
FLARManager
  markerMode : int
FLARManager uses markerMode and patternMode to determine how to handle detected markers.
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.
FLARManager
  patternMode : int
FLARManager uses markerMode and patternMode to determine how to handle detected markers.
FLARManager
  sampleBlurring : int
The amount of blur applied to the source image before sending to tracker for image analysis / object detection.
FLARManager
  smoother : IFLARMatrixSmoother
IFLARMatrixSmoother to use to apply smoothing to transformation matrices generated by trackerManager.
FLARManager
  smoothing : int
Apply a smoothing algorithm to transformation matrices generated by trackerManager.
FLARManager
  threshold : int
Threshold applied to BitmapData before tracker analysis.
FLARManager
  thresholdAdapter : IThresholdAdapter
IFLARThresholdAdapter used to automate threshold changes.
FLARManager
  trackerId : String
[read-only] String id of layer of FLARManager that interfaces with the selected tracking library.
FLARManager
  trackerManager : IFLARTrackerManager
[read-only] The layer of FLARManager that interfaces with the selected tracking library.
FLARManager
  verbose : Boolean
If true, FLARManager will output configuration changes to the console.
FLARManager
  version : String
[read-only] Current version of FLARManager.
FLARManager
Public Methods
 MethodDefined By
  
FLARManager(flarConfig:*, trackerManager:IFLARTrackerManager, stage:Stage)
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
  
getProjectionMatrix(frameworkId:int, viewportSize:Rectangle):Matrix3D
Get tracker projection matrix.
FLARManager
Public Constants
 ConstantDefined By
  FRAMEWORK_ID_ALTERNATIVA : int = 2
[static]
FLARManager
  FRAMEWORK_ID_AWAY : int = 3
[static]
FLARManager
  FRAMEWORK_ID_AWAY_LITE : int = 4
[static]
FLARManager
  FRAMEWORK_ID_FLASH : int = 1
[static]
FLARManager
  FRAMEWORK_ID_PAPERVISION : int = 5
[static]
FLARManager
  FRAMEWORK_ID_SANDY : int = 6
[static]
FLARManager
  TRACKER_ID_FLARE : String = FlareManager
[static]
FLARManager
  TRACKER_ID_FLARE_NFT : String = FlareNFTManager
[static]
FLARManager
  TRACKER_ID_FLARTOOLKIT : String = FLARToolkitManager
[static]
FLARManager
  TRACKING_MODE_MULTI : int = 2
[static]
FLARManager
  TRACKING_MODE_SINGLE : int = 1
[static]
FLARManager
Property Detail
activeMarkersproperty
activeMarkers:Vector.<FLARMarker>  [read-only]

Vector of all currently-active markers.


Implementation
    public function get activeMarkers():Vector.<FLARMarker>
adaptiveSmoothingCenterproperty 
adaptiveSmoothingCenter:Number

Adaptive smoothing reduces jitter in marker transformation matrices for markers with little motion, while maintaining responsiveness for markers with fast motion.

adaptiveSmoothingCenter is the marker motion distance (between current and last frame) at which the actual applied smoothing is equal to FLARManager.smoothing.

When a marker has moved less than adaptiveSmoothingCenter, smoothing increases; When a marker has moved more than adaptiveSmoothingCenter, smoothing decreases.


Implementation
    public function get adaptiveSmoothingCenter():Number
    public function set adaptiveSmoothingCenter(value:Number):void
flarCameraSourceproperty 
flarCameraSource:FLARCameraSource  [read-only]

Reference to FLARCameraSource used in this application. If this application does not use a camera, returns null.


Implementation
    public function get flarCameraSource():FLARCameraSource
flarSourceproperty 
flarSource:IFLARSource  [read-only]

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


Implementation
    public function get flarSource():IFLARSource
invertedproperty 
inverted:Boolean

Set to true to detect inverted (white border) markers.

If inverted has not yet been set to true in this session, there will be a slight delay before inverted becomes true, while the inversion shader is loaded.

Thanks to Jim Alliban and Lee Brimelow for the inversion algorithm.


Implementation
    public function get inverted():Boolean
    public function set inverted(value:Boolean):void
isActiveproperty 
isActive:Boolean

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


Implementation
    public function get isActive():Boolean
    public function set isActive(value:Boolean):void
markerExtrapolationproperty 
markerExtrapolation:Boolean

If true, FLARManager will extrapolate the position of a FLARMarker from its velocity when last detected.

Extrapolation continues until markerRemovalDelay frames after trackerManager reports a marker removed.

Enabling markerExtrapolation can sometimes improve tracking during fast marker motion.


Implementation
    public function get markerExtrapolation():Boolean
    public function set markerExtrapolation(value:Boolean):void
markerModeproperty 
markerMode:int

FLARManager uses markerMode and patternMode to determine how to handle detected markers. Acceptable values are FLARManager.TRACKING_MODE_SINGLE and FLARManager.TRACKING_MODE_MULTI.

The table below describes the effects of different settings for markerMode and patternMode.

markerModepatternModeEffect
MULTIMULTI'True' multi-marker mode. Tracks any number of markers of any pattern at once.
MULTISINGLETracks any number of markers, but ignores the pattern. Note that FLARToolkit will still track only the patterns specified in flarConfig.xml.
SINGLEMULTI(default) Tracks only one marker for each pattern. If multiple markers of a given pattern are visible simultaneously, only one will be tracked.
SINGLESINGLE'True' single-marker mode. If multiple markers of any pattern are visible simultaneously, only one will be tracked. Note that FLARToolkit will still track only the patterns specified in flarConfig.xml.


Implementation
    public function get markerMode():int
    public function set markerMode(value:int):void
markerRemovalDelayproperty 
markerRemovalDelay:int

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

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

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
patternModeproperty 
patternMode:int

FLARManager uses markerMode and patternMode to determine how to handle detected markers. Acceptable values are FLARManager.TRACKING_MODE_SINGLE and FLARManager.TRACKING_MODE_MULTI.


Implementation
    public function get patternMode():int
    public function set patternMode(value:int):void

See also

sampleBlurringproperty 
sampleBlurring:int

The amount of blur applied to the source image before sending to tracker for image analysis / object detection. Higher values may increase framerate, but may also 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

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


Implementation
    public function get smoother():IFLARMatrixSmoother
    public function set smoother(value:IFLARMatrixSmoother):void
smoothingproperty 
smoothing:int

Apply a smoothing algorithm to transformation matrices generated by trackerManager.

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

Threshold applied to BitmapData before tracker analysis. Pixels in source image with a brightness <= to this.threshold are candidates for marker outline detection. 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

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 when using FLARToolkit, 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 DrunkHistogramThresholdAdapter, 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
trackerIdproperty 
trackerId:String  [read-only]

String id of layer of FLARManager that interfaces with the selected tracking library.


Implementation
    public function get trackerId():String
trackerManagerproperty 
trackerManager:IFLARTrackerManager  [read-only]

The layer of FLARManager that interfaces with the selected tracking library. Exposed here to grant developers access to more control over tracker library parameters.


Implementation
    public function get trackerManager():IFLARTrackerManager
verboseproperty 
verbose:Boolean

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


Implementation
    public function get verbose():Boolean
    public function set verbose(value:Boolean):void
versionproperty 
version:String  [read-only]

Current version of FLARManager.


Implementation
    public function get version():String
Constructor Detail
FLARManager()Constructor
public function FLARManager(flarConfig:*, trackerManager:IFLARTrackerManager, stage:Stage)

Constructor.

Dispatches the following events: Event.COMPLETE: when the configuration xml is loaded and parsed. Event.INIT: when the trackerManager has initialized and FLARManager begins detecting markers. ErrorEvent.ERROR: in the case that configuration loading or parsing fails. ErrorEvent.ERROR: in the case that camera initialization fails.

Parameters
flarConfig:* — Pass the path to the FLARManager configuration xml file as a String to load the file; or pass an XML instance to configure FLARManager directly. For more information about the xml configuration file, please see the online documentation.
 
trackerManager:IFLARTrackerManager — An IFLARTrackerManager instance that communicates with a tracking library. The IFLARTrackerManager selected specifies the tracking library that will be used.
 
stage:Stage — Reference to Stage. Required by some trackers.
Method Detail
activate()method
public function activate():Boolean

Begin detecting markers once per frame. This method is called automatically on initialization.

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

Stop detecting markers. Removes all currently-active markers. ENTER_FRAME loop continues, to update video.

dispose()method 
public function dispose():void

Halts all processes and frees this instance for garbage collection.

getProjectionMatrix()method 
public function getProjectionMatrix(frameworkId:int, viewportSize:Rectangle):Matrix3D

Get tracker projection matrix. Used to init cameras for 3D frameworks.

Parameters

frameworkId:int — ID of the selected 3D framework, enumerated in FLARManager.
 
viewportSize:Rectangle — Rectangle that describes bounds of 3D viewport.

Returns
Matrix3D
Constant Detail
FRAMEWORK_ID_ALTERNATIVAConstant
public static const FRAMEWORK_ID_ALTERNATIVA:int = 2

FRAMEWORK_ID_AWAYConstant 
public static const FRAMEWORK_ID_AWAY:int = 3

FRAMEWORK_ID_AWAY_LITEConstant 
public static const FRAMEWORK_ID_AWAY_LITE:int = 4

FRAMEWORK_ID_FLASHConstant 
public static const FRAMEWORK_ID_FLASH:int = 1

FRAMEWORK_ID_PAPERVISIONConstant 
public static const FRAMEWORK_ID_PAPERVISION:int = 5

FRAMEWORK_ID_SANDYConstant 
public static const FRAMEWORK_ID_SANDY:int = 6

TRACKER_ID_FLAREConstant 
public static const TRACKER_ID_FLARE:String = FlareManager

TRACKER_ID_FLARE_NFTConstant 
public static const TRACKER_ID_FLARE_NFT:String = FlareNFTManager

TRACKER_ID_FLARTOOLKITConstant 
public static const TRACKER_ID_FLARTOOLKIT:String = FLARToolkitManager

TRACKING_MODE_MULTIConstant 
public static const TRACKING_MODE_MULTI:int = 2

TRACKING_MODE_SINGLEConstant 
public static const TRACKING_MODE_SINGLE:int = 1