Table of Contents

Class CameraDevice

Namespace
easyar

CameraDevice implements a camera device that outputs InputFrame (containing images, camera parameters, and timestamps). Available on Windows, Mac, Android, and iOS. After opening, you can call start/stop to begin and stop data acquisition. start/stop does not affect previously set camera parameters. When the device is no longer needed, you can call close to shut it down. Do not continue using it after close. CameraDevice outputs InputFrame through inputFrameSource; inputFrameSource should be connected to InputFrameSink for use. bufferCapacity represents the capacity of the InputFrame buffer. If more than this number of InputFrames are output from the device and not released, the device will stop outputting new InputFrames until previous ones are released. This may cause issues like frame freezing. On Android, you need to add the android.permission.CAMERA permission declaration in AndroidManifest.xml. On iOS, you need to add the NSCameraUsageDescription permission declaration in Info.plist.

CameraDevice

Constructors

CameraDevice

void easyar_CameraDevice__ctor(easyar_CameraDevice * * Return)
CameraDevice()
public CameraDevice()
constructor()
+ (easyar_CameraDevice *) create
public convenience init()
public CameraDevice()

Methods

isAvailable

Check if it is available. Returns true only on Windows, Mac, Android, and iOS.

bool easyar_CameraDevice_isAvailable(void)
static bool isAvailable()
public static boolean isAvailable()
companion object fun isAvailable(): Boolean
+ (bool)isAvailable
public static func isAvailable() -> Bool
public static bool isAvailable()

Returns

Boolean

androidCameraApiType

On Android, can be used to obtain the Camera API in use (camera1 or camera2). camera1 has better compatibility but lacks some necessary information, such as timestamps. camera2 has compatibility issues on some devices.

easyar_AndroidCameraApiType easyar_CameraDevice_androidCameraApiType(easyar_CameraDevice * This)
AndroidCameraApiType androidCameraApiType()
public int androidCameraApiType()
fun androidCameraApiType(): Int
- (easyar_AndroidCameraApiType)androidCameraApiType
public func androidCameraApiType() -> AndroidCameraApiType
public virtual AndroidCameraApiType androidCameraApiType()

Returns

AndroidCameraApiType

setAndroidCameraApiType

On Android, can be used to set the Camera API in use (Camera 1 or Camera 2). Must be set before calling openWithIndex, openWithSpecificType, or openWithPreferredType; otherwise, it will not take effect. It is recommended to use CameraDeviceSelector to create a CameraDevice with the recommended Camera API based on the main algorithm used.

void easyar_CameraDevice_setAndroidCameraApiType(easyar_CameraDevice * This, easyar_AndroidCameraApiType type)
void setAndroidCameraApiType(AndroidCameraApiType type)
public void setAndroidCameraApiType(int type)
fun setAndroidCameraApiType(type: Int): Unit
- (void)setAndroidCameraApiType:(easyar_AndroidCameraApiType)type
public func setAndroidCameraApiType(_ type: AndroidCameraApiType) -> Void
public virtual void setAndroidCameraApiType(AndroidCameraApiType type)

Parameters

type AndroidCameraApiType

Returns

Void

bufferCapacity

Capacity of the InputFrame buffer, default value is 8.

int easyar_CameraDevice_bufferCapacity(const easyar_CameraDevice * This)
int bufferCapacity()
public int bufferCapacity()
fun bufferCapacity(): Int
- (int)bufferCapacity
public func bufferCapacity() -> Int32
public virtual int bufferCapacity()

Returns

Int32

setBufferCapacity

Set the capacity of the InputFrame buffer.

void easyar_CameraDevice_setBufferCapacity(easyar_CameraDevice * This, int capacity)
void setBufferCapacity(int capacity)
public void setBufferCapacity(int capacity)
fun setBufferCapacity(capacity: Int): Unit
- (void)setBufferCapacity:(int)capacity
public func setBufferCapacity(_ capacity: Int32) -> Void
public virtual void setBufferCapacity(int capacity)

Parameters

capacity Int32

Returns

Void

inputFrameSource

Output port for InputFrame.

void easyar_CameraDevice_inputFrameSource(easyar_CameraDevice * This, easyar_InputFrameSource * * Return)
std::shared_ptr<InputFrameSource> inputFrameSource()
public @Nonnull InputFrameSource inputFrameSource()
fun inputFrameSource(): InputFrameSource
- (easyar_InputFrameSource *)inputFrameSource
public func inputFrameSource() -> InputFrameSource
public virtual InputFrameSource inputFrameSource()

Returns

InputFrameSource

