ObjectTarget Class¶
Inherits: Target
Description¶
ObjectTarget表示3D object target,它可以被 ObjectTracker 所跟踪。
ObjectTarget的大小由 obj 文件决定。可以通过修改 scale 达到修改size的目的。 scale 默认为1。
ObjectTarget内的数值在可以被读取之前需要首先通过setupAll方法载入。然后再通过 ObjectTracker.loadTarget 成功载入 ObjectTracker 之后可以被 ObjectTracker 检测和跟踪。
Constructor¶
- C: void easyar_ObjectTarget__ctor(easyar_ObjectTarget * * Return)¶
- C++17: ObjectTarget()¶
- Traditional C++: ObjectTarget()¶
- Java: public ObjectTarget()¶
- Kotlin: constructor()¶
- Objective-C: + (easyar_ObjectTarget *) create¶
- Swift: public convenience init()¶
- C#: public ObjectTarget()¶
createFromParameters¶
从参数创建。
- C: void easyar_ObjectTarget_createFromParameters(easyar_ObjectTargetParameters * parameters, easyar_OptionalOfObjectTarget * Return)¶
- Traditional C++: static void createFromParameters(ObjectTargetParameters * parameters, ObjectTarget * * Return)¶
- Java: public static @Nullable ObjectTarget createFromParameters(@Nonnull ObjectTargetParameters parameters)¶
- Kotlin: companion object fun createFromParameters(parameters: ObjectTargetParameters): ObjectTarget?¶
- Objective-C: + (easyar_ObjectTarget *)createFromParameters:(easyar_ObjectTargetParameters *)parameters¶
- Swift: public static func createFromParameters(_ parameters: ObjectTargetParameters) -> ObjectTarget?¶
- C#: public static Optional<ObjectTarget> createFromParameters(ObjectTargetParameters parameters)¶
createFromObjectFile¶
从obj, mtl和jpg/png文件创建。
- C: void easyar_ObjectTarget_createFromObjectFile(easyar_String * path, easyar_StorageType storageType, easyar_String * name, easyar_String * uid, easyar_String * meta, float scale, easyar_OptionalOfObjectTarget * Return)¶
- Traditional C++: static void createFromObjectFile(String * path, StorageType storageType, String * name, String * uid, String * meta, float scale, ObjectTarget * * Return)¶
- Java: public static @Nullable ObjectTarget createFromObjectFile(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 createFromObjectFile(path: String, storageType: Int, name: String, uid: String, meta: String, scale: Float): ObjectTarget?¶
- Objective-C: + (easyar_ObjectTarget *)createFromObjectFile:(NSString *)path storageType:(easyar_StorageType)storageType name:(NSString *)name uid:(NSString *)uid meta:(NSString *)meta scale:(float)scale¶
- Swift: public static func createFromObjectFile(_ path: String, _ storageType: StorageType, _ name: String, _ uid: String, _ meta: String, _ scale: Float) -> ObjectTarget?¶
- C#: public static Optional<ObjectTarget> createFromObjectFile(string path, StorageType storageType, string name, string uid, string meta, float scale)¶
setupAll¶
从一个json文件配置其中列出的所有target。这个方法只会解析json文件或字符串。
如果 path 是json文件的路径,storageType应该设成 App 或 Assets 或 Absolute ,表示路径的类型。json文件内部的路径应该是绝对路径或相对于json文件的相对路径。
详细描述参见 StorageType 。
- C: void easyar_ObjectTarget_setupAll(easyar_String * path, easyar_StorageType storageType, easyar_ListOfObjectTarget * * Return)¶
- Traditional C++: static void setupAll(String * path, StorageType storageType, ListOfObjectTarget * * Return)¶
- Java: public static java.util.@Nonnull ArrayList<@Nonnull ObjectTarget> setupAll(java.lang.@Nonnull String path, int storageType)¶
- Kotlin: companion object fun setupAll(path: String, storageType: Int): ArrayList<ObjectTarget>¶
- Objective-C: + (NSArray<easyar_ObjectTarget *> *)setupAll:(NSString *)path storageType:(easyar_StorageType)storageType¶
- Swift: public static func setupAll(_ path: String, _ storageType: StorageType) -> [ObjectTarget]¶
- C#: public static List<ObjectTarget> setupAll(string path, StorageType storageType)¶
scale¶
模型的缩放比例。其值为模型在空间中的物理大小与在模型坐标系中的大小的比值,默认值为1。(假设模型坐标系中的标尺单位为米)
- C: float easyar_ObjectTarget_scale(const easyar_ObjectTarget * 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()¶
boundingBox¶
物体的包围盒,包括盒子的8个顶点。
顶点索引定义如下:
4-----7
/| /|
5-----6 | z
| | | | |
| 0---|-3 o---y
|/ |/ /
1-----2 x
- C: void easyar_ObjectTarget_boundingBox(easyar_ObjectTarget * This, easyar_ListOfVec3F * * Return)¶
- C++17: std::vector<Vec3F> boundingBox()¶
- Traditional C++: void boundingBox(ListOfVec3F * * Return)¶
- Java: public java.util.@Nonnull ArrayList<@Nonnull Vec3F> boundingBox()¶
- Kotlin: fun boundingBox(): ArrayList<Vec3F>¶
- Objective-C: - (NSArray<easyar_Vec3F *> *)boundingBox¶
- Swift: public func boundingBox() -> [Vec3F]¶
- C#: public virtual List<Vec3F> boundingBox()¶
setScale¶
设置模型的缩放比例。设置之后会覆盖默认值以及在json文件中设的数值。其值为模型在空间中的物理大小与在模型坐标系中的大小的比值,默认值为1。(假设模型坐标系中的标尺单位为米)
还需要在渲染引擎中单独设置此模型缩放。
注意该设置需要在通过 ObjectTracker.loadTarget 载入 ObjectTracker 之前进行。
- C: bool easyar_ObjectTarget_setScale(easyar_ObjectTarget * 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)¶
runtimeID¶
获取target id。target id是运行时创建的整型数据,只有在成功的配置之后才是有效(非0)的。这个id是非0且全局递增的。
- C: int easyar_ObjectTarget_runtimeID(const easyar_ObjectTarget * 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_ObjectTarget_uid(const easyar_ObjectTarget * 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_ObjectTarget_name(const easyar_ObjectTarget * 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_ObjectTarget_setName(easyar_ObjectTarget * 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_ObjectTarget_meta(const easyar_ObjectTarget * 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_ObjectTarget_setMeta(easyar_ObjectTarget * 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)¶