ImageTarget Class

Inherits: Target

Description

ImageTarget表示平面图像的target,它可以被 ImageTracker 所跟踪。

ImageTarget内的数值在可以被读取之前需要首先通过create.../setupAll等方法填入。然后再通过 ImageTracker.loadTarget 成功载入 ImageTracker 之后可以被 ImageTracker 检测和跟踪。

Constructor

C: void easyar_ImageTarget__ctor(easyar_ImageTarget * * Return)
C++17: ImageTarget()
Traditional C++: ImageTarget()
Java: public ImageTarget()
Kotlin: constructor()
Objective-C: + (easyar_ImageTarget *) create
Swift: public convenience init()
C#: public ImageTarget()

createFromParameters

从参数创建。

C: void easyar_ImageTarget_createFromParameters(easyar_ImageTargetParameters * parameters, easyar_OptionalOfImageTarget * Return)
C++17: static std::optional<std::shared_ptr<ImageTarget>> createFromParameters(std::shared_ptr<ImageTargetParameters> parameters)
Traditional C++: static void createFromParameters(ImageTargetParameters * parameters, ImageTarget * * Return)
Java: public static @Nullable ImageTarget createFromParameters(@Nonnull ImageTargetParameters parameters)
Kotlin: companion object fun createFromParameters(parameters: ImageTargetParameters): ImageTarget?
Objective-C: + (easyar_ImageTarget *)createFromParameters:(easyar_ImageTargetParameters *)parameters
Swift: public static func createFromParameters(_ parameters: ImageTargetParameters) -> ImageTarget?
C#: public static Optional<ImageTarget> createFromParameters(ImageTargetParameters parameters)

createFromTargetFile

从etd文件创建。

C: void easyar_ImageTarget_createFromTargetFile(easyar_String * path, easyar_StorageType storageType, easyar_OptionalOfImageTarget * Return)
C++17: static std::optional<std::shared_ptr<ImageTarget>> createFromTargetFile(std::string path, StorageType storageType)
Traditional C++: static void createFromTargetFile(String * path, StorageType storageType, ImageTarget * * Return)
Java: public static @Nullable ImageTarget createFromTargetFile(java.lang.@Nonnull String path, int storageType)
Kotlin: companion object fun createFromTargetFile(path: String, storageType: Int): ImageTarget?
Objective-C: + (easyar_ImageTarget *)createFromTargetFile:(NSString *)path storageType:(easyar_StorageType)storageType
Swift: public static func createFromTargetFile(_ path: String, _ storageType: StorageType) -> ImageTarget?
C#: public static Optional<ImageTarget> createFromTargetFile(string path, StorageType storageType)

createFromTargetData

从etd数据缓存创建。

C: void easyar_ImageTarget_createFromTargetData(easyar_Buffer * buffer, easyar_OptionalOfImageTarget * Return)
C++17: static std::optional<std::shared_ptr<ImageTarget>> createFromTargetData(std::shared_ptr<Buffer> buffer)
Traditional C++: static void createFromTargetData(Buffer * buffer, ImageTarget * * Return)
Java: public static @Nullable ImageTarget createFromTargetData(@Nonnull Buffer buffer)
Kotlin: companion object fun createFromTargetData(buffer: Buffer): ImageTarget?
Objective-C: + (easyar_ImageTarget *)createFromTargetData:(easyar_Buffer *)buffer
Swift: public static func createFromTargetData(_ buffer: Buffer) -> ImageTarget?
C#: public static Optional<ImageTarget> createFromTargetData(Buffer buffer)

save

保存为etd文件。

C: bool easyar_ImageTarget_save(easyar_ImageTarget * This, easyar_String * path)
C++17: bool save(std::string path)
Traditional C++: bool save(String * path)
Java: public boolean save(java.lang.@Nonnull String path)
Kotlin: fun save(path: String): Boolean
Objective-C: - (bool)save:(NSString *)path
Swift: public func save(_ path: String) -> Bool
C#: public virtual bool save(string path)