setStateChangedCallback

Set a state change callback to notify when the camera is disconnected or preempted. Only effective on Windows platform.

void easyar_CameraDevice_setStateChangedCallback(easyar_CameraDevice * This, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromCameraState stateChangedCallback)
void setStateChangedCallback(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(CameraState)>> stateChangedCallback)
public void setStateChangedCallback(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromCameraState stateChangedCallback)
fun setStateChangedCallback(callbackScheduler: CallbackScheduler, stateChangedCallback: FunctorOfVoidFromCameraState?): Unit
- (void)setStateChangedCallback:(easyar_CallbackScheduler *)callbackScheduler stateChangedCallback:(void (^)(easyar_CameraState))stateChangedCallback
public func setStateChangedCallback(_ callbackScheduler: CallbackScheduler, _ stateChangedCallback: ((CameraState) -> Void)?) -> Void
public virtual void setStateChangedCallback(CallbackScheduler callbackScheduler, Optional<Action<CameraState>> stateChangedCallback)

Parameters

callbackScheduler CallbackScheduler
stateChangedCallback Optional<Action<CameraState>>

Returns

Void

requestPermissions

Request camera system permissions. You can choose to use this function or apply for permissions yourself. Only effective on Android and iOS platforms; on other platforms, it will directly call the callback to notify that permissions are granted. Should be called on the UI thread.

void easyar_CameraDevice_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)
static void requestPermissions(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(PermissionStatus, std::string)>> permissionCallback)
public static void requestPermissions(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromPermissionStatusAndString permissionCallback)
companion object fun requestPermissions(callbackScheduler: CallbackScheduler, permissionCallback: FunctorOfVoidFromPermissionStatusAndString?): Unit
+ (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback
public static func requestPermissions(_ callbackScheduler: CallbackScheduler, _ permissionCallback: ((PermissionStatus, String) -> Void)?) -> Void
public static void requestPermissions(CallbackScheduler callbackScheduler, Optional<Action<PermissionStatus, string>> permissionCallback)

Parameters

callbackScheduler CallbackScheduler
permissionCallback Optional<Action<PermissionStatus,String>>

Returns

Void

cameraCount

Obtain the number of cameras recognized by the operating system.

int easyar_CameraDevice_cameraCount(void)
static int cameraCount()
public static int cameraCount()
companion object fun cameraCount(): Int
+ (int)cameraCount
public static func cameraCount() -> Int32
public static int cameraCount()

Returns

Int32

openWithIndex

Open the camera device according to the camera index.

bool easyar_CameraDevice_openWithIndex(easyar_CameraDevice * This, int cameraIndex)
bool openWithIndex(int cameraIndex)
public boolean openWithIndex(int cameraIndex)
fun openWithIndex(cameraIndex: Int): Boolean
- (bool)openWithIndex:(int)cameraIndex
public func openWithIndex(_ cameraIndex: Int32) -> Bool
public virtual bool openWithIndex(int cameraIndex)

Parameters

cameraIndex Int32

Returns

Boolean

openWithSpecificType

Open the camera device with a specific camera device type; returns false if no matching type is found. On Mac, the camera type cannot be determined.

bool easyar_CameraDevice_openWithSpecificType(easyar_CameraDevice * This, easyar_CameraDeviceType type)
bool openWithSpecificType(CameraDeviceType type)
public boolean openWithSpecificType(int type)
fun openWithSpecificType(type: Int): Boolean
- (bool)openWithSpecificType:(easyar_CameraDeviceType)type
public func openWithSpecificType(_ type: CameraDeviceType) -> Bool
public virtual bool openWithSpecificType(CameraDeviceType type)

Parameters

type CameraDeviceType

Returns

Boolean

openWithPreferredType

Open the camera device with a camera device type; if no matching type is found, it will try to open the first camera device.

bool easyar_CameraDevice_openWithPreferredType(easyar_CameraDevice * This, easyar_CameraDeviceType type)
bool openWithPreferredType(CameraDeviceType type)
public boolean openWithPreferredType(int type)
fun openWithPreferredType(type: Int): Boolean
- (bool)openWithPreferredType:(easyar_CameraDeviceType)type
public func openWithPreferredType(_ type: CameraDeviceType) -> Bool
public virtual bool openWithPreferredType(CameraDeviceType type)

Parameters

type CameraDeviceType

Returns

Boolean

start

Start data acquisition.

bool easyar_CameraDevice_start(easyar_CameraDevice * This)
bool start()
public boolean start()
fun start(): Boolean
- (bool)start
public func start() -> Bool
public virtual bool start()

Returns

Boolean

stop

Stop data acquisition. This method only stops capturing images; all parameters and connections will not be affected.

void easyar_CameraDevice_stop(easyar_CameraDevice * This)
void stop()
public void stop()
fun stop(): Unit
- (void)stop
public func stop() -> Void
public virtual void stop()

Returns

Void

close

Close the camera. Do not continue using it after close.

void easyar_CameraDevice_close(easyar_CameraDevice * This)
void close()
public void close()
fun close(): Unit
- (void)close
public func close() -> Void
public virtual void close()

Returns

Void

index

Camera index. Call after a successful open.

int easyar_CameraDevice_index(const easyar_CameraDevice * This)
int index()
public int index()
fun index(): Int
- (int)index
public func index() -> Int32
public virtual int index()

Returns

Int32

type

Camera type. Call after a successful open.

easyar_CameraDeviceType easyar_CameraDevice_type(const easyar_CameraDevice * This)
CameraDeviceType type()
public int type()
fun type(): Int
- (easyar_CameraDeviceType)type
public func type() -> CameraDeviceType
public virtual CameraDeviceType type()

Returns

CameraDeviceType

cameraOrientation

The angle to rotate clockwise for the camera image to display in the device's natural orientation. Call after a successful open.

int easyar_CameraDevice_cameraOrientation(const easyar_CameraDevice * This)
int cameraOrientation()
public int cameraOrientation()
fun cameraOrientation(): Int
- (int)cameraOrientation
public func cameraOrientation() -> Int32
public virtual int cameraOrientation()

Returns

Int32

cameraParameters

Camera parameters, including image size, focal length, principal point, camera type, and camera rotation angle relative to the device's natural orientation. Call after a successful open.

void easyar_CameraDevice_cameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * * Return)
std::shared_ptr<CameraParameters> cameraParameters()
public @Nonnull CameraParameters cameraParameters()
fun cameraParameters(): CameraParameters
- (easyar_CameraParameters *)cameraParameters
public func cameraParameters() -> CameraParameters
public virtual CameraParameters cameraParameters()

