CameraDevice Class

Description

CameraDevice implements a camera device, which outputs InputFrame (including image, camera paramters, and timestamp). It is available on Windows, Mac, Android and iOS.

After open, start/stop can be invoked to start or stop data collection. start/stop will not change previous set camera parameters.

When the component is not needed anymore, call close function to close it. It shall not be used after calling close.

CameraDevice outputs InputFrame from inputFrameSource. inputFrameSource shall be connected to InputFrameSink for use. Refer to Overview _ .

bufferCapacity is the capacity of InputFrame buffer. If the count of InputFrame which has been output from the device and have not been released is more than this number, the device will not output new InputFrame , until previous InputFrame have been released. This may cause screen stuck. Refer to Overview _ .

On Android, it is required to add android.permission.CAMERA to AndroidManifest.xml for use.

On iOS, it is required to add NSCameraUsageDescription to Info.plist for use.

Constructor

C

void easyar_CameraDevice__ctor(easyar_CameraDevice * * Return)

C++17

CameraDevice()

C++03

CameraDevice()

Java

public CameraDevice()

Kotlin

constructor()

Objective-C

+ (easyar_CameraDevice *) create

Swift

public convenience init()

C#

public CameraDevice()

isAvailable

Checks if the component is available. It returns true only on Windows, Mac, Android or iOS.

C

bool easyar_CameraDevice_isAvailable(void)

C++17

static bool isAvailable()

C++03

static bool isAvailable()

Java

public static boolean isAvailable()

Kotlin

companion object fun isAvailable(): Boolean

Objective-C

+ (bool)isAvailable

Swift

public static func isAvailable() -> Bool

C#

public static bool isAvailable()

androidCameraApiType

Gets current camera API (camera1 or camera2) on Android. camera1 is better for compatibility, but lacks some necessary information such as timestamp. camera2 has compatibility issues on some devices.

C

easyar_AndroidCameraApiType easyar_CameraDevice_androidCameraApiType(easyar_CameraDevice * This)

C++17

AndroidCameraApiType androidCameraApiType()

C++03

AndroidCameraApiType androidCameraApiType()

Java

public int androidCameraApiType()

Kotlin

fun androidCameraApiType(): Int

Objective-C

- (easyar_AndroidCameraApiType)androidCameraApiType

Swift

public func androidCameraApiType() -> AndroidCameraApiType

C#

public virtual AndroidCameraApiType androidCameraApiType()

setAndroidCameraApiType

Sets current camera API (camera1 or camera2) on Android. It must be called before calling openWithIndex, openWithSpecificType or openWithPreferredType, or it will not take effect.

It is recommended to use CameraDeviceSelector to create camera with camera API set to recommended based on primary algorithm to run.

C

void easyar_CameraDevice_setAndroidCameraApiType(easyar_CameraDevice * This, easyar_AndroidCameraApiType type)

C++17

void setAndroidCameraApiType(AndroidCameraApiType type)

C++03

void setAndroidCameraApiType(AndroidCameraApiType type)

Java

public void setAndroidCameraApiType(int type)

Kotlin

fun setAndroidCameraApiType(type: Int): Unit

Objective-C

- (void)setAndroidCameraApiType:(easyar_AndroidCameraApiType)type

Swift

public func setAndroidCameraApiType(_ type: AndroidCameraApiType) -> Void

C#

public virtual void setAndroidCameraApiType(AndroidCameraApiType type)

bufferCapacity

InputFrame buffer capacity. The default is 8.

C

int easyar_CameraDevice_bufferCapacity(const easyar_CameraDevice * This)

C++17

int bufferCapacity()

C++03

int bufferCapacity()

Java

public int bufferCapacity()

Kotlin

fun bufferCapacity(): Int

Objective-C

- (int)bufferCapacity

Swift

public func bufferCapacity() -> Int32

C#

public virtual int bufferCapacity()

setBufferCapacity

Sets InputFrame buffer capacity.