createFromImageFile

从图像创建。如果不需要,name、uid、meta可以传空字符串,scale可以传默认值1。

C: void easyar_ImageTarget_createFromImageFile(easyar_String * path, easyar_StorageType storageType, easyar_String * name, easyar_String * uid, easyar_String * meta, float scale, easyar_OptionalOfImageTarget * Return)
C++17: static std::optional<std::shared_ptr<ImageTarget>> createFromImageFile(std::string path, StorageType storageType, std::string name, std::string uid, std::string meta, float scale)
Traditional C++: static void createFromImageFile(String * path, StorageType storageType, String * name, String * uid, String * meta, float scale, ImageTarget * * Return)
Java: public static @Nullable ImageTarget createFromImageFile(java.lang.@Nonnull String path, int storageType, java.lang.@Nonnull String name, java.lang.@Nonnull String uid, java.lang.@Nonnull String meta, float scale)
Kotlin: companion object fun createFromImageFile(path: String, storageType: Int, name: String, uid: String, meta: String, scale: Float): ImageTarget?
Objective-C: + (easyar_ImageTarget *)createFromImageFile:(NSString *)path storageType:(easyar_StorageType)storageType name:(NSString *)name uid:(NSString *)uid meta:(NSString *)meta scale:(float)scale
Swift: public static func createFromImageFile(_ path: String, _ storageType: StorageType, _ name: String, _ uid: String, _ meta: String, _ scale: Float) -> ImageTarget?
C#: public static Optional<ImageTarget> createFromImageFile(string path, StorageType storageType, string name, string uid, string meta, float scale)

setupAll

从一个json文件配置其中列出的所有target。这个方法只会解析json文件或字符串。

如果 path 是json文件的路径,storageType应该设成 AppAssetsAbsolute ,表示路径的类型。json文件内部的路径应该是绝对路径或相对于json文件的相对路径。

详细描述参见 StorageType

C: void easyar_ImageTarget_setupAll(easyar_String * path, easyar_StorageType storageType, easyar_ListOfImageTarget * * Return)
C++17: static std::vector<std::shared_ptr<ImageTarget>> setupAll(std::string path, StorageType storageType)
Traditional C++: static void setupAll(String * path, StorageType storageType, ListOfImageTarget * * Return)
Java: public static java.util.@Nonnull ArrayList<@Nonnull ImageTarget> setupAll(java.lang.@Nonnull String path, int storageType)
Kotlin: companion object fun setupAll(path: String, storageType: Int): ArrayList<ImageTarget>
Objective-C: + (NSArray<easyar_ImageTarget *> *)setupAll:(NSString *)path storageType:(easyar_StorageType)storageType
Swift: public static func setupAll(_ path: String, _ storageType: StorageType) -> [ImageTarget]
C#: public static List<ImageTarget> setupAll(string path, StorageType storageType)

scale

图像的缩放比例。其值为图像宽度的物理大小与1米的比值,默认值为1。

C: float easyar_ImageTarget_scale(const easyar_ImageTarget * This)
C++17: float scale()
Traditional C++: float scale()
Java: public float scale()
Kotlin: fun scale(): Float
Objective-C: - (float)scale
Swift: public func scale() -> Float
C#: public virtual float scale()

aspectRatio

图像的宽高比。

C: float easyar_ImageTarget_aspectRatio(const easyar_ImageTarget * This)
C++17: float aspectRatio()
Traditional C++: float aspectRatio()
Java: public float aspectRatio()
Kotlin: fun aspectRatio(): Float
Objective-C: - (float)aspectRatio
Swift: public func aspectRatio() -> Float
C#: public virtual float aspectRatio()

setScale

设置图像的缩放比例,设置之后会覆盖默认值以及在json文件中设的数值。其值为图像宽度的物理大小与1米的比值,默认值为1。

还需要在渲染引擎中单独设置此模型缩放。

