CameraDevice Class

Inherits: Base

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{Normal, Triggerauto, Continousauto, Infinity, Macro}
enum Device{Default, Back, Front}

Public Properties

CameraCalibration Calibration
float FPS
bool IsOpened
Vector2I Size
float[] SupportedFPS
Vector2I[] SupportedSize
bool HorizontalFlip (since 1.3.0)

Public Functions

CameraDevice()
bool Open(Device camera = Device.Default)
bool Open(int camera) (since 1.3.0)
bool Close()
bool Start()
bool Stop()
bool SetFlashTorchMode(bool on)
bool SetFocusMode(FocusMode focusMode)

enum FocusMode

Constant

Value

Description

Normal

0

Normal auto focus mode. You should call SetFocusMode(FocusMode.Triggerauto) to start the focus in this mode.

Triggerauto

1

Triggers auto focus. Focus mode will be set to FocusMode.Normal.

Continousauto

2

Continuous auto focus mode.

Infinity

3

Infinity focus mode.

Macro

4

Macro (close-up) focus mode. You should call SetFocusMode(FocusMode.Triggerauto) to start the focus in this mode.

enum Device

Constant

Value

Description

Default

0

The default camera device.

Back

1

The back faced camera device.

Front

2

The front faced camera device.

bool IsOpened

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 FPS

Current frame rate. The proximal value available will be selected for set. Use after a successful Open.

float[] SupportedFPS

The supported frame rate. Use after a successful Open.

Vector2I Size

Current preview size. The proximal value available will be selected for set. Use after a successful Open.

Vector2I[] SupportedSize

The supported preview size. Use after a successful Open.

bool HorizontalFlip (since 1.3.0)

The horizontal flip flag. When set, the camera image will be horizontal flipped from default. Use after a successful Open.

CameraCalibration Calibration

Calibration data. Use after a successful Open.

bool Open(Device camera = Device.Default)

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

bool Open(int camera) (since 1.3.0)

Opens a camera with camera index. On desktop OSes, 0 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 lost attach to the CameraDevice and a reopen will not restore the connections.

bool Start()

Starts the capture.

bool Stop()

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

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.