| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ARVideoSource Class Reference

A video source provides video frames to the artoolkitX tracking module. More...

`#include <ARVideoSource.h>`

## Classes
struct | Size

## Public Types
enum class | ScalingMode { SCALE_MODE_STRETCH , SCALE_MODE_FIT , SCALE_MODE_FILL , SCALE_MODE_1_TO_1 }

## Public Member Functions
| ARVideoSource ()
| ~ARVideoSource ()
int | getError ()
bool | isOpen () const
| Returns true if the video source is open.
bool | isRunning () const
| Returns true if the video source is open and ready to be queried.
void | configure (const char *vconf, bool noCpara, const char *cparaName, const char *cparaBuff, size_t cparaBuffLen)
| Sets initial parameters which will be used when the video source is opened.
ARParamLT * | getCameraParameters () const
| Returns the camera parameters for the video source.
ARParam * | getCameraParametersForViewportSizeAndFittingMode (const Size viewportSize, const ScalingMode scalingMode)
| Adjust camera parameters to fit an output viewport of given size, using fitting and alignment.
int | getVideoWidth () const
| Returns the width of the video in pixels.
int | getVideoHeight () const
| Returns the height of the video in pixels.
AR_PIXEL_FORMAT | getPixelFormat () const
| Returns the pixel format of the video.
bool | open ()
| Opens the video source.
bool | close ()
| Closes the video source.
bool | captureFrame ()
| Asks the video source to capture a frame.
AR2VideoBufferT * | checkoutFrameIfNewerThan (const AR2VideoTimestampT time)
| Checkout a locked video frame if the frame's timestamp is newer than 'time'.
void | checkinFrame (void)
| Checkin a locked video frame.
AR2VideoParamT * | getAR2VideoParam (void)
| Get the underlying AR2VideoParamT settings structure.
bool | getFrameTextureRGBA32 (uint32_t *buffer)
| Populates the provided color buffer with the current video frame.
int | videoPushInit (int width, int height, const char *pixelFormat, int cameraIndex, int cameraPosition)
int | videoPush (ARUint8 *buf0p, int buf0Size, int buf0PixelStride, int buf0RowStride, ARUint8 *buf1p, int buf1Size, int buf1PixelStride, int buf1RowStride, ARUint8 *buf2p, int buf2Size, int buf2PixelStride, int buf2RowStride, ARUint8 *buf3p, int buf3Size, int buf3PixelStride, int buf3RowStride)
int | videoPushFinal (void)

## Static Public Member Functions
static const std::string | ScalingModeName (const ScalingMode scalingMode)

## Detailed Description

A video source provides video frames to the artoolkitX tracking module.

Video sources contain information about the video, such as size and pixel format, camera parameters for distortion compensation, as well as the raw video data itself.

## Member Enumeration Documentation

## ◆ ScalingMode

enum class ARVideoSource::ScalingMode
| strong

Enumerator
SCALE_MODE_STRETCH |
SCALE_MODE_FIT |
SCALE_MODE_FILL |
SCALE_MODE_1_TO_1 |

## Constructor & Destructor Documentation

## ◆ ARVideoSource()

ARVideoSource::ARVideoSource | ( |  | ) |

## ◆ ~ARVideoSource()

ARVideoSource::~ARVideoSource | ( |  | ) |

Here is the call graph for this function:

## Member Function Documentation

## ◆ captureFrame()

bool ARVideoSource::captureFrame | ( |  | ) |

Asks the video source to capture a frame.

Query the current video source for availability of a new frame, and if one is available, update the current video frame buffer to point to the new frame.

Returns
  true if the video source captured a frame, otherwise false

Here is the call graph for this function:

## ◆ checkinFrame()

void ARVideoSource::checkinFrame | ( | void |  | ) |

Checkin a locked video frame.

Each call to checkoutFrameIfNewerThan() which returns non-NULL MUST be balanced with a call to this function on the same thread.

See also
  checkoutFrameIfNewerThan

## ◆ checkoutFrameIfNewerThan()

AR2VideoBufferT * ARVideoSource::checkoutFrameIfNewerThan | ( | const AR2VideoTimestampT | time | ) |

Checkout a locked video frame if the frame's timestamp is newer than 'time'.

This function returns a pointer to the current video frame buffer, but only if the frame's timestamp is newer than the time passed in parameter 'time'. If the return value is non-NULL, the caller has non-exclusive read access to the frame buffer until the next call to checkinFrame(). If the return value is NULL, no further action is required. I.e. each call to this function which returns non-NULL MUST be balanced with a call to checkinFrame() on the same thread. Multiple callers may simultaneously checkout frames, but the next frame will not be made available until all callers have called checkinFrame() on the current frame. The function will block if the current video frame is currently being updated (or waiting to be updated) until the update is complete.

Parameters

  time | Timestamp of frame to compare. Passing a timestamp of {0, 0} will ensure that the timestamp test always passes.

Returns
  Pointer to the buffer containing the current video frame, if frame's timestamp is newer and a frame is available.

See also
  checkinFrame

## ◆ close()

bool ARVideoSource::close | ( |  | ) |

