ARX  1.0
The next-generation open source augmented reality toolkit.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ARController Class Reference

Wrapper for artoolkitX functionality. More...

#include <ARController.h>

Public Member Functions

 ARController ()
 Constructor. More...
 
 ~ARController ()
 Destructor. More...
 
const char * getARToolKitVersion ()
 Returns a string containing the artoolkitX version, such as "10.0.0". More...
 
int getError ()
 
bool initialiseBase ()
 Start trackable management so trackables can be added and removed. More...
 
std::shared_ptr< ARTrackerSquaregetSquareTracker ()
 
bool isInited ()
 Report whether artoolkit was initialized and a trackable can be added. More...
 
bool startRunning (const char *vconf, const char *cparaName, const char *cparaBuff, const long cparaBuffLen)
 Start video capture and tracking. More...
 
bool startRunningStereo (const char *vconfL, const char *cparaNameL, const char *cparaBuffL, const long cparaBuffLenL, const char *vconfR, const char *cparaNameR, const char *cparaBuffR, const long cparaBuffLenR, const char *transL2RName, const char *transL2RBuff, const long transL2RBuffLen)
 Start stereo video capture and tracking. More...
 
bool videoParameters (const int videoSourceIndex, int *width, int *height, AR_PIXEL_FORMAT *pixelFormat)
 Reports width, height and pixel format of a video source. More...
 
bool isRunning ()
 Returns true if video capture and tracking is running. More...
 
bool stopRunning ()
 Video capture and tracking stops, but trackables are still valid and can be configured. More...
 
bool shutdown ()
 Stop, if running. More...
 
bool projectionMatrix (const int videoSourceIndex, const ARdouble projectionNearPlane, const ARdouble projectionFarPlane, ARdouble proj[16])
 Populates the provided array with the ARToolKit projection matrix. More...
 
bool drawVideoInit (const int videoSourceIndex)
 
bool drawVideoSettings (const int videoSourceIndex, const int width, const int height, const bool rotate90, const bool flipH, const bool flipV, const ARVideoView::HorizontalAlignment hAlign, const ARVideoView::VerticalAlignment vAlign, const ARVideoView::ScalingMode scalingMode, int32_t viewport[4])
 
bool drawVideo (const int videoSourceIndex)
 
bool drawVideoFinal (const int videoSourceIndex)
 
int addTrackable (const std::string &cfgs)
 Adds a trackable as specified in the given configuration string. More...
 
bool removeTrackable (int UID)
 Removes the trackable with the given ID. More...
 
int removeAllTrackables ()
 Clears the collection of trackables. More...
 
unsigned int countTrackables () const
 Returns the number of currently loaded trackables. More...
 
unsigned int countTrackables (ARTrackable::TrackableType trackableType) const
 Returns the number of currently loaded trackables of the specified type. More...
 
ARTrackablegetTrackableAtIndex (unsigned int index)
 Returns the trackable at the specified index. More...
 
ARTrackablefindTrackable (int UID)
 Searches the collection of trackables for the given ID. More...
 
bool capture ()
 Requests the capture of a new frame from the video source(s). More...
 
bool updateTextureRGBA32 (const int videoSourceIndex, uint32_t *buffer)
 Asks the video source to push the most recent frame into the passed-in buffer. More...
 
bool update ()
 Performs tracking and updates all trackables. More...
 
bool updateDebugTexture32 (const int videoSourceIndex, uint32_t *buffer)
 Populates the provided buffer with the current contents of the debug image. More...
 
bool getPatternImage (int patternID, uint32_t *buffer)
 Populates the provided color buffer with the image for the specified pattern. More...
 
bool loadOpticalParams (const char *optical_param_name, const char *optical_param_buff, const long optical_param_buffLen, const ARdouble projectionNearPlane, const ARdouble projectionFarPlane, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16], ARdouble p[16])
 Loads an optical parameters structure from file or from buffer. More...
 

Detailed Description

Wrapper for artoolkitX functionality.

This class handles artoolkitX initialisation, updates, and cleanup. It maintains a collection of trackables, providing methods to add and remove them.

Constructor & Destructor Documentation

◆ ARController()

ARController::ARController ( )

