ImageTracker Class

Description

ImageTracker实现了平面卡片的检测和跟踪。

ImageTracker占用(1 + SimultaneousNum)个camera的buffer。应使用camera的setBufferCapacity设置不少于所有组件占用的camera的buffer数量。参考 概览

创建之后,可以调用start/stop来开始和停止运行,start/stop是非常轻量的调用。

当不再需要该组件时,可以调用close对其进行关闭。close之后不应继续使用。

ImageTracker通过feedbackFrameSink输入 FeedbackFrame ,应将 FeedbackFrameSource 连接到feedbackFrameSink上进行使用。参考 概览

Target 可以被ImageTracker跟踪之前,你需要通过loadTarget/unloadTarget将它载入。可以通过传入接口的回调来获取load/unload的结果。

isAvailable

返回true。

C

bool easyar_ImageTracker_isAvailable(void)

C++

static bool isAvailable()

Java

public static boolean isAvailable()

Kotlin

companion object fun isAvailable(): Boolean

Objective-C

+ (bool)isAvailable

Swift

public static func isAvailable() -> Bool

C#

public static bool isAvailable()

feedbackFrameSink

FeedbackFrame 输入端口。FeedbackFrame中的InputFrame成员要求必须拥有图像、时间戳和camera参数,camera支持针孔和鱼眼相机。

C

void easyar_ImageTracker_feedbackFrameSink(easyar_ImageTracker * This, easyar_FeedbackFrameSink * * Return)

C++

std::shared_ptr<FeedbackFrameSink> feedbackFrameSink()

Java

public @Nonnull FeedbackFrameSink feedbackFrameSink()

Kotlin

fun feedbackFrameSink(): FeedbackFrameSink

Objective-C

- (easyar_FeedbackFrameSink *)feedbackFrameSink

Swift

public func feedbackFrameSink() -> FeedbackFrameSink

C#

public virtual FeedbackFrameSink feedbackFrameSink()

bufferRequirement

当前组件占用camera buffer的数量。

C

int easyar_ImageTracker_bufferRequirement(easyar_ImageTracker * This)

C++

int bufferRequirement()

Java

public int bufferRequirement()

Kotlin

fun bufferRequirement(): Int

Objective-C

- (int)bufferRequirement

Swift

public func bufferRequirement() -> Int32

C#

public virtual int bufferRequirement()

outputFrameSource

OutputFrame 输出端口。

C

void easyar_ImageTracker_outputFrameSource(easyar_ImageTracker * This, easyar_OutputFrameSource * * Return)

C++

std::shared_ptr<OutputFrameSource> outputFrameSource()

Java

public @Nonnull OutputFrameSource outputFrameSource()

Kotlin

fun outputFrameSource(): OutputFrameSource

Objective-C

- (easyar_OutputFrameSource *)outputFrameSource

Swift

public func outputFrameSource() -> OutputFrameSource

C#

public virtual OutputFrameSource outputFrameSource()

create

创建。默认的跟踪模式是 ImageTrackerMode.PreferQuality 。

C

void easyar_ImageTracker_create(easyar_ImageTracker * * Return)

C++

static std::shared_ptr<ImageTracker> create()

Java

public static @Nonnull ImageTracker create()

Kotlin

companion object fun create(): ImageTracker

Objective-C

+ (easyar_ImageTracker *)create

Swift

public static func create() -> ImageTracker

C#

public static ImageTracker create()

createWithMode

以特定跟踪模式创建。在低端手机上,可以使用 ImageTrackerMode.PreferPerformance 来获得更好的性能,但是跟踪效果会有些许损失。

C

void easyar_ImageTracker_createWithMode(easyar_ImageTrackerMode trackMode, easyar_ImageTracker * * Return)

C++

static std::shared_ptr<ImageTracker> createWithMode(ImageTrackerMode trackMode)

Java

public static @Nonnull ImageTracker createWithMode(int trackMode)

Kotlin

companion object fun createWithMode(trackMode: Int): ImageTracker

Objective-C

+ (easyar_ImageTracker *)createWithMode:(easyar_ImageTrackerMode)trackMode

Swift

public static func createWithMode(_ trackMode: ImageTrackerMode) -> ImageTracker

C#

public static ImageTracker createWithMode(ImageTrackerMode trackMode)

createWithConfig

以特定配置创建。

C

void easyar_ImageTracker_createWithConfig(easyar_ImageTrackerConfig * config, easyar_ImageTracker * * Return)

C++

static std::shared_ptr<ImageTracker> createWithConfig(std::shared_ptr<ImageTrackerConfig> config)

Java

public static @Nonnull ImageTracker createWithConfig(@Nonnull ImageTrackerConfig config)

Kotlin

companion object fun createWithConfig(config: ImageTrackerConfig): ImageTracker

