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++
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++
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++
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++
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++
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++
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++
std::shared_ptr<InputFrameSource> inputFrameSource()
- Java
public @Nonnull InputFrameSource inputFrameSource()
- Kotlin
fun inputFrameSource(): InputFrameSource
- Objective-C
- (easyar_InputFrameSource *)inputFrameSource
- Swift
public func inputFrameSource() -> InputFrameSource
- C#
public virtual InputFrameSource inputFrameSource()
inputFrameSourceType¶
InputFrame来源类型。
- C
easyar_InputFrameSourceType easyar_CameraDevice_inputFrameSourceType(easyar_CameraDevice * This)
- C++
InputFrameSourceType inputFrameSourceType()
- Java
public int inputFrameSourceType()
- Kotlin
fun inputFrameSourceType(): Int
- Objective-C
- (easyar_InputFrameSourceType)inputFrameSourceType
- Swift
public func inputFrameSourceType() -> InputFrameSourceType
- C#
public virtual InputFrameSourceType inputFrameSourceType()
setStateChangedCallback¶
设置状态变化回调以通知摄像机断开或被抢占的状态。只在Windows平台上有作用。
- C
void easyar_CameraDevice_setStateChangedCallback(easyar_CameraDevice * This, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromCameraState stateChangedCallback)
- C++
void setStateChangedCallback(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(CameraState)>> 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++
static void requestPermissions(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(PermissionStatus, std::string)>> 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++
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++
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++
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++
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++
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++
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++
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++
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++
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++
std::shared_ptr<CameraParameters> cameraParameters()
- 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++
void setCameraParameters(std::shared_ptr<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之后调用。
supportedSizeCount¶
获取当前设备支持的所有图像大小的个数。在成功的open之后调用。
- C
int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice * This)
- C++
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++
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++
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++
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++
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++
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++
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++
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++
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++
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++
bool autoFocus()
- Java
public boolean autoFocus()
- Kotlin
fun autoFocus(): Boolean
- Objective-C
- (bool)autoFocus
- Swift
public func autoFocus() -> Bool
- C#
public virtual bool autoFocus()