Closes the video source.

Returns
  true if the video source was closed successfully, otherwise false.

Here is the call graph for this function:

## ◆ configure()

void ARVideoSource::configure | ( | const char * | vconf,
|  | bool | noCpara,
|  | const char * | cparaName,
|  | const char * | cparaBuff,
|  | size_t | cparaBuffLen
| ) |  |

Sets initial parameters which will be used when the video source is opened.

Parameters

  vconf | Either NULL (the default), to use the default video configuration, or a C-string containing the video configuration to apply.
  noCpara | If false (the default), the default behaviour to determine the camera lens parameters for the video source will be followed. If true, the video source is treated as uncalibrated and attempts to retrieve the camera lens parameters will return NULL.
  cparaName | Either NULL (the default), to use the default method for camera lens parameter discovery, or a C-string containing the filesystem path to a camera lens parameter file.
  cparaBuff | Either NULL (the default), to use the default method for camera lens parameter discovery, or a pointer to an in-memory buffer containing the contents of a camera lens parameter file. If non-NULL, then parameter cparaBuffLen must hold the length of this buffer.
  cparaBuffLen | If parameter cparaBuff is NULL, this value is ignored. If parameter cparaBuff is non-NULL, this value must hold the length of the buffer pointed to by cparaBuff.

## ◆ getAR2VideoParam()

AR2VideoParamT * ARVideoSource::getAR2VideoParam | ( | void |  | ) |

Get the underlying AR2VideoParamT settings structure.

In some advanced circumstances, users might wish to make direct queries on the underlying AR2VideoParamT structure.

Returns
  A pointer to the structure. No guarantee about the lifetime or validity of the structure is made.

## ◆ getCameraParameters()

ARParamLT * ARVideoSource::getCameraParameters | ( |  | ) | const

Returns the camera parameters for the video source.

Returns
  The camera parameters, if some are available, or NULL if no parameters are available.

## ◆ getCameraParametersForViewportSizeAndFittingMode()

ARParam * ARVideoSource::getCameraParametersForViewportSizeAndFittingMode | ( | const Size | viewportSize,
|  | const ScalingMode | scalingMode
| ) |  |

Adjust camera parameters to fit an output viewport of given size, using fitting and alignment.

Here is the call graph for this function:

## ◆ getError()

int ARVideoSource::getError | ( |  | ) |

## ◆ getFrameTextureRGBA32()

bool ARVideoSource::getFrameTextureRGBA32 | ( | uint32_t * | buffer | ) |

Populates the provided color buffer with the current video frame.

Parameters

  buffer | The color buffer to populate with frame data

Returns
  true if the buffer was updated successfully, otherwise false

Here is the call graph for this function:

## ◆ getPixelFormat()

AR_PIXEL_FORMAT ARVideoSource::getPixelFormat | ( |  | ) | const

Returns the pixel format of the video.

Returns
  Pixel format of the video

## ◆ getVideoHeight()

int ARVideoSource::getVideoHeight | ( |  | ) | const

Returns the height of the video in pixels.

Returns
  Height of the video in pixels

## ◆ getVideoWidth()

int ARVideoSource::getVideoWidth | ( |  | ) | const

Returns the width of the video in pixels.

Returns
  Width of the video in pixels

## ◆ isOpen()

bool ARVideoSource::isOpen | ( |  | ) | const

Returns true if the video source is open.

Returns
  true if the video source is open

## ◆ isRunning()

bool ARVideoSource::isRunning | ( |  | ) | const

Returns true if the video source is open and ready to be queried.

Returns
  true if the video source is open and frame details are known

## ◆ open()

bool ARVideoSource::open | ( |  | ) |

Opens the video source.

Returns
  true if the video source was opened successfully, false if a fatal error occured.

Here is the call graph for this function:

## ◆ ScalingModeName()

static const std::string ARVideoSource::ScalingModeName | ( | const ScalingMode | scalingMode | ) |
| inline static

## ◆ videoPush()

int ARVideoSource::videoPush | ( | ARUint8 * | buf0p,
|  | int | buf0Size,
|  | int | buf0PixelStride,
|  | int | buf0RowStride,
|  | ARUint8 * | buf1p,
|  | int | buf1Size,
|  | int | buf1PixelStride,
|  | int | buf1RowStride,
|  | ARUint8 * | buf2p,
|  | int | buf2Size,
|  | int | buf2PixelStride,
|  | int | buf2RowStride,
|  | ARUint8 * | buf3p,
|  | int | buf3Size,
|  | int | buf3PixelStride,
|  | int | buf3RowStride
| ) |  |

Here is the call graph for this function:

## ◆ videoPushFinal()

int ARVideoSource::videoPushFinal | ( | void |  | ) |

Here is the call graph for this function:

## ◆ videoPushInit()

int ARVideoSource::videoPushInit | ( | int | width,
|  | int | height,
|  | const char * | pixelFormat,
|  | int | cameraIndex,
|  | int | cameraPosition
| ) |  |

Here is the call graph for this function:

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

- Source/ARX/include/ARX/ARVideoSource.h
- Source/ARX/ARVideoSource.cpp