CameraDevice Class

Description

CameraDevice实现了一个camera设备,输出 InputFrame (包含图像、摄像机参数和时间戳)。在Windows、Mac、Android和iOS上可用。

打开之后,可以调用start/stop来开始和停止采集数据。start/stop不会影响之前所设置的camera参数。

当不再需要该设备时,可以调用close对其进行关闭。close之后不应继续使用。

CameraDevice通过inputFrameSource输出 InputFrame ,应将inputFrameSource连接到 InputFrameSink 上进行使用。参考 概览 _ 。

bufferCapacity表示 InputFrame 缓冲的容量,如果有超过此数量的 InputFrame 从该设备中输出并且没有被释放,该设备将不再输出新的 InputFrame ,直到之前的 InputFrame 被释放。这可能造成画面卡住等问题。参考 概览 _ 。

Android使用时需要在AndroidManifest.xml中加入android.permission.CAMERA权限声明。

iOS使用时需要在Info.plist中加入NSCameraUsageDescription权限声明。

Constructor

C

void easyar_CameraDevice__ctor(easyar_CameraDevice * * Return)

C++17

CameraDevice()

C++03(Deprecated)

CameraDevice()

Java

public CameraDevice()

Kotlin

constructor()

Objective-C

+ (easyar_CameraDevice *) create

Swift

public convenience init()

C#

public CameraDevice()

isAvailable

检查是否可用。只在Windows、Mac、Android和iOS上返回true。

C

bool easyar_CameraDevice_isAvailable(void)

C++17

static bool isAvailable()

C++03(Deprecated)

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

在Android上,可用于获得使用的Camera API(camera1或camera2)。camera1兼容性较好,但缺乏一些必要的信息,如时间戳。camera2在部分设备上存在兼容性问题。

C

easyar_AndroidCameraApiType easyar_CameraDevice_androidCameraApiType(easyar_CameraDevice * This)

C++17

AndroidCameraApiType androidCameraApiType()

C++03(Deprecated)

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

在Android上,可用于设置使用的Camera API(Camera 1或Camera 2)。必须在调用openWithIndex、openWithSpecificType或openWithPreferredType之前进行设置,否则不会生效。

推荐使用 CameraDeviceSelector 以根据使用的主要算法来创建设好推荐Camera API的CameraDevice。

C

void easyar_CameraDevice_setAndroidCameraApiType(easyar_CameraDevice * This, easyar_AndroidCameraApiType type)

C++17

void setAndroidCameraApiType(AndroidCameraApiType type)

C++03(Deprecated)

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 缓冲的容量,默认值为8。

C

int easyar_CameraDevice_bufferCapacity(const easyar_CameraDevice * This)

C++17

int bufferCapacity()

C++03(Deprecated)

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

设置 InputFrame 缓冲的容量。

C

void easyar_CameraDevice_setBufferCapacity(easyar_CameraDevice * This, int capacity)

C++17

void setBufferCapacity(int capacity)

C++03(Deprecated)

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 输出端口。

C

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

C++17

std::shared_ptr<InputFrameSource> inputFrameSource()

C++03(Deprecated)

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

设置状态变化回调以通知摄像机断开或被抢占的状态。只在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(Deprecated)

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

请求camera系统权限。你可以选择使用这个函数或自己申请权限。只在Android和iOS平台上有效,其他平台上的行为为直接调用回调通知权限已授权。应在UI线程调用该函数。

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(Deprecated)

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

获得操作系统识别到的camera数量。

C

int easyar_CameraDevice_cameraCount(void)

C++17

static int cameraCount()

C++03(Deprecated)

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

按照camera索引打开camera设备。

C

bool easyar_CameraDevice_openWithIndex(easyar_CameraDevice * This, int cameraIndex)

C++17

bool openWithIndex(int cameraIndex)

C++03(Deprecated)

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

按照精确的camera设备类型打开camera设备,如果没有匹配的类型则会返回false。在Mac上,camera类型无法判别。

C

bool easyar_CameraDevice_openWithSpecificType(easyar_CameraDevice * This, easyar_CameraDeviceType type)

C++17

bool openWithSpecificType(CameraDeviceType type)

C++03(Deprecated)

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

按照camera设备类型打开camera设备,如果没有匹配的类型则会尝试打开第一个camera设备。

C

bool easyar_CameraDevice_openWithPreferredType(easyar_CameraDevice * This, easyar_CameraDeviceType type)

C++17

bool openWithPreferredType(CameraDeviceType type)

C++03(Deprecated)

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

开始采集数据。

C

bool easyar_CameraDevice_start(easyar_CameraDevice * This)

C++17

bool start()

