ObjectTracker Class

Inherits: TargetTracker

Description

An ObjectTracker is a class for 3D object target detection and tracking.

ObjectTracker detects and tracks ObjectTarget. You need to call attachStreamer to attach a FrameStreamer to tracker first, then the images from the FrameStreamer are used for by the tracker. You can call start/stop to enable/disable the track process. start and stop are very lightweight calls.

Before a Target can be tracked by tracker, you have to load it using async method loadTarget/unloadTarget or synchronized loadTargetBlocked/unloadTargetBlocked. The async interfaces are recommended if you desire an unblocked process. You can get load/unload results from callbacks passed into the interfaces.

You can get a Frame by FrameStreamer.peek which contains current camera image and tracked TargetInstance.

Constructor

C: void easyar_ObjectTracker__ctor(easyar_ObjectTracker * * Return)
C++11: ObjectTracker()
Traditional C++: ObjectTracker()
Java: public ObjectTracker()
Objective-C: + (easyar_ObjectTracker *) create
Swift (since EasyAR SDK 2.1.0): public convenience init()

loadTarget

Load a Target into the tracker. A Target can only be tracked by tracker after a successful load.

This method is an async method. A load operation may take some time to finish and detection of a new/lost target may take more time during the load. The track time after detection will not be affected. If you want to know the load result, you have to handle the callback data. The callback will be called from a different thread; it will not block the track thread or any other operations except other load/unload.

C: void easyar_ObjectTracker_loadTarget(easyar_ObjectTracker * This, easyar_Target * target, easyar_FunctorOfVoidFromPointerOfTargetAndBool callback)
C++11: void loadTarget(std::shared_ptr<Target> target, std::function<void(std::shared_ptr<Target>, bool)> callback)
Traditional C++: void loadTarget(Target * target, FunctorOfVoidFromPointerOfTargetAndBool callback)
Java: public native void loadTarget(Target target, FunctorOfVoidFromPointerOfTargetAndBool callback)
Objective-C: - (void)loadTarget:(easyar_Target *)target callback:(void (^)(easyar_Target * target, bool status))callback
Swift (since EasyAR SDK 2.1.0): public override func loadTarget(_ target: Target, _ callback: @escaping (Target, Bool) -> Void) -> Void

unloadTarget

Unload a Target from the tracker.

This method is an async method. An unload operation may take some time to finish and detection of a new/lost target may take more time during the unload. If you want to know the unload result, you have to handle the callback data. The callback will be called from a different thread; it will not block the track thread or any other operations except other load/unload.

C: void easyar_ObjectTracker_unloadTarget(easyar_ObjectTracker * This, easyar_Target * target, easyar_FunctorOfVoidFromPointerOfTargetAndBool callback)
C++11: void unloadTarget(std::shared_ptr<Target> target, std::function<void(std::shared_ptr<Target>, bool)> callback)
Traditional C++: void unloadTarget(Target * target, FunctorOfVoidFromPointerOfTargetAndBool callback)
Java: public native void unloadTarget(Target target, FunctorOfVoidFromPointerOfTargetAndBool callback)
Objective-C: - (void)unloadTarget:(easyar_Target *)target callback:(void (^)(easyar_Target * target, bool status))callback
Swift (since EasyAR SDK 2.1.0): public override func unloadTarget(_ target: Target, _ callback: @escaping (Target, Bool) -> Void) -> Void

loadTargetBlocked

Load a Target into the tracker. A Target can only be tracked by tracker after a successful load.

This is a synchronized method. A load operation may take some time to finish and detection of a new/lost target may take more time during the load. It will block the calling thread. However, the track thread or camera thread will not be blocked.

C: bool easyar_ObjectTracker_loadTargetBlocked(easyar_ObjectTracker * This, easyar_Target * target)
C++11: bool loadTargetBlocked(std::shared_ptr<Target> target)
Traditional C++: bool loadTargetBlocked(Target * target)
Java: public native boolean loadTargetBlocked(Target target)
Objective-C: - (bool)loadTargetBlocked:(easyar_Target *)target
Swift (since EasyAR SDK 2.1.0): public override func loadTargetBlocked(_ target: Target) -> Bool

