KudanCV
KudanImageTracker Class Reference

The image tracker, for detecting and tracking KudanImageTrackables in an image stram. More...

#include <KudanCV.h>

Classes

class  Private
 

Public Member Functions

 KudanImageTracker ()
 
 ~KudanImageTracker ()
 
bool processFrame (const unsigned char *image, int width, int height, int channels, int padding, bool requireFlip)
 
int getNumberOfTrackables ()
 
std::vector< std::shared_ptr< KudanImageTrackable > > getTrackables ()
 
int getNumberOfDetectedTrackables ()
 
std::vector< std::shared_ptr< KudanImageTrackable > > getDetectedTrackables ()
 
bool addTrackable (const std::string path, std::string name="")
 
int addTrackableSet (const std::string path)
 
int addTrackableSet (const unsigned char *data, size_t length)
 
bool addTrackable (std::shared_ptr< KudanImageTrackable > kudanTrackable)
 
bool removeTrackable (std::shared_ptr< KudanImageTrackable > kudanTrackable)
 
std::shared_ptr< KudanImageTrackablegetTrackable (std::string name)
 
void setApiKey (std::string apiKey)
 
bool hasCameraCalibration ()
 
void setCameraParameters (KudanCameraParameters &cameraParameters)
 
KudanCameraParametersgetCameraParameters ()
 
KudanMatrix3 getCameraMatrix ()
 
KudanMatrix4 getProjectionMatrix (float nearPlane, float farPlane)
 
void setDetectionSensitivity (float sensitivity)
 
void resetDetectionSensitiviy ()
 
void setMaximumSimultaneousTracking (int maxTrack)
 
void toggleParallelDetection (bool doParallel)
 
bool isDetectorParallel ()
 
void setRecoveryMode (bool recovery)
 
void prohibitRecoveryMode ()
 
bool queryRecoveryMode ()
 
bool queryRecoveryMode (std::shared_ptr< KudanImageTrackable > trackable)
 

Detailed Description

The image tracker, for detecting and tracking KudanImageTrackables in an image stram.

Constructor & Destructor Documentation

◆ KudanImageTracker()

KudanImageTracker::KudanImageTracker ( )

Default constructor. This automatically initialises the tracker.

◆ ~KudanImageTracker()

KudanImageTracker::~KudanImageTracker ( )

This deinitialises the tracker automatically

Member Function Documentation

◆ addTrackable() [1/2]

bool KudanImageTracker::addTrackable ( const std::string  path,
std::string  name = "" 
)

Create and add a single Trackable from an image.

Parameters
pathThe location of the image
nameA name for the Trackable. If empty (default) the name is derived from the image path.
Returns
boolean indicating if the Trackable was created and added successfully

◆ addTrackable() [2/2]

bool KudanImageTracker::addTrackable ( std::shared_ptr< KudanImageTrackable kudanTrackable)

Add a Trackable to the tracker. The Trackable should be valid and created already.

Returns
Boolean indicating whether it was successfully added to the underlying tracker

◆ addTrackableSet() [1/2]

int KudanImageTracker::addTrackableSet ( const std::string  path)

Load a Trackable set from an file (created with the Toolkit)

Parameters
pathThe location of the .KARMarker file
Returns
The number of Trackables successfully loaded from this set

◆ addTrackableSet() [2/2]

int KudanImageTracker::addTrackableSet ( const unsigned char *  data,
size_t  length 
)

Load a Trackable set from data (created with the Toolkit)

Parameters
dataRaw Trackable file data
lengthThe length of the data
Returns
The number of Trackables successfully loaded

◆ getCameraMatrix()

KudanMatrix3 KudanImageTracker::getCameraMatrix ( )

Get the calibration matrix for this camera, derived from the intrinsic parameters. This is a 3x3 matrix represented as the float array within a KudanMatrix3

Returns
A KudanMatrix3 representing the intrinsic parameters
Exceptions
KudanExceptionis thrown if the parameters have not been set

◆ getCameraParameters()

KudanCameraParameters & KudanImageTracker::getCameraParameters ( )

Get a (reference to) the camera parameters set on the tracker.

Returns
A reference to a KudanCameraParameters object. Altering this will change the one stored in the tracker

◆ getDetectedTrackables()

std::vector< std::shared_ptr< KudanImageTrackable > > KudanImageTracker::getDetectedTrackables ( )

Get a list of pointers to all Trackables successfuly tracked in the last frame

Returns
A list of (pointers to) KudanImageTrackable objects, representing all of the Trackables currently tracked.

◆ getNumberOfDetectedTrackables()

int KudanImageTracker::getNumberOfDetectedTrackables ( )

Get the number of Trackables successfully tracked in this frame

Returns
The number of currently tracked Trackables.

◆ getNumberOfTrackables()

int KudanImageTracker::getNumberOfTrackables ( )

Get the number of Trackables loaded successfully into the tracker

◆ getProjectionMatrix()

KudanMatrix4 KudanImageTracker::getProjectionMatrix ( float  nearPlane,
float  farPlane 
)

Get the projection matrix for this camera, derived from the intrinsic parameters and the given clipping planes This is a 4x4 matrix represented as the float array within a KudanMatrix.

