CameraDevice Class

Header: #include "easyar/camera.hpp"

Inherits: RefBase

Description

CameraDevice is the class represent a device camera.

A CameraDevice works on its own thread. You can open/close a camera. You can also close and reopen a different camera with different input parameters at any point. start/stop is used to stat or stop the camera preview but keep pre-set camera parameters and algorithm connections. The control methods are similar to those provided in the system API.

CameraDevice is the input source of trackers and other algorithms. You should call open before any other methods, otherwise they will have no effect. All algorithms can only work after a CameraDevice is attached. If a CameraDevice is closed, all algorithms will lost attach to the CameraDevice and a reopen will not restore the connections.

Public Types

enum FocusMode{kFocusModeNormal, kFocusModeTriggerauto, kFocusModeContinousauto, kFocusModeInfinity, kFocusModeMacro}
enum Device{kDeviceDefault, kDeviceBack, kDeviceFront}

Public Functions

CameraDevice()
virtual ~CameraDevice()
bool open(int camera = kDeviceDefault)
bool close()
virtual bool start()
virtual bool stop()
bool isOpened()
float frameRate() const
int supportedFrameRateCount() const
float supportedFrameRate(int idx) const
bool setFrameRate(float fps)
Vec2I size() const
int supportedSizeCount() const
Vec2I supportedSize(int idx) const
bool setSize(Vec2I size)
CameraCalibration cameraCalibration() const
bool setFlashTorchMode(bool on)
bool setFocusMode(FocusMode focusMode)
void setHorizontalFlip(bool flip) (since 1.3.0)

enum CameraDevice::FocusMode

Constant

Value

Description

kFocusModeNormal

0

Normal auto focus mode. You should call setFocusMode(kFocusModeTriggerauto) to start the focus in this mode.

kFocusModeTriggerauto

1

Triggers auto focus. Focus mode will be set to kFocusModeNormal.

kFocusModeContinousauto

2

Continuous auto focus mode.

kFocusModeInfinity

3

Infinity focus mode.

kFocusModeMacro

4

Macro (close-up) focus mode. You should call setFocusMode(kFocusModeTriggerauto) to start the focus in this mode.

enum CameraDevice::Device

Constant

Value

Description

kDeviceDefault

0

The default camera device.

kDeviceBack

1

The back faced camera device.

kDeviceFront

2

The front faced camera device.

CameraDevice()

Creates a CameraDevice object.

virtual ~CameraDevice()

Destroys the CameraDevice object.

bool open(int camera = kDeviceDefault)

Opens a camera with camera device type. On desktop OSes, kDeviceDefault represents the default camera and the value > 0 represents the device number (start from 1).

bool close()

Closes a camera. If a CameraDevice is closed, all algorithms will lose attach to the CameraDevice and a reopen will not restore the connections.

virtual bool start()

Starts the capture.

virtual bool stop()

Stops the capture. Only stops the capture process, all parameters and connections with algorithms are kept unchanged.

bool isOpened()

Returns true if the CameraDevice is opened, false otherwise. It is useful for the functions getting parameters because only an opened camera will return valid values.

float frameRate() const

Gets the current frame rate. Use after a successful open.

int supportedFrameRateCount() const

Gets the number of supported frame rate. Use after a successful open.

float supportedFrameRate(int idx) const

Gets the supported frame rate of index idx . Returns 0 if idx is out of range. Use after a successful open.

bool setFrameRate(float fps)

Sets the frame rate. The proximal value available will be selected, use frameRate to get the frame rate. Use after a successful open.

Vec2I size() const

Gets the current preview size. Use after a successful open.

int supportedSizeCount() const

Gets the number of supported preview size. Use after a successful open.

Vec2I supportedSize(int idx) const

Gets the supported preview size of index idx . Returns {0, 0} if idx is out of range. Use after a successful open.

bool setSize(Vec2I size)

Sets the preview size. The proximal value available will be selected, use size to get the actual size. Use after a successful open.

CameraCalibration cameraCalibration() const

Gets calibration data. Use after a successful open.

bool setFlashTorchMode(bool on)

Sets flash torch mode to on . Use after a successful open.

bool setFocusMode(FocusMode focusMode)

Sets focus mode to focusMode . Use after start.

void setHorizontalFlip(bool flip) (since 1.3.0)

Set horizontal flip flag to the camera. When set, the camera image will be horizontal flipped from default. Use after a successful open.