Header: #include "easyar/target.hpp" (until 1.2.1)
Header: #include "easyar/imagetarget.hpp" (since 1.3.0)
ImageTarget represents planer image targets that can be tracked by ImageTracker.
The size of ImageTarget is set in json which will be loaded in the load method or calculated from image resolution automatically if not provided.
A ImageTarget should be loaded using load before any value is valid. And ImageTarget can be tracked by ImageTracker after a successful load into the ImageTracker using ImageTracker::loadTarget or ImageTracker::loadTargetBlocked.
Creates a ImageTarget object.
Destroys the ImageTarget object.
virtual bool load(const char* path, int storageType, const char* name = 0)¶
Load a json file or json string. This method only parses the json file or string.
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.
Vec2F size() const¶
Returns size of the image target. It is only valid (non-zero) after a successful load into the ImageTracker using ImageTracker::loadTarget or ImageTracker::loadTargetBlocked, or set manually using setSize.
If a size is not set in json or by setSize, the default size calculated from image resolution will be returned.
bool setSize(const Vec2F& size)¶
Sets image target size, this will overwrite the value set in the json file or the default value.
The value will be recalculated from image resolution after ImageTracker::loadTarget or ImageTracker::loadTargetBlocked. After calculation, the max value of size will be kept, and the other dimension will be updated from the resolution. Make sure to query size use size after a successfully load of target.
When the size is set to have the same aspect ratio as image resolution, it will make no difference after recalculation and the size will not actually change.
static TargetList loadAll(const char* path, int storageType) (since 1.3.0)¶
Loads all targets listed in the json file or json string from path with storageType . See load and StorageType for more descriptions of storageType and json file.