C: bool easyar_ImageTarget_setScale(easyar_ImageTarget * This, float scale)
C++17: bool setScale(float scale)
Traditional C++: bool setScale(float scale)
Java: public boolean setScale(float scale)
Kotlin: fun setScale(scale: Float): Boolean
Objective-C: - (bool)setScale:(float)scale
Swift: public func setScale(_ scale: Float) -> Bool
C#: public virtual bool setScale(float scale)

images

获取target中存储的图像列表。通常这个方法用来获取云端返回的target的识别图数据。

C: void easyar_ImageTarget_images(easyar_ImageTarget * This, easyar_ListOfImage * * Return)
C++17: std::vector<std::shared_ptr<Image>> images()
Traditional C++: void images(ListOfImage * * Return)
Java: public java.util.@Nonnull ArrayList<@Nonnull Image> images()
Kotlin: fun images(): ArrayList<Image>
Objective-C: - (NSArray<easyar_Image *> *)images
Swift: public func images() -> [Image]
C#: public virtual List<Image> images()

runtimeID

获取target id。target id是运行时创建的整型数据,只有在成功的配置之后才是有效(非0)的。这个id是非0且全局递增的。

C: int easyar_ImageTarget_runtimeID(const easyar_ImageTarget * This)
C++17: int runtimeID()
Traditional C++: int runtimeID()
Java: public int runtimeID()
Kotlin: fun runtimeID(): Int
Objective-C: - (int)runtimeID
Swift: public override func runtimeID() -> Int32
C#: public override int runtimeID()

uid

获取target uid。ImageTarget的uid在云识别算法中使用。在没有接入云识别的时候,你可以在json配置中设置这个uid,在自己的代码中作为另一种区分target的方法。

C: void easyar_ImageTarget_uid(const easyar_ImageTarget * This, easyar_String * * Return)
C++17: std::string uid()
Traditional C++: void uid(String * * Return)
Java: public java.lang.@Nonnull String uid()
Kotlin: fun uid(): String
Objective-C: - (NSString *)uid
Swift: public override func uid() -> String
C#: public override string uid()

name

获取target名字。名字用来在json文件中区分target。

C: void easyar_ImageTarget_name(const easyar_ImageTarget * This, easyar_String * * Return)
C++17: std::string name()
Traditional C++: void name(String * * Return)
Java: public java.lang.@Nonnull String name()
Kotlin: fun name(): String
Objective-C: - (NSString *)name
Swift: public override func name() -> String
C#: public override string name()

setName

设置target名字。这个操作会覆盖上一次的设置或是服务器返回的数据。

C: void easyar_ImageTarget_setName(easyar_ImageTarget * This, easyar_String * name)
C++17: void setName(std::string name)
Traditional C++: void setName(String * name)
Java: public void setName(java.lang.@Nonnull String name)
Kotlin: fun setName(name: String): Unit
Objective-C: - (void)setName:(NSString *)name
Swift: public override func setName(_ name: String) -> Void
C#: public override void setName(string name)

meta

获取setMetaData所设置的meta data。或者在云识别返回的target中,获得服务器所设置的meta data。

C: void easyar_ImageTarget_meta(const easyar_ImageTarget * This, easyar_String * * Return)
C++17: std::string meta()
Traditional C++: void meta(String * * Return)
Java: public java.lang.@Nonnull String meta()
Kotlin: fun meta(): String
Objective-C: - (NSString *)meta
Swift: public override func meta() -> String
C#: public override string meta()

setMeta

设置meta data。这个操作会覆盖上一次的设置或是服务器返回的数据。

C: void easyar_ImageTarget_setMeta(easyar_ImageTarget * This, easyar_String * data)
C++17: void setMeta(std::string data)
Traditional C++: void setMeta(String * data)
Java: public void setMeta(java.lang.@Nonnull String data)
Kotlin: fun setMeta(data: String): Unit
Objective-C: - (void)setMeta:(NSString *)data
Swift: public override func setMeta(_ data: String) -> Void
C#: public override void setMeta(string data)