Constructor.

◆ ~ARController()

ARController::~ARController ( )

Destructor.

Here is the call graph for this function:

Member Function Documentation

◆ addTrackable()

int ARController::addTrackable ( const std::string &  cfgs)

Adds a trackable as specified in the given configuration string.

The format of the string can be one of:

  • Square marker from pattern file: "single;pattern_file;pattern_width", e.g. "single;data/hiro.patt;80"
  • Square marker from pattern passed in config: "single_buffer;pattern_width;buffer=[]", e.g. "single_buffer;80;buffer=234 221 237..."
  • Square barcode marker: "single_barcode;barcode_id;pattern_width", e.g. "single_barcode;0;80"
  • Multi-square marker: "multi;config_file", e.g. "multi;data/multi/marker.dat"
  • Multi-square auto marker: "multi;origin_barcode_id;pattern_width", e.g. "multi;0;80.0"
  • NFT marker: "nft;nft_dataset_pathname", e.g. "nft;gibraltar"
Parameters
cfgsThe configuration string
Returns
The UID of the trackable instantiated based on the configuration string, or -1 if an error occurred.
Here is the call graph for this function:

◆ capture()

bool ARController::capture ( )

Requests the capture of a new frame from the video source(s).

In the case of stereo video sources, capture from both sources will be attempted.

Returns
The capture succeeded, or false if no frame was captured.
Here is the call graph for this function:

◆ countTrackables() [1/2]

unsigned int ARController::countTrackables ( ) const

Returns the number of currently loaded trackables.

Returns
The number of currently loaded trackables.

◆ countTrackables() [2/2]

unsigned int ARController::countTrackables ( ARTrackable::TrackableType  trackableType) const

Returns the number of currently loaded trackables of the specified type.

Returns
The number of currently loaded trackables.

◆ drawVideo()

bool ARController::drawVideo ( const int  videoSourceIndex)
Here is the call graph for this function:

◆ drawVideoFinal()

bool ARController::drawVideoFinal ( const int  videoSourceIndex)

◆ drawVideoInit()

bool ARController::drawVideoInit ( const int  videoSourceIndex)

◆ drawVideoSettings()

bool ARController::drawVideoSettings ( const int  videoSourceIndex,
const int  width,
const int  height,
const bool  rotate90,
const bool  flipH,
const bool  flipV,
const ARVideoView::HorizontalAlignment  hAlign,
const ARVideoView::VerticalAlignment  vAlign,
const ARVideoView::ScalingMode  scalingMode,
int32_t  viewport[4] 
)
Here is the call graph for this function:

◆ findTrackable()

ARTrackable * ARController::findTrackable ( int  UID)

Searches the collection of trackables for the given ID.

Parameters
UIDThe UID of the trackables to find
Returns
The found trackable, or NULL if no matching UID was found.

◆ getARToolKitVersion()

const char * ARController::getARToolKitVersion ( )

Returns a string containing the artoolkitX version, such as "10.0.0".

Returns
The artoolkitX version
Here is the call graph for this function:

◆ getError()

int ARController::getError ( )

◆ getPatternImage()

bool ARController::getPatternImage ( int  patternID,
uint32_t *  buffer 
)

Populates the provided color buffer with the image for the specified pattern.

Parameters
patternIDThe artoolkitX pattern ID to use
bufferThe color buffer to populate
Returns
true if successful, false if an error occurred

◆ getSquareTracker()

std::shared_ptr< ARTrackerSquare > ARController::getSquareTracker ( )
inline

◆ getTrackableAtIndex()

ARTrackable * ARController::getTrackableAtIndex ( unsigned int  index)

Returns the trackable at the specified index.

Parameters
index0-based index into the array of trackables.
Returns
The trackable, or NULL if no trackable exists at that index.

◆ initialiseBase()

bool ARController::initialiseBase ( )

Start trackable management so trackables can be added and removed.

Returns
true if initialisation was OK, false if an error occured.
Here is the call graph for this function:

◆ isInited()

bool ARController::isInited ( )

Report whether artoolkit was initialized and a trackable can be added.

Trackables can be added once basic initialisation has occurred.

Returns
true if adding a trackable is currently possible

◆ isRunning()

bool ARController::isRunning ( )

Returns true if video capture and tracking is running.

Returns
true if the video source(s) is/are open and returning frames, otherwise false.

◆ loadOpticalParams()

bool ARController::loadOpticalParams ( const char *  optical_param_name,
const char *  optical_param_buff,
const long  optical_param_buffLen,
const ARdouble  projectionNearPlane,
const ARdouble  projectionFarPlane,
ARdouble fovy_p,
ARdouble aspect_p,
ARdouble  m[16],
ARdouble  p[16] 
)

Loads an optical parameters structure from file or from buffer.

Parameters
optical_param_nameIf supplied, points to a buffer specifying the path to the optical parameters file (as generated by the calib_optical utility.)
optical_param_buffIf optical_param_name is NULL, the contents of this buffer will be interpreted as containing the contents of an optical parameters file.
optical_param_buffLenLength of the buffer specified in optical_param_buff. Ignored if optical_param_buff is NULL.
projectionNearPlaneIf p is non-NULL, near plane distance for projection matrix calculation.
projectionFarPlaneIf p is non-NULL, far plane distance for projection matrix calculation.
fovy_pPointer to an ARdouble, which will be filled with the field-of-view (Y axis) component of the optical parameters.
aspect_pPointer to an ARdouble, which will be filled with the aspect ratio (width / height) component of the optical parameters.
mPointer to an array of 16 ARdoubles, which will be filled with the transformation matrix component of the optical parameters.
p(Optional) May be NULL, or a pointer to an array of 16 ARdoubles, which will be filled with the perspective matrix calculated from fovy and aspect combined with the near and far projection values supplied in projectionNearPlane and projectionFarPlane.
Here is the call graph for this function:

◆ projectionMatrix()

bool ARController::projectionMatrix ( const int  videoSourceIndex,
const ARdouble  projectionNearPlane,
const ARdouble  projectionFarPlane,
ARdouble  proj[16] 
)

Populates the provided array with the ARToolKit projection matrix.

The projection matrix is computed once the video source has been opened, and camera parameters become available. If this method is called before this happens, then the passed array is untouched and the method will return false.

Parameters
videoSourceIndexIndex into an array of video sources, specifying which source should be queried.
projectionNearPlaneNear plane distance for projection matrix calculation.
projectionFarPlaneFar plane distance for projection matrix calculation.
projArray to populate with OpenGL compatible projection matrix
Returns
true if the projection matrix has been computed, otherwise false
Here is the call graph for this function:

◆ removeAllTrackables()

int ARController::removeAllTrackables ( )

Clears the collection of trackables.

Returns
The number of trackables removed
Here is the call graph for this function:

◆ removeTrackable()

bool ARController::removeTrackable ( int  UID)

Removes the trackable with the given ID.

Parameters
UIDThe UID of the trackable to remove
Returns
true if the trackable was removed, false if an error occurred.
Here is the call graph for this function:

◆ shutdown()

bool ARController::shutdown ( )

Stop, if running.

Remove all trackables, clean up all memory. Starting again from this state requires initialiseBase() to be called again.

Returns
true if shutdown was successful, otherwise false
Here is the call graph for this function:

◆ startRunning()

bool ARController::startRunning ( const char *  vconf,
const char *  cparaName,
const char *  cparaBuff,
const long  cparaBuffLen 
)

Start video capture and tracking.

(AR/NFT initialisation will begin on a subsequent call to update().)

Parameters
vconfVideo configuration string.
cparaNameCamera parameters filename, or NULL if camera parameters file not being used.
cparaBuffA byte-buffer containing contents of a camera parameters file, or NULL if a camera parameters file is being used.
cparaBuffLenLength (in bytes) of cparaBuffLen, or 0 if a camera parameters file is being used.
Returns
true if video capture and tracking was started, otherwise false.
Here is the call graph for this function:

◆ startRunningStereo()

bool ARController::startRunningStereo ( const char *  vconfL,
const char *  cparaNameL,
const char *  cparaBuffL,
const long  cparaBuffLenL,
const char *  vconfR,
const char *  cparaNameR,
const char *  cparaBuffR,
const long  cparaBuffLenR,
const char *  transL2RName,
const char *  transL2RBuff,
const long  transL2RBuffLen 
)

Start stereo video capture and tracking.

(AR/NFT initialisation will begin on a subsequent call to update().)

Parameters
vconfLVideo configuration string for the "left" video source.
cparaNameLCamera parameters filename for the "left" video source, or NULL if camera parameters file not being used.
cparaBuffLA byte-buffer containing contents of a camera parameters file for the "left" video source, or NULL if a camera parameters file is being used.
cparaBuffLenLLength (in bytes) of cparaBuffLenL, or 0 if a camera parameters file is being used.
vconfRVideo configuration string for the "right" video source.
cparaNameRCamera parameters filename for the "right" video source, or NULL if camera parameters file not being used.
cparaBuffRA byte-buffer containing contents of a camera parameters file for the "right" video source, or NULL if a camera parameters file is being used.
cparaBuffLenRLength (in bytes) of cparaBuffLenR, or 0 if a camera parameters file is being used.
transL2RNameStereo calibration filename, or NULL if stereo calibration file not being used.
transL2RBuffA byte-buffer containing contents of a stereo calibration file, or NULL if a stereo calibration file is being used.
transL2RBuffLenLength (in bytes) of transL2RBuff, or 0 if a stereo calibration file is being used.
Returns
true if video capture and tracking was started, otherwise false.
Here is the call graph for this function:

◆ stopRunning()

bool ARController::stopRunning ( )

Video capture and tracking stops, but trackables are still valid and can be configured.

Returns
true if video capture and tracking was stopped, otherwise false.
Here is the call graph for this function:

◆ update()

bool ARController::update ( )

Performs tracking and updates all trackables.

The latest frame from the current video source is retrieved and analysed. Each trackable in the collection is updated with new tracking information. The trackable info array is iterated over, and detected trackables are matched up with those in the trackable collection. Each matched trackable is updated with visibility and transformation information. Any trackables not detected are considered not currently visible.

Returns
true if update completed successfully, false if an error occurred
Here is the call graph for this function:

◆ updateDebugTexture32()

bool ARController::updateDebugTexture32 ( const int  videoSourceIndex,
uint32_t *  buffer 
)

Populates the provided buffer with the current contents of the debug image.

Parameters
videoSourceIndexIndex into an array of video sources, specifying which source should be queried.
bufferPointer to a buffer of pixels (of type 'uint32_t') to be filled. It is the caller's responsibility to ensure that the buffer is of sufficient size. The pixels are RGBA in little-endian systems, or ABGR in big-endian systems.

◆ updateTextureRGBA32()

bool ARController::updateTextureRGBA32 ( const int  videoSourceIndex,
uint32_t *  buffer 
)

Asks the video source to push the most recent frame into the passed-in buffer.

Parameters
videoSourceIndexIndex into an array of video sources, specifying which source should be queried.
bufferPointer to a buffer of pixels (of type 'uint32_t') to be filled. It is the caller's responsibility to ensure that the buffer is of sufficient size. The pixels are RGBA in little-endian systems, or ABGR in big-endian systems.
Here is the call graph for this function:

◆ videoParameters()

bool ARController::videoParameters ( const int  videoSourceIndex,
int *  width,
int *  height,
AR_PIXEL_FORMAT *  pixelFormat 
)

Reports width, height and pixel format of a video source.

To retrieve the size (in bytes) of each pixel, use arUtilGetPixelSize(*pixelFormat); To get a C-string with the name of the pixel format, use arUtilGetPixelFormatName(*pixelFormat);

Parameters
videoSourceIndexIndex into an array of video sources, specifying which source should be queried.
widthPointer to an int which will be filled with the width (in pixels) of the video frame, or NULL if this information is not required.
heightPointer to an int which will be filled with the height (in pixels) of the video frame, or NULL if this information is not required.
pixelFormatPointer to an AR_PIXEL_FORMAT which will be filled with the pixel format of the video frame, or NULL if this information is not required.
Returns
true if the video source(s) is/are open and returning frames, otherwise false.
Here is the call graph for this function:

The documentation for this class was generated from the following files: