Table Of Contents

Previous topic

CameraCalibration Class

Next topic

CameraDeviceFocusMode Enum

CameraDevice Class

Description

CameraDevice is the class represent a device camera.

You can open/close a camera. You can also close and reopen a different camera with different input parameters at any point. start/stop is used to stat or stop the camera preview but keep pre-set camera parameters. The control methods are similar to those provided in the system API.

CameraDevice is the input source of CameraFrameStreamer. You should call open before any other methods, otherwise they will have no effect. CameraFrameStreamer can only work after a CameraDevice is attached. Close and reopen camera will not breake connections with CameraFrameStreamer.

Constructor

C: void easyar_CameraDevice__ctor(easyar_CameraDevice** Return)
C++11: CameraDevice()
Traditional C++: CameraDevice()
Java: public CameraDevice()
Objective-C: + (easyar_CameraDevice *) create
Swift (since EasyAR SDK 2.1.0): public convenience init()

start

Starts the capture.

C: bool easyar_CameraDevice_start(easyar_CameraDevice* This)
C++11: bool start()
Traditional C++: bool start()
Java: public native boolean start()
Objective-C: - (bool)start
Swift (since EasyAR SDK 2.1.0): public func start() -> Bool

stop

Stops the capture. Only stops the capture process, all parameters and connections with CameraFrameStreamer are kept unchanged.

C: bool easyar_CameraDevice_stop(easyar_CameraDevice* This)
C++11: bool stop()
Traditional C++: bool stop()
Java: public native boolean stop()
Objective-C: - (bool)stop
Swift (since EasyAR SDK 2.1.0): public func stop() -> Bool

requestPermissions

Request platform permission for camera. You can choose to call this or request permissions by yourself.

C: void easyar_CameraDevice_requestPermissions(easyar_CameraDevice* This, easyar_FunctorOfVoidFromPermissionStatusAndString permissionCallback)
C++11: void requestPermissions(std::function<void(PermissionStatus, std::string)> permissionCallback)
Traditional C++: void requestPermissions(FunctorOfVoidFromPermissionStatusAndString permissionCallback)
Java: public native void requestPermissions(FunctorOfVoidFromPermissionStatusAndString permissionCallback)
Objective-C: - (void)requestPermissions:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback
Swift (since EasyAR SDK 2.1.0): public func requestPermissions(_ permissionCallback: @escaping (PermissionStatus, String) -> Void) -> Void

open

Opens a camera with camera device type. On desktop OSes, Default represents the default camera and the value > 0 represents the device number (start from 1).

C: bool easyar_CameraDevice_open(easyar_CameraDevice* This, int camera)
C++11: bool open(int camera)
Traditional C++: bool open(int camera)
Java: public native boolean open(int camera)
Objective-C: - (bool)open:(int)camera
Swift (since EasyAR SDK 2.1.0): public func `open`(_ camera: Int32) -> Bool

close

Closes a camera.

C: bool easyar_CameraDevice_close(easyar_CameraDevice* This)
C++11: bool close()
Traditional C++: bool close()
Java: public native boolean close()
Objective-C: - (bool)close
Swift (since EasyAR SDK 2.1.0): public func close() -> Bool

isOpened

Returns true if the CameraDevice is opened, false otherwise. It is useful for the functions getting parameters because only an opened camera will return valid values.

C: bool easyar_CameraDevice_isOpened(easyar_CameraDevice* This)
C++11: bool isOpened()
Traditional C++: bool isOpened()
Java: public native boolean isOpened()
Objective-C: - (bool)isOpened
Swift (since EasyAR SDK 2.1.0): public func isOpened() -> Bool

setHorizontalFlip

Set horizontal flip flag to the camera. When set, the camera image will be horizontal flipped from default. Use after a successful open.

When you are using front camera on Android and iOS and HorizontalFlip is set to false or HorizontalFlip set to true in other conditions, EasyAR will turn on the horizontal flip mode.

When horizontal flip mode is on, the camera image will be horizontally flipped from the raw data when display. But the camera data used for tracking will never be flipped.

The default behavior is made to be same with system camera. It makes you feel like looking into a mirror when you are using front camera. You can always change the default behavior by reversing HorizontalFlip.