Objective-C

+ (easyar_ImageTracker *)createWithConfig:(easyar_ImageTrackerConfig *)config

Swift

public static func createWithConfig(_ config: ImageTrackerConfig) -> ImageTracker

C#

public static ImageTracker createWithConfig(ImageTrackerConfig config)

setResultPostProcessing

设置结果后处理。

enablePersistentTargetInstance默认为false,开启时,如果 InputFrame 数据中包含空间信息,则 ImageTrackerResult 中的targetInstances会包含所有识别到的instance(包括当前未跟踪的)。

enableRtct默认为false,开启时,如果 InputFrame 数据中包含时间信息和空间信息,则 ImageTrackerResult 中的 targetInstances 的 pose 会使用 RealTimeCoordinateTransform 进行处理。

C

void easyar_ImageTracker_setResultPostProcessing(easyar_ImageTracker * This, bool enablePersistentTargetInstance, bool enableMotionFusion)

C++

void setResultPostProcessing(bool enablePersistentTargetInstance, bool enableMotionFusion)

Java

public void setResultPostProcessing(boolean enablePersistentTargetInstance, boolean enableMotionFusion)

Kotlin

fun setResultPostProcessing(enablePersistentTargetInstance: Boolean, enableMotionFusion: Boolean): Unit

Objective-C

- (void)setResultPostProcessing:(bool)enablePersistentTargetInstance enableMotionFusion:(bool)enableMotionFusion

Swift

public func setResultPostProcessing(_ enablePersistentTargetInstance: Bool, _ enableMotionFusion: Bool) -> Void

C#

public virtual void setResultPostProcessing(bool enablePersistentTargetInstance, bool enableMotionFusion)

setResultAsyncMode

设置结果异步模式。如果结果通过outputFrameSource输出,则应设置位true,如果结果通过getSyncResult获取,则应设置为false。默认enableAsync为true。同步模式仅在输入帧包含空间信息且使用XR License时可生效。

C

bool easyar_ImageTracker_setResultAsyncMode(easyar_ImageTracker * This, bool enableAsync)

C++

bool setResultAsyncMode(bool enableAsync)

Java

public boolean setResultAsyncMode(boolean enableAsync)

Kotlin

fun setResultAsyncMode(enableAsync: Boolean): Boolean

Objective-C

- (bool)setResultAsyncMode:(bool)enableAsync

Swift

public func setResultAsyncMode(_ enableAsync: Bool) -> Bool

C#

public virtual bool setResultAsyncMode(bool enableAsync)

start

开始跟踪算法。

C

bool easyar_ImageTracker_start(easyar_ImageTracker * This)

C++

bool start()

Java

public boolean start()

Kotlin

fun start(): Boolean

Objective-C

- (bool)start

Swift

public func start() -> Bool

C#

public virtual bool start()

stop

暂停跟踪算法。调用start来重新启动跟踪。

C

void easyar_ImageTracker_stop(easyar_ImageTracker * This)

C++

void stop()

Java

public void stop()

Kotlin

fun stop(): Unit

Objective-C

- (void)stop

Swift

public func stop() -> Void

C#

public virtual void stop()

close

关闭。close之后不应继续使用。

C

void easyar_ImageTracker_close(easyar_ImageTracker * This)

C++

void close()

Java

public void close()

Kotlin

fun close(): Unit

Objective-C

- (void)close

Swift

public func close() -> Void

C#

public virtual void close()

loadTarget

加载一个 Target 进入tracker。 Target 只有在成功加载进入tracker之后才能被识别和跟踪。

这个方法是异步方法。加载过程可能会需要一些时间来完成,这段时间内新的和丢失的target的检测可能会花比平时更多的时间,但是检测到之后的跟踪不受影响。如果你希望知道加载的结果,需要处理callback数据。callback将会在 CallbackScheduler 所指定的线程上被调用。跟踪线程和除了其它加载/卸载之外的操作都不会被阻塞。

C

void easyar_ImageTracker_loadTarget(easyar_ImageTracker * This, easyar_Target * target, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromTargetAndBool callback)

C++

void loadTarget(std::shared_ptr<Target> target, std::shared_ptr<CallbackScheduler> callbackScheduler, std::function<void(std::shared_ptr<Target>, bool)> callback)

Java

public void loadTarget(@Nonnull Target target, @Nonnull CallbackScheduler callbackScheduler, @Nonnull FunctorOfVoidFromTargetAndBool callback)

Kotlin

fun loadTarget(target: Target, callbackScheduler: CallbackScheduler, callback: FunctorOfVoidFromTargetAndBool): Unit

Objective-C

- (void)loadTarget:(easyar_Target *)target callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_Target * target, bool status))callback

Swift

public func loadTarget(_ target: Target, _ callbackScheduler: CallbackScheduler, _ callback: @escaping (Target, Bool) -> Void) -> Void