C

void easyar_CameraDevice_setBufferCapacity(easyar_CameraDevice * This, int capacity)

C++17

void setBufferCapacity(int capacity)

C++03

void setBufferCapacity(int capacity)

Java

public void setBufferCapacity(int capacity)

Kotlin

fun setBufferCapacity(capacity: Int): Unit

Objective-C

- (void)setBufferCapacity:(int)capacity

Swift

public func setBufferCapacity(_ capacity: Int32) -> Void

C#

public virtual void setBufferCapacity(int capacity)

inputFrameSource

InputFrame output port.

C

void easyar_CameraDevice_inputFrameSource(easyar_CameraDevice * This, easyar_InputFrameSource * * Return)

C++17

std::shared_ptr<InputFrameSource> inputFrameSource()

C++03

void inputFrameSource(InputFrameSource * * Return)

Java

public @Nonnull InputFrameSource inputFrameSource()

Kotlin

fun inputFrameSource(): InputFrameSource

Objective-C

- (easyar_InputFrameSource *)inputFrameSource

Swift

public func inputFrameSource() -> InputFrameSource

C#

public virtual InputFrameSource inputFrameSource()

setStateChangedCallback

Sets callback on state change to notify state of camera disconnection or preemption. It is only available on Windows.

C

void easyar_CameraDevice_setStateChangedCallback(easyar_CameraDevice * This, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromCameraState stateChangedCallback)

C++17

void setStateChangedCallback(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(CameraState)>> stateChangedCallback)

C++03

void setStateChangedCallback(CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromCameraState stateChangedCallback)

Java

public void setStateChangedCallback(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromCameraState stateChangedCallback)

Kotlin

fun setStateChangedCallback(callbackScheduler: CallbackScheduler, stateChangedCallback: FunctorOfVoidFromCameraState?): Unit

Objective-C

- (void)setStateChangedCallback:(easyar_CallbackScheduler *)callbackScheduler stateChangedCallback:(void (^)(easyar_CameraState))stateChangedCallback

Swift

public func setStateChangedCallback(_ callbackScheduler: CallbackScheduler, _ stateChangedCallback: ((CameraState) -> Void)?) -> Void

C#

public virtual void setStateChangedCallback(CallbackScheduler callbackScheduler, Optional<Action<CameraState>> stateChangedCallback)

requestPermissions

Requests camera permission from operating system. You can call this function or request permission directly from operating system. It is only available on Android and iOS. On other platforms, it will call the callback directly with status being granted. This function need to be called from the UI thread.

C

void easyar_CameraDevice_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)

C++17

static void requestPermissions(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(PermissionStatus, std::string)>> permissionCallback)

C++03

static void requestPermissions(CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)

Java

public static void requestPermissions(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromPermissionStatusAndString permissionCallback)

Kotlin

companion object fun requestPermissions(callbackScheduler: CallbackScheduler, permissionCallback: FunctorOfVoidFromPermissionStatusAndString?): Unit

Objective-C

