Target Class

Header: #include "easyar/target.hpp"

Inherits: RefBase

Inherited By: ImageTarget

Description

Target is the base class for all targets that can be tracked by ImageTracker or other algorithms inside EasyAR.

A target should be loaded before any value is valid.

Public Functions

Target()
virtual ~Target()
virtual bool load(const char* path, int storageType, const char* name = 0)
int id() const
const char* uid() const
const char* name() const
const char* metaData() const
bool setMetaData(const char* data)
ImageList images()

Target()

Creates a Target object.

virtual ~Target()

Destroys the Target object.

virtual bool load(const char* path, int storageType, const char* name = 0)

Load a json file or json string. The implement of this method is empty, you should use it from a derived class.

Load named target if name is not empty, otherwise load the first target.

If path is json file path, storageType should be kStorageApp or kStorageAssets or kStorageAbsolute indicating the path type. Paths inside json files should be absolute path or relative path to the json file.

If path is json string, storageType should be (kStorageApp | kStorageJson) or (kStorageAssets | kStorageJson) or ( kStorageAbsolute | kStorageJson). Paths inside json string should be absolute path or relative path to the storageType root.

See StorageType for more descriptions of StorageType.

int id() const

Returns the target id. A target id is a int number generated at runtime, it is valid (non-zero) only after a successful load.

const char* uid() const

Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.

const char* name() const

Returns the target name. Name is used to distinguish targets in a json file. see load for more details.

const char* metaData() const

Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.

bool setMetaData(const char* data)

Set meta data. data will be copied as string. It will erase previously set data or data from cloud.

ImageList images()

Returns a list of images that stored in the target. It is generally used to get image data from cloud returned target.