KudanCV
KudanImageTrackable Class Reference

#include <KudanCV.h>

Public Member Functions

 KudanImageTrackable (std::shared_ptr< Private >)
 
bool isTrackingReliable ()
 
int isRecovered ()
 
bool isTracked ()
 
KudanVector3 getPosition ()
 
KudanQuaternion getOrientation ()
 
int getNumTrackedPoints ()
 
std::vector< KudanVector2getTrackedPoints ()
 
std::vector< KudanVector2getTrackedCorners ()
 
std::string getName ()
 
void setName (std::string name)
 
float getWidth ()
 
float getHeight ()
 
void setWidth (float width)
 
void setHeight (float height)
 
bool setSize (float width, float height)
 
void setScale (float scale)
 
void allowRecoveryMode ()
 
void forceRecoveryMode ()
 
void prohibitRecoveryMode ()
 
bool queryRecoveryMode (bool globalSetting)
 

Static Public Member Functions

static std::shared_ptr< KudanImageTrackablecreateFromImageFile (std::string path, std::string name="")
 
static std::shared_ptr< KudanImageTrackablecreateFromFilePointer (FILE *filePointer)
 
static std::shared_ptr< KudanImageTrackablecreateFromImageData (const unsigned char *imageData, std::string name, int width, int height, int channels, int padding)
 

Friends

class KudanImageTracker
 

Detailed Description

An image which can be tracked. An Image Trackable is a representation of an image which can be detected and tracked by the KudanImageTracker. It stores a representation of the 2D image suitable for tracking, with various other settings (such as its size in pixels). The class will also represent the pose of the tracked image with respect to the camera when tracking is successful, plus other state.

Constructor & Destructor Documentation

KudanImageTrackable ( std::shared_ptr< Private >  )

This is the only constructor, which cannot be used (because it needs Private data access). Create a KudanImageTrackable using the createFromImageFile (etc) static methods

Member Function Documentation

void allowRecoveryMode ( )

Turn on recovery mode for this Trackable, if enabled. This Trackable can use recover mode if the global setting is switched on (default to global setting). This makes re-detection of previously seen Trackables quicker and possible from a greater range of angles.

static std::shared_ptr<KudanImageTrackable> createFromFilePointer ( FILE *  filePointer)
static

Create a new Trackable directly from a file. This is for loading data processed by the Kudan Toolkit in the .KARMarker format, not for reading image files.

Parameters
filePointerA file pointer refering to a .KARMarker file, created with the Kudan Toolkit.
Returns
On success a pointer to the new KudanImageTrackable; a nullptr on fail
static std::shared_ptr<KudanImageTrackable> createFromImageData ( const unsigned char *  imageData,
std::string  name,
int  width,
int  height,
int  channels,
int  padding 
)
static

Create a new Trackable from image data. These data should be in the form of a pointer to an unsigned character array. The format of the data must match the specified size and number of channels, otherwise this can cause errors which won't be detected. If Kudan is being used with OpenCV this is easily used with a cv::Mat: createFromImageData(mat.data, "name", mat.size().width, mat.size().height, mat.channels(), 0); In general the image data should be ordered such that the channel c pixel at (x,y) is at position [(width * y + x)*channels + c] (in the same manner as OpenCV)

Parameters
imageDataPointer to the actual image data
nameName of this Trackable
width,height,channels,paddingParameters of the image data
Returns
On success a pointer to the new KudanImageTrackable; a nullptr on fail
Exceptions
KudanExceptionis thrown if the data pointer is null or if a wrong number of channels is given
static std::shared_ptr<KudanImageTrackable> createFromImageFile ( std::string  path,
std::string  name = "" 
)
static

Create a new Trackable from an image file. The image is loaded from the specified path, if it exists, and processed to create a Trackable object.

Parameters
pathLocation of th eimage file (jpeg or png)
nameName of this Trackable (optional). If not given, the name is derived from the path
Returns
On success a pointer to the new KudanImageTrackable; a nullptr on fail
Exceptions
KudanExceptionis thrown if the image cannot be read or is empty.
void forceRecoveryMode ( )

Turn on recovery mode for this Trackable. This Trackable will have recovery mode emabled irrespective of the global setting.

float getHeight ( )

Get the size of the Trackable image with respect to 3D units along its local Y axis. If the size has been set, this affects the height returned.

Returns
The height of the trackable
std::string getName ( )

