![]() |
KudanCV
|
#include <KudanCV.h>
Classes | |
class | Private |
Public Member Functions | |
KudanImageTrackable (std::shared_ptr< Private >) | |
bool | isTrackingReliable () |
int | isRecovered () |
bool | isTracked () |
KudanVector3 | getPosition () |
KudanQuaternion | getOrientation () |
int | getNumTrackedPoints () |
std::vector< KudanVector2 > | getTrackedPoints () |
std::vector< KudanVector2 > | getTrackedCorners () |
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) |
bool | setVirtualCrop (float x, float y, float w, float h) |
bool | resetVirtualCrop () |
bool | isAutoCropped () |
void | allowRecoveryMode () |
void | forceRecoveryMode () |
void | prohibitRecoveryMode () |
bool | queryRecoveryMode (bool globalSetting) |
void | setExtensible (bool isExtensible) |
bool | isExtensible () |
bool | isExtended () |
void | clearExtensions () |
Static Public Member Functions | |
static std::shared_ptr< KudanImageTrackable > | createFromImageFile (std::string path, std::string name="", bool autoCrop=false) |
static std::shared_ptr< KudanImageTrackable > | createFromFilePointer (FILE *filePointer) |
static std::shared_ptr< KudanImageTrackable > | createFromImageData (const unsigned char *imageData, std::string name, int width, int height, int channels, int padding) |
static std::shared_ptr< KudanImageTrackable > | createFromImageData (const unsigned char *imageData, std::string name, int width, int height, int channels, int padding, bool autoCrop) |
Friends | |
class | KudanImageTracker |
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.
KudanImageTrackable::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
void KudanImageTrackable::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.
void KudanImageTrackable::clearExtensions | ( | ) |
If this Trackable has any extensions, it will delete them (so they can be re-created). If any of the extensions are being tracked, tracking will immediately fail.
|
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.
filePointer | A file pointer refering to a .KARMarker file, created with the Kudan Toolkit. |
|
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)
imageData | Pointer to the actual image data |
name | Name of this Trackable |
width,height,channels,padding | Parameters of the image data |
KudanException | is thrown if the data pointer is null or if a wrong number of channels is given |
|
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.
path | Location of th eimage file (jpeg or png) |
name | Name of this Trackable (optional). If not given, the name is derived from the path |
KudanException | is thrown if the image cannot be read or is empty. |
void KudanImageTrackable::forceRecoveryMode | ( | ) |
Turn on recovery mode for this Trackable. This Trackable will have recovery mode emabled irrespective of the global setting.
float KudanImageTrackable::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.
std::string KudanImageTrackable::getName | ( | ) |
Get the name of this Trackable.
int KudanImageTrackable::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.
KudanQuaternion KudanImageTrackable::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
KudanVector3 KudanImageTrackable::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.
std::vector< KudanVector2 > KudanImageTrackable::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
std::vector< KudanVector2 > KudanImageTrackable::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()
float KudanImageTrackable::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.
bool KudanImageTrackable::isAutoCropped | ( | ) |
This returns whether the trackable was automatically cropped or not. Note that even if auto-cropping was requested, it might not have been applied, if it was deemed not to be necessary: this returns whether cropping actually happened. Note also that virtual cropping cannot be applied to an auto-cropped marker
bool KudanImageTrackable::isExtended | ( | ) |
Query whether this Trackable has existing extensions or not (i.e. extended tracking and detection was enabled and new Trackables have been created
bool KudanImageTrackable::isExtensible | ( | ) |
Query whether this Trackable can be extended or not (see setExtensible)
int KudanImageTrackable::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)
bool KudanImageTrackable::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
bool KudanImageTrackable::isTrackingReliable | ( | ) |
Query whether tracking of this Trackable is currently deemed reliable.
void KudanImageTrackable::prohibitRecoveryMode | ( | ) |
Switch off recovery mode for this Trackable. This prevents this Trackable from using recovery mode, irrespective of the global setting.
bool KudanImageTrackable::queryRecoveryMode | ( | bool | globalSetting | ) |
Query recovery mode for this Trackable. This could depend on the global setting, depending how it was set.
globalSetting | Specifies whether recovery mode is allowed in the tracker |
bool KudanImageTrackable::resetVirtualCrop | ( | ) |
If this trackable has been virtually cropped, this rests it to its initial state. This might not always be possible, e.g. if the trackable has since been extended
void KudanImageTrackable::setExtensible | ( | bool | isExtensible | ) |
Turn on/off extended detection and tracking for this Trackable. This will allow new Trackables to be automatically created at increasing scales with respect to the original trackable image, to increase the range from which it can be detected and tracked.
isExtensible | Set whether extended tracking and detection is on (true) of off (false). If switched on, new trackbles will be automatically created; if switched off, this stops, but extisting extensions will remain (see clearExtensions) |
void KudanImageTrackable::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.
height | The height of the trackable in some units |
void KudanImageTrackable::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)
name | The name which will be assigned to this trackable |
void KudanImageTrackable::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
scale | Scale factor relating the trackable image size to the apparent size in 3D |
bool KudanImageTrackable::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)
width,height | The dimensions of the Trackable image. These can be in any units, but should always have the same aspect ratio as the actual image. |
KudanException | is thrown if the Trackable is not initialised or if the width or height are invalid |
bool KudanImageTrackable::setVirtualCrop | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
This allows the size of the displayed region to be manually changed, to arbitrary location and size. This does not change the tracking at all, but just the way the result of the tracking is viewed. For example, setting the x and y parameters to 0 and the width and height to 10 will make it appear as though the trackable is a very small square, occupying the top left corner only of the trackable image. Note that the units are the same as those in which the trackable size is expressed in. This means that setting the virtual cropping should be done after specifying the real world size (for example, setting the width to 100 then setting the cropped width to 50 will mean that half of the horizontal size of the trackable will be covered). Some checks are carried out (resulting area must be positive, for example), and there are some limitations (a trackable which is already extended or auto-cropped cannot be re-cropped). The return value will report whether cropping was applied.
x,y | The coordinates of the top left corner of the virtual tracked, region in trackable units |
w,h | The size of the virtual tracked region, in trackable units |
void KudanImageTrackable::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.
width | The width of the trackable in some units |