C: void easyar_CameraDevice_setHorizontalFlip(easyar_CameraDevice* This, bool flip)
C++11: void setHorizontalFlip(bool flip)
Traditional C++: void setHorizontalFlip(bool flip)
Java: public native void setHorizontalFlip(boolean flip)
Objective-C: - (void)setHorizontalFlip:(bool)flip
Swift (since EasyAR SDK 2.1.0): public func setHorizontalFlip(_ flip: Bool) -> Void

frameRate

Gets the current frame rate. Use after a successful open.

C: float easyar_CameraDevice_frameRate(const easyar_CameraDevice* This)
C++11: float frameRate()
Traditional C++: float frameRate()
Java: public native float frameRate()
Objective-C: - (float)frameRate
Swift (since EasyAR SDK 2.1.0): public func frameRate() -> Float

supportedFrameRateCount

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

C: int easyar_CameraDevice_supportedFrameRateCount(const easyar_CameraDevice* This)
C++11: int supportedFrameRateCount()
Traditional C++: int supportedFrameRateCount()
Java: public native int supportedFrameRateCount()
Objective-C: - (int)supportedFrameRateCount
Swift (since EasyAR SDK 2.1.0): public func supportedFrameRateCount() -> Int32

supportedFrameRate

Gets the supported frame rate of index idx . Returns 0 if idx is out of range. Use after a successful open.

C: float easyar_CameraDevice_supportedFrameRate(const easyar_CameraDevice* This, int idx)
C++11: float supportedFrameRate(int idx)
Traditional C++: float supportedFrameRate(int idx)
Java: public native float supportedFrameRate(int idx)
Objective-C: - (float)supportedFrameRate:(int)idx
Swift (since EasyAR SDK 2.1.0): public func supportedFrameRate(_ idx: Int32) -> Float

setFrameRate

Sets the frame rate. The proximal value available will be selected, use frameRate to get the frame rate. Use after a successful open.

C: bool easyar_CameraDevice_setFrameRate(easyar_CameraDevice* This, float fps)
C++11: bool setFrameRate(float fps)
Traditional C++: bool setFrameRate(float fps)
Java: public native boolean setFrameRate(float fps)
Objective-C: - (bool)setFrameRate:(float)fps
Swift (since EasyAR SDK 2.1.0): public func setFrameRate(_ fps: Float) -> Bool

size

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

C: easyar_Vec2I easyar_CameraDevice_size(const easyar_CameraDevice* This)
C++11: Vec2I size()
Traditional C++: Vec2I size()
Java: public native Vec2I size()
Objective-C: - (easyar_Vec2I *)size
Swift (since EasyAR SDK 2.1.0): public func size() -> Vec2I

supportedSizeCount

Gets the number of supported preview size. Use after a successful open.

C: int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice* This)
C++11: int supportedSizeCount()
Traditional C++: int supportedSizeCount()
Java: public native int supportedSizeCount()
Objective-C: - (int)supportedSizeCount
Swift (since EasyAR SDK 2.1.0): public func supportedSizeCount() -> Int32

supportedSize

Gets the supported preview size of index idx . Returns {0, 0} if idx is out of range. Use after a successful open.

C: easyar_Vec2I easyar_CameraDevice_supportedSize(const easyar_CameraDevice* This, int idx)
C++11: Vec2I supportedSize(int idx)
Traditional C++: Vec2I supportedSize(int idx)
Java: public native Vec2I supportedSize(int idx)
Objective-C: - (easyar_Vec2I *)supportedSize:(int)idx
Swift (since EasyAR SDK 2.1.0): public func supportedSize(_ idx: Int32) -> Vec2I

setSize

Sets the preview size. The proximal value available will be selected, use size to get the actual size. Use after a successful open.

C: bool easyar_CameraDevice_setSize(easyar_CameraDevice* This, easyar_Vec2I size)
C++11: bool setSize(Vec2I size)
Traditional C++: bool setSize(Vec2I size)
Java: public native boolean setSize(Vec2I size)
Objective-C: - (bool)setSize:(easyar_Vec2I *)size
Swift (since EasyAR SDK 2.1.0): public func setSize(_ size: Vec2I) -> Bool

