Table Of Contents

Previous topic

ImageTarget Class

Next topic

ImageTrackerMode Enum

ImageTracker Class

Inherits: TargetTracker

Description

An ImageTracker is a class for image target detection and tracking.

ImageTracker detects and tracks ImageTarget. 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_ImageTracker__ctor(easyar_ImageTracker** Return)
C++11: ImageTracker()
Traditional C++: ImageTracker()
Java: public ImageTracker()
Objective-C: + (easyar_ImageTracker *) create
Swift (since EasyAR SDK 2.1.0): public convenience init()

ImageTrackerMode.PreferQuality is the default mode.

createWithMode

C: void easyar_ImageTracker_createWithMode(easyar_ImageTrackerMode mode, easyar_ImageTracker** Return)
C++11: static std::shared_ptr<ImageTracker> createWithMode(ImageTrackerMode mode)
Traditional C++: static void createWithMode(ImageTrackerMode mode, ImageTracker** Return)
Java: public static native ImageTracker createWithMode(int mode)
Objective-C: + (easyar_ImageTracker *)createWithMode:(easyar_ImageTrackerMode)mode
Swift (since EasyAR SDK 2.1.0): public static func createWithMode(_ mode: ImageTrackerMode) -> ImageTracker

(since 2.2.0) In 2.2.0, we enhanced the quality of tracking, but it may be slower and cost more energy on low-end phones. You can use ImageTrackerMode.PreferPerformance to keep a better performance with a little quality loss.

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_ImageTracker_loadTarget(easyar_ImageTracker* 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_ImageTracker_unloadTarget(easyar_ImageTracker* 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_ImageTracker_loadTargetBlocked(easyar_ImageTracker* 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_ImageTracker_unloadTargetBlocked(easyar_ImageTracker* 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_ImageTracker_targets(easyar_ImageTracker* 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_ImageTracker_setSimultaneousNum(easyar_ImageTracker* 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_ImageTracker_simultaneousNum(easyar_ImageTracker* 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_ImageTracker_attachStreamer(easyar_ImageTracker* 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_ImageTracker_start(easyar_ImageTracker* 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_ImageTracker_stop(easyar_ImageTracker* 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