Reference

Functions

std::shared_ptr<DXCamera> DXCam::create(int device_idx = 0, int output_idx = -1, size_t max_buffer_len = 64)

Create a DXCamera instance which captures the full screen by default.

Parameters:
  • device_idx[in] The index of the device to be used. Call get_devices_info() to list all devices.

  • output_idx[in] The index of the monitor to be used. Call get_outputs_info() to list all outputs.

  • max_buffer_len[in] The size of the frame buffer.

Returns:

A shared pointer to the DXCamera instance. If there exists an instance with the same device and output, the shared pointer to the existing instance will be returned.

std::shared_ptr<DXCamera> DXCam::create(const Region &region, int device_idx = 0, int output_idx = -1, size_t max_buffer_len = 64)

Create a DXCamera instance which captures a rectangle region by default.

Parameters:
  • region[in] The rectangle region to be captured.

  • device_idx[in] The index of the device to be used. Call get_devices_info() to list all devices.

  • output_idx[in] The index of the monitor to be used. Call get_outputs_info() to list all outputs.

  • max_buffer_len[in] The size of the frame buffer.

Returns:

A shared pointer to the DXCamera instance. If there exists an instance with the same device and output, the shared pointer to the existing instance will be returned.

std::vector<DeviceInfo> DXCam::get_devices_info()

List all devices.

Returns:

A vector of DeviceInfo.

std::vector<std::vector<OutputInfo>> DXCam::get_outputs_info()

List all outputs.

Returns:

A vector of vectors containing OutputInfo. The first dimension represents devices, and the second dimension represents outputs of that device.

Structs

struct DeviceInfo

The information of a device, i.e. graphics card.

Public Members

std::wstring description

The description of the device.

SIZE_T vram_size

The size of the VRAM in MiB.

UINT vendor_id

The vendor ID of the device.

struct OutputInfo

The information of an output, i.e. screen.

Public Members

std::wstring device_name

The name of the device.

LONG width

The width of the output.

LONG height

The height of the output.

int rotation_angle

The rotation angle of the output.

bool is_primary

Indicates if the output is the primary display.

Classes

class DXCamera

Public Functions

long get_width() const

Get the width of the region being captured.

Returns:

The width in pixels.

long get_height() const

Get the height of the region being captured.

Returns:

The height in pixels.

int get_rotation_angle() const

Get the rotation angle of the screen being captured.

Returns:

The rotation angle in degrees.

const Region &get_region() const

Get the region being captured.

Returns:

The region object.

size_t get_buffer_len() const

Get the size of the frame buffer in continuous capturing mode.

Returns:

The length of the frame buffer.

bool is_capturing() const

Check if the camera is currently capturing.

Returns:

True if capturing, false otherwise.

cv::Mat grab()

Grab the default region instantly.

Returns:

a Mat object, containing the captured image.

cv::Mat grab(const Region &region)

Grab the specified region instantly.

Parameters:

region[in] The rectangle region to be captured.

Returns:

a Mat object, containing the captured image.

void start(int target_fps = 60, bool video_mode = false, int delay = 0)

Start capturing the default region.

Parameters:
  • target_fps[in] The target FPS.

  • video_mode[in] If true, a frame will always be pushed to the frame buffer at the target FPS even if there is no a new frame available. If false, only new frames will be pushed to the frame buffer.

  • delay[in] The delay in seconds before capturing starts.

void start(const Region &region, int target_fps = 60, bool video_mode = false, int delay = 0)

Start capturing the specified region.

Parameters:
  • region[in] The rectangle region to be captured.

  • target_fps[in] The target FPS.

  • video_mode[in] If true, a frame will always be pushed to the frame buffer at the target FPS even if there is no a new frame available. If false, only new frames will be pushed to the frame buffer.

  • delay[in] The delay in seconds before capturing starts.

void stop()

Stop capturing.

cv::Mat get_latest_frame()

Get the latest frame from the frame buffer.

Returns:

a Mat object, containing the latest frame in the frame buffer.

void get_frame_buffer(const cv::Mat *const **frame_buffer, std::mutex *const **frame_buffer_mutex, const size_t **len, const std::atomic<int> **head, const std::atomic<int> **tail, const std::atomic<bool> **full, std::mutex **frame_buffer_all_mutex)

Get the pointers to access the frame buffer, which is a circular queue.

If you want to access the whole frame buffer, you should lock frame_buffer_all_mutex. If you want to access a single frame, you should lock the corresponding mutex in frame_buffer_mutex.

Parameters:
  • frame_buffer[out] The pointer to (the pointer to the first element of) the frame buffer array.

  • frame_buffer_mutex[out] The pointer to (the pointer to the first element of) the array of the mutex of single frames.

  • len[out] The pointer to the length of the frame buffer.

  • head[out] The pointer to the index of the oldest frame in the frame buffer.

  • tail[out] The pointer to the index of the next frame of the latest frame in the frame buffer.

  • full[out] The pointer to the flag indicating whether the frame buffer is full.

  • frame_buffer_all_mutex[out] The pointer to the mutex of the frame buffer.

class Region

Represents a rectangular region.

Public Functions

int get_width() const

Get the width of the region.

Returns:

The width of the region.

int get_height() const

Get the height of the region.

Returns:

The height of the region.

Public Members

int left

The coordinate of the left boundary of the region.

int top

The coordinate of the top boundary of the region.

int right

The coordinate of the right boundary of the region.

int bottom

The coordinate of the bottom boundary of the region.