+ (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback

Swift

public static func requestPermissions(_ callbackScheduler: CallbackScheduler, _ permissionCallback: ((PermissionStatus, String) -> Void)?) -> Void

C#

public static void requestPermissions(CallbackScheduler callbackScheduler, Optional<Action<PermissionStatus, string>> permissionCallback)

cameraCount

Gets count of cameras recognized by the operating system.

C

int easyar_CameraDevice_cameraCount(void)

C++17

static int cameraCount()

C++03

static int cameraCount()

Java

public static int cameraCount()

Kotlin

companion object fun cameraCount(): Int

Objective-C

+ (int)cameraCount

Swift

public static func cameraCount() -> Int32

C#

public static int cameraCount()

openWithIndex

Opens a camera by index.

C

bool easyar_CameraDevice_openWithIndex(easyar_CameraDevice * This, int cameraIndex)

C++17

bool openWithIndex(int cameraIndex)

C++03

bool openWithIndex(int cameraIndex)

Java

public boolean openWithIndex(int cameraIndex)

Kotlin

fun openWithIndex(cameraIndex: Int): Boolean

Objective-C

- (bool)openWithIndex:(int)cameraIndex

Swift

public func openWithIndex(_ cameraIndex: Int32) -> Bool

C#

public virtual bool openWithIndex(int cameraIndex)

openWithSpecificType

Opens a camera by specific camera device type. If no camera is matched, false will be returned. On Mac, camera device types can not be distinguished.

C

bool easyar_CameraDevice_openWithSpecificType(easyar_CameraDevice * This, easyar_CameraDeviceType type)

C++17

bool openWithSpecificType(CameraDeviceType type)

C++03

bool openWithSpecificType(CameraDeviceType type)

Java

public boolean openWithSpecificType(int type)

Kotlin

fun openWithSpecificType(type: Int): Boolean

Objective-C

- (bool)openWithSpecificType:(easyar_CameraDeviceType)type

Swift

public func openWithSpecificType(_ type: CameraDeviceType) -> Bool

C#

public virtual bool openWithSpecificType(CameraDeviceType type)

openWithPreferredType

Opens a camera by camera device type. If no camera is matched, the first camera will be used.

C

bool easyar_CameraDevice_openWithPreferredType(easyar_CameraDevice * This, easyar_CameraDeviceType type)

C++17

bool openWithPreferredType(CameraDeviceType type)

C++03

bool openWithPreferredType(CameraDeviceType type)

Java

public boolean openWithPreferredType(int type)

Kotlin

fun openWithPreferredType(type: Int): Boolean

Objective-C

- (bool)openWithPreferredType:(easyar_CameraDeviceType)type

Swift

public func openWithPreferredType(_ type: CameraDeviceType) -> Bool

C#

public virtual bool openWithPreferredType(CameraDeviceType type)

start

Starts video stream capture.

C

bool easyar_CameraDevice_start(easyar_CameraDevice * This)

C++17

bool start()

C++03

bool start()

Java

public boolean start()

Kotlin

fun start(): Boolean

Objective-C

- (bool)start

Swift

public func start() -> Bool

C#

public virtual bool start()

stop

Stops video stream capture. It will only stop capture and will not change previous set camera parameters and connection.

C

void easyar_CameraDevice_stop(easyar_CameraDevice * This)

C++17

void stop()

C++03

void stop()

Java

public void stop()

Kotlin

fun stop(): Unit

Objective-C

- (void)stop

Swift

public func stop() -> Void

C#

public virtual void stop()

close

Close. The component shall not be used after calling close.

C

void easyar_CameraDevice_close(easyar_CameraDevice * This)

C++17

void close()

C++03

void close()

Java

public void close()

Kotlin

fun close(): Unit

Objective-C

- (void)close

Swift

public func close() -> Void

C#

public virtual void close()

index

Camera index.

C

int easyar_CameraDevice_index(const easyar_CameraDevice * This)

C++17

int index()

C++03

int index()

Java

public int index()

Kotlin

fun index(): Int

Objective-C

- (int)index

Swift

public func index() -> Int32

C#

public virtual int index()

type

Camera type.

C

easyar_CameraDeviceType easyar_CameraDevice_type(const easyar_CameraDevice * This)

C++17

CameraDeviceType type()

C++03

CameraDeviceType type()

Java

public int type()

Kotlin

fun type(): Int

Objective-C

- (easyar_CameraDeviceType)type

Swift

public func type() -> CameraDeviceType

C#

public virtual CameraDeviceType type()

cameraParameters

Camera parameters, including image size, focal length, principal point, camera type and camera rotation against natural orientation. Call after a successful open.

C

void easyar_CameraDevice_cameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * * Return)

C++17

std::shared_ptr<CameraParameters> cameraParameters()

C++03

void cameraParameters(CameraParameters * * Return)

Java

public @Nonnull CameraParameters cameraParameters()

