C++ Java Unity
C++ Reference
State Class Reference

Detailed Description

A persistent handle to the state of the whole augmented reality system at a given point in time.

A State can include:

  • Information about any objects or frames of reference that Vuforia is currently tracking (getTrackable() and getTrackableResult()).
  • The video frame for the state's point in time and camera calibration details (getFrame() and getCameraCalibration()).
  • Information about current illumination conditions (getIllumination()).

There are two different ways to obtain a State, depending on if you want to access data via a Pull or Push model:

  1. Via an instance of StateUpdater (Pull model)
  2. Via the UpdateCallback mechanism, Vuforia::registerCallback() (Push model)

Both push and pull models can be used simultaneously, if you like. For example, you would typically want to use the Pull interface as part of your render loop, but you may want to simultaneously use the Push interface for other parts of the system, such as if you need access to state information as early as possible in order to do any other custom computer vision in addition to Vuforia.

Note, however, that in an application where the camera, renderer, and main loop are all running on separate threads, care must be taken to ensure that a consistent State object is used across the whole application.

The data associated with a given State instance remains valid as long as the State instance is retained, acting like a smart pointer to the underlying data. Vuforia will continue to run in the background but the retained State instance will not be updated, and will therefore become increasingly out of date over time.

Note that the timestamp of the Frame returned by getFrame() may not match the timestamp on the various returned TrackableResults. See StateUpdater for more details.

Public Member Functions

 State ()
 Default constructor. More...
 
 State (const State &other)
 Copy constructor. More...
 
 ~State ()
 Destructor. More...
 
Stateoperator= (const State &other)
 Thread safe assignment operator. More...
 
Frame getFrame () const
 Get the Frame associated with this State. More...
 
const CameraCalibrationgetCameraCalibration () const
 Get the camera calibration for this State, if available. More...
 
const IlluminationgetIllumination () const
 Get illumination information for this State (if available). More...
 
const DeviceTrackableResultgetDeviceTrackableResult () const
 Get the DeviceTrackableResult, if it exists. More...
 
List< const TrackableResultgetTrackableResults () const
 

Protected Attributes

StateData * mData
 

Constructor & Destructor Documentation

State ( )

Default constructor.

State ( const State other)

Copy constructor.

A State is a lightweight object which keeps internal smart pointers to its data.

Copying is therefore cheap, and recommended over using references.

~State ( )

Destructor.

Member Function Documentation

State& operator= ( const State other)

Thread safe assignment operator.

A State is a lightweight object which keeps internal smart pointers to its data.

Copying is therefore cheap, and recommended over using references.

Frame getFrame ( ) const

Get the Frame associated with this State.

Returns
A Frame object representing the camera frame that any camera-based Trackable instances used to generate the TrackableResults accessible via getTrackableResult().
Note
For non-camera-based TrackableResult instances, the timestamp of this Frame may not match the timestamp of the TrackableResult. See StateUpdater for more details.
const CameraCalibration* getCameraCalibration ( ) const

Get the camera calibration for this State, if available.

Returns
Camara calibration information for this State, or NULL if no camera calibration was available when this State was captured.

The returned object is only valid as long as the State object is valid. Do not keep a copy of the pointer!

const Illumination* getIllumination ( ) const

Get illumination information for this State (if available).

Returns
An Illumination instance containing illumination information for this State, or NULL if no illumination information is available.

The returned object is only valid as long as the State object is valid. Do not keep a copy of the pointer!

const DeviceTrackableResult* getDeviceTrackableResult ( ) const

Get the DeviceTrackableResult, if it exists.

This is a convenience method that provides easy access to the DeviceTrackableResult, if a DeviceTracker has been started.

Note
The DeviceTrackableResult is also available via getTrackableResult().
The returned object is only valid as long as the State object is valid. Do not keep a copy of the pointer!
Returns
the DeviceTrackableResult, or NULL if no DeviceTracker is running.
List<const TrackableResult> getTrackableResults ( ) const

Provides access to the list of TrackableResults in the State referring to Trackable objects currently being tracked. The returned list is only valid as long as the State object is valid. Do not keep a copy of the list or the TrackableResults list elements point to!

Member Data Documentation

StateData* mData
protected