zoomScale

Gets the current zoom scale. Use after a successful open.

C: float easyar_CameraDevice_zoomScale(const easyar_CameraDevice* This)
C++11: float zoomScale()
Traditional C++: float zoomScale()
Java: public native float zoomScale()
Objective-C: - (float)zoomScale
Swift (since EasyAR SDK 2.1.0): public func zoomScale() -> Float

setZoomScale

Sets the zoom scale. Use after a successful open.

C: void easyar_CameraDevice_setZoomScale(easyar_CameraDevice* This, float scale)
C++11: void setZoomScale(float scale)
Traditional C++: void setZoomScale(float scale)
Java: public native void setZoomScale(float scale)
Objective-C: - (void)setZoomScale:(float)scale
Swift (since EasyAR SDK 2.1.0): public func setZoomScale(_ scale: Float) -> Void

minZoomScale

Minimal zoom scale supported. Use after a successful open.

C: float easyar_CameraDevice_minZoomScale(const easyar_CameraDevice* This)
C++11: float minZoomScale()
Traditional C++: float minZoomScale()
Java: public native float minZoomScale()
Objective-C: - (float)minZoomScale
Swift (since EasyAR SDK 2.1.0): public func minZoomScale() -> Float

maxZoomScale

Maximal zoom scale supported. Use after a successful open.

C: float easyar_CameraDevice_maxZoomScale(const easyar_CameraDevice* This)
C++11: float maxZoomScale()
Traditional C++: float maxZoomScale()
Java: public native float maxZoomScale()
Objective-C: - (float)maxZoomScale
Swift (since EasyAR SDK 2.1.0): public func maxZoomScale() -> Float

cameraCalibration

Gets calibration data. Use after a successful open.

C: void easyar_CameraDevice_cameraCalibration(const easyar_CameraDevice* This, easyar_CameraCalibration** Return)
C++11: std::shared_ptr<CameraCalibration> cameraCalibration()
Traditional C++: void cameraCalibration(CameraCalibration** Return)
Java: public native CameraCalibration cameraCalibration()
Objective-C: - (easyar_CameraCalibration *)cameraCalibration
Swift (since EasyAR SDK 2.1.0): public func cameraCalibration() -> CameraCalibration?

setFlashTorchMode

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

C: bool easyar_CameraDevice_setFlashTorchMode(easyar_CameraDevice* This, bool on)
C++11: bool setFlashTorchMode(bool on)
Traditional C++: bool setFlashTorchMode(bool on)
Java: public native boolean setFlashTorchMode(boolean on)
Objective-C: - (bool)setFlashTorchMode:(bool)on
Swift (since EasyAR SDK 2.1.0): public func setFlashTorchMode(_ on: Bool) -> Bool

setFocusMode

Sets focus mode to focusMode . Use after start.

C: bool easyar_CameraDevice_setFocusMode(easyar_CameraDevice* This, easyar_CameraDeviceFocusMode focusMode)
C++11: bool setFocusMode(CameraDeviceFocusMode focusMode)
Traditional C++: bool setFocusMode(CameraDeviceFocusMode focusMode)
Java: public native boolean setFocusMode(/* CameraDeviceFocusMode */ int focusMode)
Objective-C: - (bool)setFocusMode:(easyar_CameraDeviceFocusMode)focusMode
Swift (since EasyAR SDK 2.1.0): public func setFocusMode(_ focusMode: CameraDeviceFocusMode) -> Bool

projectionGL

Returns projection matrix.

C: easyar_Matrix44F easyar_CameraDevice_projectionGL(easyar_CameraDevice* This, float nearPlane, float farPlane)
C++11: Matrix44F projectionGL(float nearPlane, float farPlane)
Traditional C++: Matrix44F projectionGL(float nearPlane, float farPlane)
Java: public native Matrix44F projectionGL(float nearPlane, float farPlane)
Objective-C: - (easyar_Matrix44F *)projectionGL:(float)nearPlane farPlane:(float)farPlane
Swift (since EasyAR SDK 2.1.0): public func projectionGL(_ nearPlane: Float, _ farPlane: Float) -> Matrix44F