Kotlin

fun cameraParameters(): CameraParameters

Objective-C

- (easyar_CameraParameters *)cameraParameters

Swift

public func cameraParameters() -> CameraParameters

C#

public virtual CameraParameters cameraParameters()

setCameraParameters

Sets camera parameters. Call after a successful open.

C

void easyar_CameraDevice_setCameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * cameraParameters)

C++17

void setCameraParameters(std::shared_ptr<CameraParameters> cameraParameters)

C++03

void setCameraParameters(CameraParameters * cameraParameters)

Java

public void setCameraParameters(@Nonnull CameraParameters cameraParameters)

Kotlin

fun setCameraParameters(cameraParameters: CameraParameters): Unit

Objective-C

- (void)setCameraParameters:(easyar_CameraParameters *)cameraParameters

Swift

public func setCameraParameters(_ cameraParameters: CameraParameters) -> Void

C#

public virtual void setCameraParameters(CameraParameters cameraParameters)

size

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

C

easyar_Vec2I easyar_CameraDevice_size(const easyar_CameraDevice * This)

C++17

Vec2I size()

C++03

Vec2I size()

Java

public @Nonnull Vec2I size()

Kotlin

fun size(): Vec2I

Objective-C

- (easyar_Vec2I *)size

Swift

public func size() -> Vec2I

C#

public virtual Vec2I size()

supportedSizeCount

Gets the number of supported preview sizes. Call after a successful open.

C

int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice * This)

C++17

int supportedSizeCount()

C++03

int supportedSizeCount()

Java

public int supportedSizeCount()

Kotlin

fun supportedSizeCount(): Int

Objective-C

- (int)supportedSizeCount

Swift

public func supportedSizeCount() -> Int32

C#

public virtual int supportedSizeCount()

supportedSize

Gets the index-th supported preview size. It returns {0, 0} if index is out of range. Call after a successful open.

C

easyar_Vec2I easyar_CameraDevice_supportedSize(const easyar_CameraDevice * This, int index)

C++17

Vec2I supportedSize(int index)

C++03

Vec2I supportedSize(int index)

Java

public @Nonnull Vec2I supportedSize(int index)

Kotlin

fun supportedSize(index: Int): Vec2I

Objective-C

- (easyar_Vec2I *)supportedSize:(int)index

Swift

public func supportedSize(_ index: Int32) -> Vec2I

C#

public virtual Vec2I supportedSize(int index)

setSize

Sets the preview size. The available nearest value will be selected. Call size to get the actual size. Call after a successful open. frameRateRange may change after calling setSize.

C

bool easyar_CameraDevice_setSize(easyar_CameraDevice * This, easyar_Vec2I size)

C++17

bool setSize(Vec2I size)

C++03

bool setSize(Vec2I size)

Java

public boolean setSize(@Nonnull Vec2I size)

Kotlin

fun setSize(size: Vec2I): Boolean

Objective-C

- (bool)setSize:(easyar_Vec2I *)size

Swift

public func setSize(_ size: Vec2I) -> Bool

C#

public virtual bool setSize(Vec2I size)

supportedFrameRateRangeCount

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

C

int easyar_CameraDevice_supportedFrameRateRangeCount(const easyar_CameraDevice * This)

C++17

int supportedFrameRateRangeCount()

C++03

int supportedFrameRateRangeCount()

Java

public int supportedFrameRateRangeCount()

Kotlin

fun supportedFrameRateRangeCount(): Int

Objective-C

- (int)supportedFrameRateRangeCount

Swift

public func supportedFrameRateRangeCount() -> Int32

C#

public virtual int supportedFrameRateRangeCount()

supportedFrameRateRangeLower

Gets range lower bound of the index-th supported frame rate range. Call after a successful open.

C

float easyar_CameraDevice_supportedFrameRateRangeLower(const easyar_CameraDevice * This, int index)

C++17

float supportedFrameRateRangeLower(int index)

C++03