Parameters
nearPlane,farPlaneThe clipping planes to be used for rendering (not part of the camera parameters).
Returns
A KudanMatrix representing the intrinsic parameters plus clipping planes.
Exceptions
KudanExceptionis thrown if the parameters have not been set

◆ getTrackable()

std::shared_ptr< KudanImageTrackable > KudanImageTracker::getTrackable ( std::string  name)

Get a pointer to a KudanImageTrackable by its name. This is so that settigns can be set on it

◆ getTrackables()

std::vector< std::shared_ptr< KudanImageTrackable > > KudanImageTracker::getTrackables ( )

Get a list of pointers to all existing Trackables

Returns
A list of (pointers to) KudanImageTrackable objects, representing all of the Trackables currently loaded.

◆ hasCameraCalibration()

bool KudanImageTracker::hasCameraCalibration ( )

Queries if a calibration has been set (with setCameraParameters).

Returns
A boolean which is true if the calibration has been set

◆ isDetectorParallel()

bool KudanImageTracker::isDetectorParallel ( )

Query whether the detector is allowed to look for multiple Trackables in parallel or not

Returns
Boolean indicating whether parallel detection is enabled.

Query whether the detector is allowed to look for multiple trackables in parallel or not

◆ processFrame()

bool KudanImageTracker::processFrame ( const unsigned char *  image,
int  width,
int  height,
int  channels,
int  padding,
bool  requireFlip 
)

Process a new frame for detection and tracking. Any non-tracked Trackables will be searched for (depending on settings), and any Trackables visible in the previous frame will be tracked into this frame. This will fail (return false) if a valid license is not set.

Parameters
image8bpp greyscale image data.
width,heightsize of the image
channelsnumber of channels in the image (mono, colour, colour+alpha)
paddingthe number of bytes to ignore at the end of each line
requireFlipsome devices provide the image upside down (rotation of 180 degrees). This flips the image (in both axes) before processing
Returns
A boolean indicating whether tracking happened (true) or not (false)
Exceptions
KudanExceptionis thrown if there is no calibration data or an empty image.

◆ prohibitRecoveryMode()

void KudanImageTracker::prohibitRecoveryMode ( )

Completely switch off recovery mode. Recovery mode cannot be used on ANY Trackable, despite individual settings.

◆ queryRecoveryMode() [1/2]

bool KudanImageTracker::queryRecoveryMode ( )

Query whether recovery mode is being used (for Trackables which are not set individually)

Returns
A boolean indicating if recovery mode is globally on or off

◆ queryRecoveryMode() [2/2]

bool KudanImageTracker::queryRecoveryMode ( std::shared_ptr< KudanImageTrackable trackable)

Query whether recovery mode is being used for the specific Trackable. This needs to look at the global state to find out.

Parameters
trackablePointer to a Trackable object. Returns false if Trackable is nullptr.
Returns
A boolean indicating if recovery mode is on or off for the specified Trackable.

◆ removeTrackable()

bool KudanImageTracker::removeTrackable ( std::shared_ptr< KudanImageTrackable kudanTrackable)

Caution: not implemented yet

◆ resetDetectionSensitiviy()

void KudanImageTracker::resetDetectionSensitiviy ( )

Resets the detector sensitivity to default values

◆ setApiKey()

void KudanImageTracker::setApiKey ( std::string  apiKey)

A valid API key needs to be set before calling processFrame.

Parameters
apiKeyA valid key can only be acquired from Kudan.

◆ setCameraParameters()

void KudanImageTracker::setCameraParameters ( KudanCameraParameters cameraParameters)

Sets the camera parameters using given camera parameters.

Parameters
cameraParametersObject of KudanCameraParameters which defines the camera intrinsics and image size.
Exceptions
KudanExceptionis thrown if the parameters are invalid

◆ setDetectionSensitivity()

void KudanImageTracker::setDetectionSensitivity ( float  sensitivity)

Set the detector sensitivity. High sensitivity values mean the detector will more readily make detections (at the expense of accuracy). Lower values indicate more caution / robustness at the expense of missing detections

Parameters
sensitivitySensitivity value in range [0,1]

◆ setMaximumSimultaneousTracking()

void KudanImageTracker::setMaximumSimultaneousTracking ( int  maxTrack)

Set the maximum number of Trackables that can be tracked at any one time. This does not limit the number which are searched for, until all possible Trackables are being tracked (at which point detection stops) Setting to 0 means there is no limit

Parameters
maxTrackThe maximum number of Trackables which can be tracked at a time.

◆ setRecoveryMode()

void KudanImageTracker::setRecoveryMode ( bool  recovery)

Toggle recover mode. This turns recovery mode on/off for all Trackables, unless set otherwise on individual Trackables

Parameters
recoverySet whether recovery mode is on or off

◆ toggleParallelDetection()

void KudanImageTracker::toggleParallelDetection ( bool  doParallel)

Set whether the detector is allowed to look for multiple Trackables in parallel or not. The number of threads used (if on) is set automatcally and is platform-specific.

Parameters
doParallelSet if parallel detection is on or off

Set whether the detector is allowed to look for multiple trackables in parallel or not


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