unloadTargetBlocked

Unload a Target from the tracker.

This is a synchronized method. An unload operation may take some time to finish and detection of a new/lost target may take more time during the unload. It will block the calling thread. However, the track thread or camera thread will not be blocked.

C: bool easyar_ObjectTracker_unloadTargetBlocked(easyar_ObjectTracker * This, easyar_Target * target)
C++11: bool unloadTargetBlocked(std::shared_ptr<Target> target)
Traditional C++: bool unloadTargetBlocked(Target * target)
Java: public native boolean unloadTargetBlocked(Target target)
Objective-C: - (bool)unloadTargetBlocked:(easyar_Target *)target
Swift (since EasyAR SDK 2.1.0): public override func unloadTargetBlocked(_ target: Target) -> Bool

targets

Returns current loaded targets in the tracker. If an async load/unload is in progress, the returned value will not reflect the result until all load/unload finish.

C: void easyar_ObjectTracker_targets(easyar_ObjectTracker * This, easyar_ListOfPointerOfTarget * * Return)
C++11: std::vector<std::shared_ptr<Target>> targets()
Traditional C++: void targets(ListOfPointerOfTarget * * Return)
Java: public native java.util.ArrayList<Target> targets()
Objective-C: - (NSArray<easyar_Target *> *)targets
Swift (since EasyAR SDK 2.1.0): public override func targets() -> [Target]

setSimultaneousNum

Set the max number of targets which will be the simulatneously tracked by the tracker. The default value is 1.

C: bool easyar_ObjectTracker_setSimultaneousNum(easyar_ObjectTracker * This, int num)
C++11: bool setSimultaneousNum(int num)
Traditional C++: bool setSimultaneousNum(int num)
Java: public native boolean setSimultaneousNum(int num)
Objective-C: - (bool)setSimultaneousNum:(int)num
Swift (since EasyAR SDK 2.1.0): public override func setSimultaneousNum(_ num: Int32) -> Bool

simultaneousNum

Get the max number of targets which will be the simulatneously tracked by the tracker. The default value is 1.

C: int easyar_ObjectTracker_simultaneousNum(easyar_ObjectTracker * This)
C++11: int simultaneousNum()
Traditional C++: int simultaneousNum()
Java: public native int simultaneousNum()
Objective-C: - (int)simultaneousNum
Swift (since EasyAR SDK 2.1.0): public override func simultaneousNum() -> Int32

attachStreamer

Attach FrameStreamer to the tracker. Tracker will not start to track until a FrameStreamer is attached.

Attach null object will detach previous attached FrameStreamer from tracker.

C: bool easyar_ObjectTracker_attachStreamer(easyar_ObjectTracker * This, easyar_FrameStreamer * obj)
C++11: bool attachStreamer(std::shared_ptr<FrameStreamer> obj)
Traditional C++: bool attachStreamer(FrameStreamer * obj)
Java: public native boolean attachStreamer(FrameStreamer obj)
Objective-C: - (bool)attachStreamer:(easyar_FrameStreamer *)obj
Swift (since EasyAR SDK 2.1.0): public override func attachStreamer(_ obj: FrameStreamer?) -> Bool

start

Starts the track algorithm. The track will not actually start until a FrameStreamer is attached.

C: bool easyar_ObjectTracker_start(easyar_ObjectTracker * This)
C++11: bool start()
Traditional C++: bool start()
Java: public native boolean start()
Objective-C: - (bool)start
Swift (since EasyAR SDK 2.1.0): public override func start() -> Bool

stop

Stops the track algorithm. Call start to start the track again.

C: bool easyar_ObjectTracker_stop(easyar_ObjectTracker * This)
C++11: bool stop()
Traditional C++: bool stop()
Java: public native boolean stop()
Objective-C: - (bool)stop
Swift (since EasyAR SDK 2.1.0): public override func stop() -> Bool