C#

public virtual void loadTarget(Target target, CallbackScheduler callbackScheduler, Action<Target, bool> callback)

unloadTarget

从tracker中卸载 Target

这个方法是异步方法。卸载过程可能会需要一些时间来完成,这段时间内新的和丢失的target的检测可能会花比平时更多的时间,但是检测到之后的跟踪不受影响。如果你希望知道卸载的结果,需要处理callback数据。callback将会在 CallbackScheduler 所指定的线程上被调用。跟踪线程和除了其它加载/卸载之外的操作都不会被阻塞。

C

void easyar_ImageTracker_unloadTarget(easyar_ImageTracker * This, easyar_Target * target, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromTargetAndBool callback)

C++

void unloadTarget(std::shared_ptr<Target> target, std::shared_ptr<CallbackScheduler> callbackScheduler, std::function<void(std::shared_ptr<Target>, bool)> callback)

Java

public void unloadTarget(@Nonnull Target target, @Nonnull CallbackScheduler callbackScheduler, @Nonnull FunctorOfVoidFromTargetAndBool callback)

Kotlin

fun unloadTarget(target: Target, callbackScheduler: CallbackScheduler, callback: FunctorOfVoidFromTargetAndBool): Unit

Objective-C

- (void)unloadTarget:(easyar_Target *)target callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_Target * target, bool status))callback

Swift

public func unloadTarget(_ target: Target, _ callbackScheduler: CallbackScheduler, _ callback: @escaping (Target, Bool) -> Void) -> Void

C#

public virtual void unloadTarget(Target target, CallbackScheduler callbackScheduler, Action<Target, bool> callback)

targets

返回当前已经被加载进入tracker的target。如果异步的加载/卸载正在执行,在加载/卸载完成之前的返回值将不会反映这些加载/卸载的结果。

C

void easyar_ImageTracker_targets(const easyar_ImageTracker * This, easyar_ListOfTarget * * Return)

C++

std::vector<std::shared_ptr<Target>> targets()

Java

public java.util.@Nonnull ArrayList<@Nonnull Target> targets()

Kotlin

fun targets(): ArrayList<Target>

Objective-C

- (NSArray<easyar_Target *> *)targets

Swift

public func targets() -> [Target]

C#

public virtual List<Target> targets()

setSimultaneousNum

设置最大可被tracker跟踪的目标个数。默认值为1。

C

bool easyar_ImageTracker_setSimultaneousNum(easyar_ImageTracker * This, int num)

C++

bool setSimultaneousNum(int num)

Java

public boolean setSimultaneousNum(int num)

Kotlin

fun setSimultaneousNum(num: Int): Boolean

Objective-C

- (bool)setSimultaneousNum:(int)num

Swift

public func setSimultaneousNum(_ num: Int32) -> Bool

C#

public virtual bool setSimultaneousNum(int num)

simultaneousNum

获取最大可被tracker跟踪的目标个数。默认值为1。

C

int easyar_ImageTracker_simultaneousNum(const easyar_ImageTracker * This)

C++

int simultaneousNum()

Java

public int simultaneousNum()

Kotlin

fun simultaneousNum(): Int

Objective-C

- (int)simultaneousNum

Swift

public func simultaneousNum() -> Int32

C#

public virtual int simultaneousNum()

getSyncResult

获得同步输出结果。如果ImageTracker已暂停,或者未通过setResultAsyncMode将结果异步模式设为false,则返回值为空。

C

void easyar_ImageTracker_getSyncResult(easyar_ImageTracker * This, double timestamp, easyar_Matrix44F cameraTransform, easyar_MotionTrackingStatus trackingStatus, easyar_OptionalOfImageTrackerResult * Return)

C++

std::optional<std::shared_ptr<ImageTrackerResult>> getSyncResult(double timestamp, Matrix44F cameraTransform, MotionTrackingStatus trackingStatus)

Java

public @Nullable ImageTrackerResult getSyncResult(double timestamp, @Nonnull Matrix44F cameraTransform, int trackingStatus)

Kotlin

fun getSyncResult(timestamp: Double, cameraTransform: Matrix44F, trackingStatus: Int): ImageTrackerResult?

Objective-C

- (easyar_ImageTrackerResult *)getSyncResult:(double)timestamp cameraTransform:(easyar_Matrix44F *)cameraTransform trackingStatus:(easyar_MotionTrackingStatus)trackingStatus

Swift

public func getSyncResult(_ timestamp: Double, _ cameraTransform: Matrix44F, _ trackingStatus: MotionTrackingStatus) -> ImageTrackerResult?

C#

public virtual Optional<ImageTrackerResult> getSyncResult(double timestamp, Matrix44F cameraTransform, MotionTrackingStatus trackingStatus)