Returns

CameraParameters

setCameraParameters

Set camera parameters. Call after a successful open.

void easyar_CameraDevice_setCameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * cameraParameters)
void setCameraParameters(std::shared_ptr<CameraParameters> cameraParameters)
public void setCameraParameters(@Nonnull CameraParameters cameraParameters)
fun setCameraParameters(cameraParameters: CameraParameters): Unit
- (void)setCameraParameters:(easyar_CameraParameters *)cameraParameters
public func setCameraParameters(_ cameraParameters: CameraParameters) -> Void
public virtual void setCameraParameters(CameraParameters cameraParameters)

Parameters

cameraParameters CameraParameters

Returns

Void

size

Get the current image size. Call after a successful open.

easyar_Vec2I easyar_CameraDevice_size(const easyar_CameraDevice * This)
Vec2I size()
public @Nonnull Vec2I size()
fun size(): Vec2I
- (easyar_Vec2I *)size
public func size() -> Vec2I
public virtual Vec2I size()

Returns

Vec2I

supportedSizeCount

Get the number of all image sizes supported by the current device. Call after a successful open.

int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice * This)
int supportedSizeCount()
public int supportedSizeCount()
fun supportedSizeCount(): Int
- (int)supportedSizeCount
public func supportedSizeCount() -> Int32
public virtual int supportedSizeCount()

Returns

Int32

supportedSize

Get the index-th of all image sizes supported by the current device. Returns {0, 0} if index is out of range. Call after a successful open.

easyar_Vec2I easyar_CameraDevice_supportedSize(const easyar_CameraDevice * This, int index)
Vec2I supportedSize(int index)
public @Nonnull Vec2I supportedSize(int index)
fun supportedSize(index: Int): Vec2I
- (easyar_Vec2I *)supportedSize:(int)index
public func supportedSize(_ index: Int32) -> Vec2I
public virtual Vec2I supportedSize(int index)

Parameters

index Int32

Returns

Vec2I

setSize

Set the current image size. The closest available option to the set value will be used. You can use size to get the actual size. Call after a successful open. Setting the size may change the frameRateRange.

bool easyar_CameraDevice_setSize(easyar_CameraDevice * This, easyar_Vec2I size)
bool setSize(Vec2I size)
public boolean setSize(@Nonnull Vec2I size)
fun setSize(size: Vec2I): Boolean
- (bool)setSize:(easyar_Vec2I *)size
public func setSize(_ size: Vec2I) -> Bool
public virtual bool setSize(Vec2I size)

