ImageTarget Class

Inherits: Target

Description

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 setup method or calculated from image resolution automatically if not provided.

A ImageTarget should be setuped using setup 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.

Constructor

C: void easyar_ImageTarget__ctor(easyar_ImageTarget * * Return)
C++11: ImageTarget()
Traditional C++: ImageTarget()
Java: public ImageTarget()
Objective-C: + (easyar_ImageTarget *) create
Swift (since EasyAR SDK 2.1.0): public convenience init()

setup

Setup target using a json file or json string. This method only parses the json file or string.

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

If path is json file path, storageType should be App or Assets or Absolute 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 (App | Json) or (Assets | Json) or (Absolute | Json). Paths inside json string should be absolute path or relative path to the storageType root.

See StorageType for more descriptions of StorageType.

C: bool easyar_ImageTarget_setup(easyar_ImageTarget * This, easyar_String * path, int storageType, easyar_String * name)
C++11: bool setup(std::string path, int storageType, std::string name)
Traditional C++: bool setup(String * path, int storageType, String * name)
Java: public native boolean setup(java.lang.String path, int storageType, java.lang.String name)
Objective-C: - (bool)setup:(NSString *)path storageType:(int)storageType name:(NSString *)name
Swift (since EasyAR SDK 2.1.0): public func setup(_ path: String, _ storageType: Int32, _ name: String) -> Bool

setupAll

Setup all targets listed in the json file or json string from path with storageType. See setup and StorageType for more descriptions of storageType and json file.

C: void easyar_ImageTarget_setupAll(easyar_String * path, int storageType, easyar_ListOfPointerOfImageTarget * * Return)
C++11: static std::vector<std::shared_ptr<ImageTarget>> setupAll(std::string path, int storageType)
Traditional C++: static void setupAll(String * path, int storageType, ListOfPointerOfImageTarget * * Return)
Java: public static native java.util.ArrayList<ImageTarget> setupAll(java.lang.String path, int storageType)
Objective-C: + (NSArray<easyar_ImageTarget *> *)setupAll:(NSString *)path storageType:(int)storageType
Swift (since EasyAR SDK 2.1.0): public static func setupAll(_ path: String, _ storageType: Int32) -> [ImageTarget]

size

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.

C: easyar_Vec2F easyar_ImageTarget_size(const easyar_ImageTarget * This)
C++11: Vec2F size()
Traditional C++: Vec2F size()
Java: public native Vec2F size()
Objective-C: - (easyar_Vec2F *)size
Swift (since EasyAR SDK 2.1.0): public func size() -> Vec2F

setSize

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.

C: bool easyar_ImageTarget_setSize(easyar_ImageTarget * This, easyar_Vec2F size)
C++11: bool setSize(Vec2F size)
Traditional C++: bool setSize(Vec2F size)
Java: public native boolean setSize(Vec2F size)
Objective-C: - (bool)setSize:(easyar_Vec2F *)size
Swift (since EasyAR SDK 2.1.0): public func setSize(_ size: Vec2F) -> Bool

images

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

C: void easyar_ImageTarget_images(easyar_ImageTarget * This, easyar_ListOfPointerOfImage * * Return)
C++11: std::vector<std::shared_ptr<Image>> images()
Traditional C++: void images(ListOfPointerOfImage * * Return)
Java: public native java.util.ArrayList<Image> images()
Objective-C: - (NSArray<easyar_Image *> *)images
Swift (since EasyAR SDK 2.1.0): public func images() -> [Image]

runtimeID

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

C: int easyar_ImageTarget_runtimeID(const easyar_ImageTarget * This)
C++11: int runtimeID()
Traditional C++: int runtimeID()
Java: public native int runtimeID()
Objective-C: - (int)runtimeID
Swift (since EasyAR SDK 2.1.0): public override func runtimeID() -> Int32

uid

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 an alternative method to distinguish from targets.

C: void easyar_ImageTarget_uid(const easyar_ImageTarget * This, easyar_String * * Return)
C++11: std::string uid()
Traditional C++: void uid(String * * Return)
Java: public native java.lang.String uid()
Objective-C: - (NSString *)uid
Swift (since EasyAR SDK 2.1.0): public override func uid() -> String

name

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

C: void easyar_ImageTarget_name(const easyar_ImageTarget * This, easyar_String * * Return)
C++11: std::string name()
Traditional C++: void name(String * * Return)
Java: public native java.lang.String name()
Objective-C: - (NSString *)name
Swift (since EasyAR SDK 2.1.0): public override func name() -> String

meta

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

C: void easyar_ImageTarget_meta(const easyar_ImageTarget * This, easyar_String * * Return)
C++11: std::string meta()
Traditional C++: void meta(String * * Return)
Java: public native java.lang.String meta()
Objective-C: - (NSString *)meta
Swift (since EasyAR SDK 2.1.0): public override func meta() -> String

setMeta

Set meta data. It will erase previously set data or data from cloud.

C: void easyar_ImageTarget_setMeta(easyar_ImageTarget * This, easyar_String * data)
C++11: void setMeta(std::string data)
Traditional C++: void setMeta(String * data)
Java: public native void setMeta(java.lang.String data)
Objective-C: - (void)setMeta:(NSString *)data
Swift (since EasyAR SDK 2.1.0): public override func setMeta(_ data: String) -> Void