Get the name of this Trackable.

Returns
A string representing the name of this trackable
int getNumTrackedPoints ( )

Return the number of points used to track this Trackable and estimate its pose. This can be used as a crude way of evaluating how well this Trackable is tracked.

Returns
int A number, representing the number of tracked points.
KudanQuaternion getOrientation ( )

Get the 6dof pose of the image Trackable, with respect to the camera. This represents the orientation of the image about its own centre, as a unit quaternion

Returns
a KudanQuaternion which represents a 4D quaternion (x, y, z, w)
KudanVector3 getPosition ( )

Get the 6dof pose of the image Trackable, with respect to the camera. This represents the position of the centre of the image in 3D in the camera coordinate frame.

Returns
A KudanVector3 which represents a 3D point (x, y, z)
std::vector<KudanVector2> getTrackedCorners ( )

Get a vector of exaclty 4 (or if tracking is not running, zero) points, which are the corners of the tracked region in the camera image

Returns
A vector of 0 or 4 KudanPoints, describing the corners of a quadrilateral in the image
std::vector<KudanVector2> getTrackedPoints ( )

Get a vector of 2D points representing the locations of points on the camera image used for tracking this Trackable. This will have length equivalent to getNumTrackedPoints()

Returns
A vector of KudanPoints, describing points on the current camera image
float getWidth ( )

Get the size of the Trackable image with respect to 3D units along its local X axis. If the size has been set, this affects the width returned.

Returns
The width of the trackable
int isRecovered ( )

Query whether the current tracking state was achieved through recovery-based detection (related to the recovery mode). This returns 0 if detection happened in the usual way, and nonzero if recovery was used (1 indicates recovery re-detection, 2 indicates instant recovery while tracking)

Returns
An integer representing whether recovery was used (1, 2) or not (0)
bool isTracked ( )

Is this Trackable currently detectd by the image tracker? This is equivalent to asking whether this Trackable will be in the detected Trackables list

Returns
A boolean indicating whether this Trackable was successfully tracked in the most recent process frame.
bool isTrackingReliable ( )

Query whether tracking of this Trackable is currently deemed reliable.

Returns
True is tracking is happening in the normal way, false if tracking is not able to use the full matching method
void prohibitRecoveryMode ( )

Switch off recovery mode for this Trackable. This prevents this Trackable from using recovery mode, irrespective of the global setting.

bool queryRecoveryMode ( bool  globalSetting)

Query recovery mode for this Trackable. This could depend on the global setting, depending how it was set.

Parameters
globalSettingSpecifies whether recovery mode is allowed in the tracker
Returns
true if recovery mode is enabled for this Trackable, given the Trackable's setting and the global state; otherwise false.
void setHeight ( float  height)

Set the value which represents the height of this trackable (in the units / reference frame of your choice) This sets what size the trackable will have in the 3D coordinate frame in which its pose is represented. It does not affect tracking.

Parameters
heightThe height of the trackable in some units
void setName ( std::string  name)

Set the name on this Trackable. This is stored in the unerlying tracker state and is used to find the correct data (be careful with duplicates)

Parameters
nameThe name which will be assigned to this trackable
void setScale ( float  scale)

Set the scale at which this trackale is represented in the 3D coordinate system. This does not change internal state, and is equivalent to calling setSize. Using setScale(1) will mean the trackable's size is represented in pixel units of the actual trackable image

Parameters
scaleScale factor relating the trackable image size to the apparent size in 3D
bool setSize ( float  width,
float  height 
)

Set the Trackable's size. This might change some graphics but will not change the underlying image or tracking behaviour. It should be used to specify dimensions which make sense for the given Trackable (e.g. real world scale). This will not allow you to change the aspect ratio! Set only to consistent multiplies of the current size (altering the width or height independently does not make sense - this is really a scale factor)

Parameters
width,heightThe dimensions of the Trackable image. These can be in any units, but should always have the same aspect ratio as the actual image.
Exceptions
KudanExceptionis thrown if the Trackable is not initialised or if the width or height are invalid
Returns
A boolean indicating succcess (true) or failure (false) of changing the size
void setWidth ( float  width)

Set the value which represents the width of this trackable (in the units / reference frame of your choice) This sets what size the trackable will have in the 3D coordinate frame in which its pose is represented. It does not affect tracking.

Parameters
widthThe width of the trackable in some units

The documentation for this class was generated from the following file: