![]() |
ARX
1.0
The next-generation open source augmented reality toolkit.
|
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< ARTrackerSquare > | getSquareTracker () |
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... | |
ARTrackable * | getTrackableAtIndex (unsigned int index) |
Returns the trackable at the specified index. More... | |
ARTrackable * | findTrackable (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... | |
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.
ARController::ARController | ( | ) |
Constructor.
ARController::~ARController | ( | ) |
Destructor.
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:
cfgs | The configuration string |
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.
unsigned int ARController::countTrackables | ( | ) | const |
Returns the number of currently loaded trackables.
unsigned int ARController::countTrackables | ( | ARTrackable::TrackableType | trackableType | ) | const |
Returns the number of currently loaded trackables of the specified type.
bool ARController::drawVideo | ( | const int | videoSourceIndex | ) |
bool ARController::drawVideoFinal | ( | const int | videoSourceIndex | ) |
bool ARController::drawVideoInit | ( | const int | videoSourceIndex | ) |
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] | ||
) |
ARTrackable * ARController::findTrackable | ( | int | UID | ) |
Searches the collection of trackables for the given ID.
UID | The UID of the trackables to find |
const char * ARController::getARToolKitVersion | ( | ) |
Returns a string containing the artoolkitX version, such as "10.0.0".
int ARController::getError | ( | ) |
bool ARController::getPatternImage | ( | int | patternID, |
uint32_t * | buffer | ||
) |
Populates the provided color buffer with the image for the specified pattern.
patternID | The artoolkitX pattern ID to use |
buffer | The color buffer to populate |
|
inline |
ARTrackable * ARController::getTrackableAtIndex | ( | unsigned int | index | ) |
Returns the trackable at the specified index.
index | 0-based index into the array of trackables. |
bool ARController::initialiseBase | ( | ) |
Start trackable management so trackables can be added and removed.
bool ARController::isInited | ( | ) |
Report whether artoolkit was initialized and a trackable can be added.
Trackables can be added once basic initialisation has occurred.
bool ARController::isRunning | ( | ) |
Returns true if video capture and tracking is running.
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.
optical_param_name | If supplied, points to a buffer specifying the path to the optical parameters file (as generated by the calib_optical utility.) |
optical_param_buff | If optical_param_name is NULL, the contents of this buffer will be interpreted as containing the contents of an optical parameters file. |
optical_param_buffLen | Length of the buffer specified in optical_param_buff. Ignored if optical_param_buff is NULL. |
projectionNearPlane | If p is non-NULL, near plane distance for projection matrix calculation. |
projectionFarPlane | If p is non-NULL, far plane distance for projection matrix calculation. |
fovy_p | Pointer to an ARdouble, which will be filled with the field-of-view (Y axis) component of the optical parameters. |
aspect_p | Pointer to an ARdouble, which will be filled with the aspect ratio (width / height) component of the optical parameters. |
m | Pointer 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. |
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.
videoSourceIndex | Index into an array of video sources, specifying which source should be queried. |
projectionNearPlane | Near plane distance for projection matrix calculation. |
projectionFarPlane | Far plane distance for projection matrix calculation. |
proj | Array to populate with OpenGL compatible projection matrix |
int ARController::removeAllTrackables | ( | ) |
Clears the collection of trackables.
bool ARController::removeTrackable | ( | int | UID | ) |
Removes the trackable with the given ID.
UID | The UID of the trackable to remove |
bool ARController::shutdown | ( | ) |
Stop, if running.
Remove all trackables, clean up all memory. Starting again from this state requires initialiseBase() to be called again.
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().)
vconf | Video configuration string. |
cparaName | Camera parameters filename, or NULL if camera parameters file not being used. |
cparaBuff | A byte-buffer containing contents of a camera parameters file, or NULL if a camera parameters file is being used. |
cparaBuffLen | Length (in bytes) of cparaBuffLen, or 0 if a camera parameters file is being used. |
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().)
vconfL | Video configuration string for the "left" video source. |
cparaNameL | Camera parameters filename for the "left" video source, or NULL if camera parameters file not being used. |
cparaBuffL | A byte-buffer containing contents of a camera parameters file for the "left" video source, or NULL if a camera parameters file is being used. |
cparaBuffLenL | Length (in bytes) of cparaBuffLenL, or 0 if a camera parameters file is being used. |
vconfR | Video configuration string for the "right" video source. |
cparaNameR | Camera parameters filename for the "right" video source, or NULL if camera parameters file not being used. |
cparaBuffR | A byte-buffer containing contents of a camera parameters file for the "right" video source, or NULL if a camera parameters file is being used. |
cparaBuffLenR | Length (in bytes) of cparaBuffLenR, or 0 if a camera parameters file is being used. |
transL2RName | Stereo calibration filename, or NULL if stereo calibration file not being used. |
transL2RBuff | A byte-buffer containing contents of a stereo calibration file, or NULL if a stereo calibration file is being used. |
transL2RBuffLen | Length (in bytes) of transL2RBuff, or 0 if a stereo calibration file is being used. |
bool ARController::stopRunning | ( | ) |
Video capture and tracking stops, but trackables are still valid and can be configured.
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.
bool ARController::updateDebugTexture32 | ( | const int | videoSourceIndex, |
uint32_t * | buffer | ||
) |
Populates the provided buffer with the current contents of the debug image.
videoSourceIndex | Index into an array of video sources, specifying which source should be queried. |
buffer | Pointer 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. |
bool ARController::updateTextureRGBA32 | ( | const int | videoSourceIndex, |
uint32_t * | buffer | ||
) |
Asks the video source to push the most recent frame into the passed-in buffer.
videoSourceIndex | Index into an array of video sources, specifying which source should be queried. |
buffer | Pointer 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. |
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);
videoSourceIndex | Index into an array of video sources, specifying which source should be queried. |
width | Pointer to an int which will be filled with the width (in pixels) of the video frame, or NULL if this information is not required. |
height | Pointer to an int which will be filled with the height (in pixels) of the video frame, or NULL if this information is not required. |
pixelFormat | Pointer 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. |