Parameters

size Vec2I

Returns

Boolean

supportedFrameRateRangeCount

Get the number of all frame rate ranges supported by the current device. Call after a successful open.

int easyar_CameraDevice_supportedFrameRateRangeCount(const easyar_CameraDevice * This)
int supportedFrameRateRangeCount()
public int supportedFrameRateRangeCount()
fun supportedFrameRateRangeCount(): Int
- (int)supportedFrameRateRangeCount
public func supportedFrameRateRangeCount() -> Int32
public virtual int supportedFrameRateRangeCount()

Returns

Int32

supportedFrameRateRangeLower

Get the lower bound of the index-th frame rate range supported by the current device. Call after a successful open.

float easyar_CameraDevice_supportedFrameRateRangeLower(const easyar_CameraDevice * This, int index)
float supportedFrameRateRangeLower(int index)
public float supportedFrameRateRangeLower(int index)
fun supportedFrameRateRangeLower(index: Int): Float
- (float)supportedFrameRateRangeLower:(int)index
public func supportedFrameRateRangeLower(_ index: Int32) -> Float
public virtual float supportedFrameRateRangeLower(int index)

Parameters

index Int32

Returns

Single

supportedFrameRateRangeUpper

Get the upper bound of the index-th frame rate range supported by the current device. Call after a successful open.

float easyar_CameraDevice_supportedFrameRateRangeUpper(const easyar_CameraDevice * This, int index)
float supportedFrameRateRangeUpper(int index)
public float supportedFrameRateRangeUpper(int index)
fun supportedFrameRateRangeUpper(index: Int): Float
- (float)supportedFrameRateRangeUpper:(int)index
public func supportedFrameRateRangeUpper(_ index: Int32) -> Float
public virtual float supportedFrameRateRangeUpper(int index)

Parameters

index Int32

Returns

Single

frameRateRange

Get the index of the current frame rate range of the current device. Call after a successful open. On iOS/macOS, it may return -1, indicating non-fixed frame rate; you can use supportedFrameRateRangeLower and supportedFrameRateRangeUpper to get the minimum and maximum values.

int easyar_CameraDevice_frameRateRange(const easyar_CameraDevice * This)
int frameRateRange()
public int frameRateRange()
fun frameRateRange(): Int
- (int)frameRateRange
public func frameRateRange() -> Int32
public virtual int frameRateRange()

Returns

Int32

setFrameRateRange

Set the index of the current frame rate range for the current device. Call after a successful open.

bool easyar_CameraDevice_setFrameRateRange(easyar_CameraDevice * This, int index)
bool setFrameRateRange(int index)
public boolean setFrameRateRange(int index)
fun setFrameRateRange(index: Int): Boolean
- (bool)setFrameRateRange:(int)index
public func setFrameRateRange(_ index: Int32) -> Bool
public virtual bool setFrameRateRange(int index)

Parameters

index Int32

Returns

Boolean

setFlashTorchMode

Set flash torch mode to on. Call after a successful open.

bool easyar_CameraDevice_setFlashTorchMode(easyar_CameraDevice * This, bool on)
bool setFlashTorchMode(bool on)
public boolean setFlashTorchMode(boolean on)
fun setFlashTorchMode(on: Boolean): Boolean
- (bool)setFlashTorchMode:(bool)on
public func setFlashTorchMode(_ on: Bool) -> Bool
public virtual bool setFlashTorchMode(bool on)

Parameters

on Boolean

Returns

Boolean

setFocusMode

Set focus mode to focusMode. Call after a successful open.

bool easyar_CameraDevice_setFocusMode(easyar_CameraDevice * This, easyar_CameraDeviceFocusMode focusMode)
bool setFocusMode(CameraDeviceFocusMode focusMode)
public boolean setFocusMode(int focusMode)
fun setFocusMode(focusMode: Int): Boolean
- (bool)setFocusMode:(easyar_CameraDeviceFocusMode)focusMode
public func setFocusMode(_ focusMode: CameraDeviceFocusMode) -> Bool
public virtual bool setFocusMode(CameraDeviceFocusMode focusMode)

Parameters

focusMode CameraDeviceFocusMode

Returns

Boolean

autoFocus

Trigger auto-focus once. Use after start. Can only be used when FocusMode is Normal or Macro.

bool easyar_CameraDevice_autoFocus(easyar_CameraDevice * This)
bool autoFocus()
public boolean autoFocus()
fun autoFocus(): Boolean
- (bool)autoFocus
public func autoFocus() -> Bool
public virtual bool autoFocus()

Returns

Boolean