C++03(Deprecated)

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

停止采集数据。这个方法只会停止捕获图像,所有参数和连接将不会受到影响。

C

void easyar_CameraDevice_stop(easyar_CameraDevice * This)

C++17

void stop()

C++03(Deprecated)

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

关闭camera。close之后不应继续使用。

C

void easyar_CameraDevice_close(easyar_CameraDevice * This)

C++17

void close()

C++03(Deprecated)

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

cameras索引。

C

int easyar_CameraDevice_index(const easyar_CameraDevice * This)

C++17

int index()

C++03(Deprecated)

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类型。

C

easyar_CameraDeviceType easyar_CameraDevice_type(const easyar_CameraDevice * This)

C++17

CameraDeviceType type()

C++03(Deprecated)

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参数,包括图像大小、焦距、主点、camera类型和camera相对设备自然方向的旋转角度。在成功的open之后调用。

C

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

C++17

std::shared_ptr<CameraParameters> cameraParameters()

C++03(Deprecated)

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

设置camera参数。在成功的open之后调用。

C

void easyar_CameraDevice_setCameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * cameraParameters)

C++17

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

C++03(Deprecated)

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

获取当前图像大小。在成功的open之后调用。

C

easyar_Vec2I easyar_CameraDevice_size(const easyar_CameraDevice * This)

C++17

Vec2I size()

C++03(Deprecated)

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

获取当前设备支持的所有图像大小的个数。在成功的open之后调用。

C

int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice * This)

C++17

int supportedSizeCount()

C++03(Deprecated)

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

获取当前设备支持的所有图像大小的第 index 个. 如果 index 超出范围则返回{0, 0}。在成功的open之后调用。

C

easyar_Vec2I easyar_CameraDevice_supportedSize(const easyar_CameraDevice * This, int index)

C++17

Vec2I supportedSize(int index)

C++03(Deprecated)

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

设置当前图像大小。最接近设置值的可选值将被使用。可以使用size来获取实际的大小。在成功的open之后调用。设置size后frameRateRange可能会发生变化。

C

bool easyar_CameraDevice_setSize(easyar_CameraDevice * This, easyar_Vec2I size)

C++17

bool setSize(Vec2I size)

C++03(Deprecated)

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

获取当前设备支持的所有帧率范围的个数。在成功的open之后调用。

C

int easyar_CameraDevice_supportedFrameRateRangeCount(const easyar_CameraDevice * This)

C++17

int supportedFrameRateRangeCount()

C++03(Deprecated)

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

获取当前设备支持的所有帧率范围的第 index 个的下界。在成功的open之后调用。

C

float easyar_CameraDevice_supportedFrameRateRangeLower(const easyar_CameraDevice * This, int index)

C++17

float supportedFrameRateRangeLower(int index)

C++03(Deprecated)

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

获取当前设备支持的所有帧率范围的第 index 个的上界。在成功的open之后调用。

C

float easyar_CameraDevice_supportedFrameRateRangeUpper(const easyar_CameraDevice * This, int index)

C++17

float supportedFrameRateRangeUpper(int index)

C++03(Deprecated)

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

获取当前设备的当前帧率范围的索引。在成功的open之后调用。

C

int easyar_CameraDevice_frameRateRange(const easyar_CameraDevice * This)

C++17

int frameRateRange()

C++03(Deprecated)

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

设置当前设备的当前帧率范围的索引。在成功的open之后调用。

C

bool easyar_CameraDevice_setFrameRateRange(easyar_CameraDevice * This, int index)

C++17

bool setFrameRateRange(int index)

C++03(Deprecated)

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

设置flash torch模式为on。在成功的open之后调用。

C

bool easyar_CameraDevice_setFlashTorchMode(easyar_CameraDevice * This, bool on)

C++17

bool setFlashTorchMode(bool on)

C++03(Deprecated)

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

设置对焦模式为focusMode。在成功的open之后调用。

C

bool easyar_CameraDevice_setFocusMode(easyar_CameraDevice * This, easyar_CameraDeviceFocusMode focusMode)

C++17

bool setFocusMode(CameraDeviceFocusMode focusMode)

C++03(Deprecated)

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

调用一次自动对焦。在start之后使用。仅在FocusMode为Normal或Macro时才能使用。

C

bool easyar_CameraDevice_autoFocus(easyar_CameraDevice * This)

C++17

bool autoFocus()

C++03(Deprecated)

bool autoFocus()

Java

public boolean autoFocus()

Kotlin

fun autoFocus(): Boolean

Objective-C

- (bool)autoFocus

Swift

public func autoFocus() -> Bool

C#

public virtual bool autoFocus()