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++
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++
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++
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++
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++
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++
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++
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()
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++
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¶
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++
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¶
Gets count of cameras recognized by the operating system.
- 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¶
Opens a camera by index.
- 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¶
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++
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++
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++
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++
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++
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++
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++
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++
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¶
Sets camera parameters. Call after a successful 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¶
Gets the current preview size. Call after a successful open.
supportedSizeCount¶
Gets the number of supported preview sizes. Call after a successful 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¶
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++
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++
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++
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++
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++
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++
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++
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++
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++
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++
bool autoFocus()
- Java
public boolean autoFocus()
- Kotlin
fun autoFocus(): Boolean
- Objective-C
- (bool)autoFocus
- Swift
public func autoFocus() -> Bool
- C#
public virtual bool autoFocus()