float supportedFrameRateRangeLower(int index)

Java

public float supportedFrameRateRangeLower(int index)

Kotlin

fun supportedFrameRateRangeLower(index: Int): Float

Objective-C

- (float)supportedFrameRateRangeLower:(int)index

Swift

public func supportedFrameRateRangeLower(_ index: Int32) -> Float

C#

public virtual float supportedFrameRateRangeLower(int index)

supportedFrameRateRangeUpper

Gets range upper bound of the index-th supported frame rate range. Call after a successful open.

C

float easyar_CameraDevice_supportedFrameRateRangeUpper(const easyar_CameraDevice * This, int index)

C++17

float supportedFrameRateRangeUpper(int index)

C++03

float supportedFrameRateRangeUpper(int index)

Java

public float supportedFrameRateRangeUpper(int index)

Kotlin

fun supportedFrameRateRangeUpper(index: Int): Float

Objective-C

- (float)supportedFrameRateRangeUpper:(int)index

Swift

public func supportedFrameRateRangeUpper(_ index: Int32) -> Float

C#

public virtual float supportedFrameRateRangeUpper(int index)

frameRateRange

Gets current index of frame rate range. Call after a successful open.

C

int easyar_CameraDevice_frameRateRange(const easyar_CameraDevice * This)

C++17

int frameRateRange()

C++03

int frameRateRange()

Java

public int frameRateRange()

Kotlin

fun frameRateRange(): Int

Objective-C

- (int)frameRateRange

Swift

public func frameRateRange() -> Int32

C#

public virtual int frameRateRange()

setFrameRateRange

Sets current index of frame rate range. Call after a successful open.

C

bool easyar_CameraDevice_setFrameRateRange(easyar_CameraDevice * This, int index)

C++17

bool setFrameRateRange(int index)

C++03

bool setFrameRateRange(int index)

Java

public boolean setFrameRateRange(int index)

Kotlin

fun setFrameRateRange(index: Int): Boolean

Objective-C

- (bool)setFrameRateRange:(int)index

Swift

public func setFrameRateRange(_ index: Int32) -> Bool

C#

public virtual bool setFrameRateRange(int index)

setFlashTorchMode

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

C

bool easyar_CameraDevice_setFlashTorchMode(easyar_CameraDevice * This, bool on)

C++17

bool setFlashTorchMode(bool on)

C++03

bool setFlashTorchMode(bool on)

Java

public boolean setFlashTorchMode(boolean on)

Kotlin

fun setFlashTorchMode(on: Boolean): Boolean

Objective-C

- (bool)setFlashTorchMode:(bool)on

Swift

public func setFlashTorchMode(_ on: Bool) -> Bool

C#

public virtual bool setFlashTorchMode(bool on)

setFocusMode

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

C

bool easyar_CameraDevice_setFocusMode(easyar_CameraDevice * This, easyar_CameraDeviceFocusMode focusMode)

C++17

bool setFocusMode(CameraDeviceFocusMode focusMode)

C++03

bool setFocusMode(CameraDeviceFocusMode focusMode)

Java

public boolean setFocusMode(int focusMode)

Kotlin

fun setFocusMode(focusMode: Int): Boolean

Objective-C

- (bool)setFocusMode:(easyar_CameraDeviceFocusMode)focusMode

Swift

public func setFocusMode(_ focusMode: CameraDeviceFocusMode) -> Bool

C#

public virtual bool setFocusMode(CameraDeviceFocusMode focusMode)

autoFocus

Does auto focus once. Call after start. It is only available when FocusMode is Normal or Macro.

C

bool easyar_CameraDevice_autoFocus(easyar_CameraDevice * This)

C++17

bool autoFocus()

C++03

bool autoFocus()

Java

public boolean autoFocus()

Kotlin

fun autoFocus(): Boolean

Objective-C

- (bool)autoFocus

Swift

public func autoFocus() -> Bool

C#

public virtual bool autoFocus()