C++ Java Unity
C++ Reference
MultiTarget Class Referenceabstract

Detailed Description

A type of ObjectTarget that represents an object constructed from multiple component Trackables.

A MultiTarget is useful when you want to construct a Trackable using multiple component Trackables arranged in a fixed spatial relationship to each other.

To build a MultiTarget, you typically initialize and load a DataSet containing the Trackables you want to combine (usually ImageTargets), then call DataSet::createMultiTarget() to get a new MultiTarget object. Loop through the Trackables using DataSet::getTrackable() and add them to the new MultiTarget using addPart(), calling setPartOffset() to define the offset (position and rotation) for each added Trackable.

For example, suppose you want to be able to recognise and track a cereal box. You also want to be able to initialize the tracking from both sides of the box - it shouldn't matter if the front or the back of the box is facing the user, your application should be able to recognise and track both sides.

You would need to start by building two ImageTargets, one to track the front side of the box, and another to track the back side. Normally, you would need to track both of the ImageTargets separately in your application. But if you build a MultiTarget and use addPart() and setPartOffset() to define a spatial relationship between the two targets that matches the spatial relationship of the front and back sides of your real-world cereal box, Vuforia takes care of tracking both of the ImageTargets as one, and returns TrackableResults as though you had just a single Trackable.

Note
It is not possible to modify a MultiTarget while its DataSet is active. See the DataSet class for more information.
Inheritance diagram for MultiTarget:
ObjectTarget Trackable NonCopyable

Public Member Functions

virtual List< TrackablegetParts ()=0
 Returns the list of Trackables that form the MultiTarget. More...
 
virtual List< const TrackablegetParts () const =0
 Provides read-only access to the list of Trackables that form the MultiTarget. More...
 
virtual TrackablegetPart (const char *name)=0
 Get a Trackable part by name. More...
 
virtual const TrackablegetPart (const char *name) const =0
 Get a Trackable part by name. More...
 
virtual int addPart (Trackable *trackable)=0
 Add a Trackable part to this MultiTarget. More...
 
virtual bool removePart (int idx)=0
 Remove a Trackable part from this MultiTarget. More...
 
virtual bool setPartOffset (int idx, const Matrix34F &offset)=0
 Set the offset transform of a part, relative to the MultiTarget's origin. More...
 
virtual bool getPartOffset (int idx, Matrix34F &offset) const =0
 Get the offset transform of a part, relative to the MultiTarget's origin. More...
 
- Public Member Functions inherited from ObjectTarget
virtual const char * getUniqueTargetId () const =0
 Get the persistent system-wide unique id for this target. More...
 
virtual Vec3F getSize () const =0
 Get the size of this target. More...
 
virtual bool setSize (const Vec3F &size)=0
 Apply a uniform scale to this target that makes it the given size. More...
 
virtual bool setMotionHint (MOTION_HINT hint)=0
 Set the motion hint to indicate how the target moves in space. More...
 
virtual MOTION_HINT getMotionHint () const =0
 Get the motion hint of this target. More...
 
- Public Member Functions inherited from Trackable
virtual Type getType () const =0
 Get the Type for this instance (typically a subclass of Trackable). More...
 
virtual bool isOfType (Type type) const =0
 Check whether this instance is of the given Type or any of its subclasses. More...
 
virtual int getId () const =0
 Get a unique id for this Trackable. More...
 
virtual const char * getName () const =0
 Get the name of this Trackable's name. More...
 
virtual bool setUserData (void *userData)=0
 Set user data for this Trackable. More...
 
virtual void * getUserData () const =0
 Get the user data that was previously set using setUserData(). More...
 
virtual ~Trackable ()
 

Static Public Member Functions

static Type getClassType ()
 Get the Type for class "MultiTarget". More...
 
- Static Public Member Functions inherited from ObjectTarget
static Type getClassType ()
 Get the Type for class "ObjectTarget". More...
 
- Static Public Member Functions inherited from Trackable
static Type getClassType ()
 Get the Type of class 'Trackable'. More...
 

Additional Inherited Members

- Public Types inherited from ObjectTarget
enum  MOTION_HINT {
  STATIC,
  ADAPTIVE
}
 Target property that indicates how the target moves in space. More...
 

Member Function Documentation

static Type getClassType ( )
static

Get the Type for class "MultiTarget".

virtual List<Trackable> getParts ( )
pure virtual

Returns the list of Trackables that form the MultiTarget.

virtual List<const Trackable> getParts ( ) const
pure virtual

Provides read-only access to the list of Trackables that form the MultiTarget.

virtual Trackable* getPart ( const char *  name)
pure virtual

Get a Trackable part by name.

Parameters
nameThe name of the part to get.
Returns
The requested part, or NULL of none of the parts of this MultiTarget have the given name.
virtual const Trackable* getPart ( const char *  name) const
pure virtual

Get a Trackable part by name.

Parameters
nameThe name of the part to get.
Returns
The requested part, or NULL of none of the parts of this MultiTarget have the given name.
virtual int addPart ( Trackable trackable)
pure virtual

Add a Trackable part to this MultiTarget.

The newly-added part defaults to having zero offset (no translation, no rotation). Use the returned index with setPartOffset() to set an offset transform for the new part.

This method will fail if the given Trackable has already been added to this MultiTarget, or if the DataSet that owns this MultiTarget is currently active.

Parameters
trackableThe part to add. It must exist on the DataSet that owns this MultiTarget.
Returns
The index of the newly added part, or -1 on failure.
virtual bool removePart ( int  idx)
pure virtual

Remove a Trackable part from this MultiTarget.

Parameters
idxThe index of the part to remove, in the range 0..getNumParts()-1.
Returns
true on success, or false if the requested index is out of range or if the DataSet that owns this MultiTarget is currently active.
virtual bool setPartOffset ( int  idx,
const Matrix34F offset 
)
pure virtual

Set the offset transform of a part, relative to the MultiTarget's origin.

If a part has zero offset (i.e. no rotation and no translation, represented by an identity rotation matrix with (0,0,0) translation), the pose of the part will be identical to the pose of the MultiTarget.

By default, parts newly-added via addPart() have zero offset.

If multiple parts share the same offset, the parts will be co-located.

Parameters
idxThe index of the part, in the range 0..getNumParts()-1.
offsetThe pose of the part, relative to the MultiTarget's origin.
Returns
true on success, or false if the index is invalid or if the DataSet that owns this MultiTarget is currently active.
virtual bool getPartOffset ( int  idx,
Matrix34F offset 
) const
pure virtual

Get the offset transform of a part, relative to the MultiTarget's origin.

Parameters
idxThe index of the part, in the range 0..getNumParts()-1.
offsetWill be populated with the pose of the part (relative to the MultiTarget's origin) when this method returns.
Returns
true on success, or false if the requested index is out of range.