Getting Started with EasyAR
Header:#include "easyar/tracker.hpp" (until 1.2.1)
Header:#include "easyar/imagetracker.hpp" (since 1.3.0)
Inherits:RefBase

Description

An ImageTracker is a class for target detection and tracking.

ImageTracker detects and tracks ImageTarget. You need to call attachCamera to attach a CameraDevice to ImageTracker first, then the images from the CameraDevice 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 ImageTracker, 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 TargetLoadCallBack passed into the interfaces.

You can get a Frame by Augmenter::newFrame which contains current camera image and tracked AugmentedTarget.

Public Functions

ImageTracker()
~ImageTracker()
virtual boolattachCamera(const CameraDevice& obj)
virtual booldetachCamera(const CameraDevice& obj)
virtual boolstart()
virtual boolstop()
virtual voidloadTarget(const Target& obj, TargetLoadCallBack* callback = 0)
virtual boolloadTargetBlocked(const Target& obj)
virtual voidunloadTarget(const Target& obj, TargetLoadCallBack* callback = 0)
virtual boolunloadTargetBlocked(const Target& obj)
virtual TargetListtargets()
virtual boolsetSimultaneousNum(int num) (since 1.3.0)
virtual intsimultaneousNum() (since 1.3.0)

ImageTracker()

Creates a ImageTracker object.

virtual ~ImageTracker()

Destroys the ImageTracker object.

virtual bool attachCamera(const CameraDevice& obj)

Attach CameraDevice to the ImageTracker. ImageTracker will not start to track until a CameraDevice is attached.

virtual bool detachCamera(const CameraDevice& obj)

Detach CameraDevice from the ImageTracker. After detach, the ImageTracker will not accept images from the CameraDevice anymore and the track will stop if no CameraDevice is attached.

virtual bool start()

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

virtual bool stop()

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

virtual void loadTarget(const Target& obj, TargetLoadCallBack* callback = 0)

Load a Target into the tracker. A Target can only be tracked by ImageTracker 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 provide a non-null callback. The callback will be called from a different thread; it will not block the track thread or any other operations except other load/unload.

virtual bool loadTargetBlocked(const Target& obj)

Load a Target into the tracker. A Target can only be tracked by ImageTracker 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.

virtual void unloadTarget(const Target& obj, TargetLoadCallBack* callback = 0)

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 provide a non-null callback. The callback will be called from a different thread; it will not block the track thread or any other operations except other load/unload.

virtual bool unloadTargetBlocked(const Target& obj)

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.

virtual TargetList 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.

virtual bool setSimultaneousNum(int num) (since 1.3.0)

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

virtual int simultaneousNum() (since 1.3.0)

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