CameraEnhancer
The CameraEnhancer class provides camera-specific functionality including camera selection, focus control, zoom, and other enhanced features. The CameraEnhancer is also responsible for the basic UI of the camera view.
Definition
Assembly: dynamsoft-capture-vision-react-native
class CameraEnhancer extends ImageSourceAdapter
Static Properties
| Property | Description |
|---|---|
instance |
Returns the singleton instance of CameraEnhancer. |
instance
static CameraEnhancer get instance;
Methods
| Method | Description |
|---|---|
close |
Closes the camera and releases the related resources. |
destroy |
Destroys the camera enhancer instance and releases the related resources on the host side. |
disableEnhancedFeatures |
Disables the selected and activated enhanced features of the Camera Enhancer. |
enableEnhancedFeatures |
Activates the selected enhanced features provided by the Camera Enhancer library, including the auto-zoom and smart torch features. |
getCameraPosition |
Returns the current camera being used. |
getFocusMode |
Returns the current focus mode of the camera. |
getScanRegion |
Returns the current scan region. |
getZoomFactor |
Returns the current zoom factor of the camera. |
open |
Opens the selected camera to begin the capture process. |
selectCamera |
Selects the camera based on the specified camera position. |
setFocus |
Sets the focus point as well as the mode for the camera. |
setResolution |
Sets the resolution of the camera. |
setScanRegion |
Sets the scan region of the camera and displays a bordered area on the UI. |
setZoomFactor |
Sets the zoom factor of the camera. |
turnOffTorch |
Turns off the camera’s flashlight (if available). |
turnOnTorch |
Turns on the camera’s flashlight (if available). |
getInstance |
Gets the singleton instance of CameraEnhancer. |
requestCameraPermission |
Request the camera permission. |
The following methods are inherited from superclass ImageSourceAdapter
| Method | Description |
|---|---|
addImageToBuffer |
Adds an image to the internal buffer. |
clearBuffer |
Clears all images from the buffer, resetting the state for new image fetching. |
getBufferOverflowProtectionMode |
Get the current mode for handling buffer overflow. |
getColourChannelUsageType |
Get the current usage type for color channels in images. |
getImage |
Get a buffered image. Implementing classes should return a Promise that resolves with an instance of ImageData. |
getMaximumImageCount |
Get the maximum number of images that can be buffered. |
hasImage |
Checks if an image with the specified ID is present in the buffer. |
setBufferOverflowProtectionMode |
Sets the behavior for handling new incoming images when the buffer is full. |
setColourChannelUsageType |
Sets the usage type for color channels in images. |
setMaximumImageCount |
Sets the maximum number of images that can be buffered at any time. |
setNextImageToReturn |
Sets the processing priority of a specific image. This can affect the order in which images are returned by getImage. |
startFetching |
Start fetching images from the source to the Video Buffer of ImageSourceAdapter. |
stopFetching |
Stop fetching images from the source to the Video Buffer of ImageSourceAdapter. |
close
Closes the camera and releases the related resources. When the CaptureVisionRouter instance calls stopCapturing, please make sure to call this method as well to ensure that the resources are released properly.
close()
destroy
Destroys the camera enhancer instance and releases the related resources on the host side.
destroy()
disableEnhancedFeatures
Disables the selected and activated enhanced features of the Camera Enhancer.
disableEnhancedFeatures(features: EnumEnhancedFeatures | number)
Parameters
features: An enum value or a combination of EnumEnhancedFeatures indicating the features to be disabled.
enableEnhancedFeatures
Activates the selected enhanced features (represented by EnumEnhancedFeatures) provided by the Camera Enhancer library, including the auto-zoom and smart torch features.
enableEnhancedFeatures(features: EnumEnhancedFeatures | number)
Parameters
features: An enum value or a combination of EnumEnhancedFeatures indicating the features to be disabled.
getCameraPosition
Returns the current camera being used, represented as a EnumCameraPosition.
getCameraPosition(): Promise<number>
Returns
A promise that resolves the current camera position, of type EnumCameraPosition.
getFocusMode
Returns the current focus mode of the camera, represented as a EnumFocusMode.
getFocusMode(): Promise<number>
Returns
A promise that resolves the current focus mode, of type EnumFocusMode.
getScanRegion
Returns the current scan region as a DSRect object.
getScanRegion(): Promise<undefined | null | DSRect>
Returns
A promise that resolves current scan region.
getZoomFactor
Returns the current zoom factor of the camera.
getZoomFactor(): Promise<number>
Returns
A promise that resolves current zoom factor.
open
Opens the selected camera to begin the capture process.
open()
selectCamera
Selects the camera based on the specified EnumCameraPosition.
selectCamera(position: number)
Parameters
position: One of the EnumCameraPosition.
Remarks
- backUltraWide & backDualWideAuto: iPhone only.
setCameraView
Bind a CameraView instance with this CameraEnhancer instance.
setCameraView(view: CameraView)
Parameters
view: A CameraView element.
setFocus
Sets the focus point as well as the mode (as a EnumFocusMode) for the camera.
setFocus(floatX: number, floatY: number, focusMode: number)
Parameters
floatX: The x of focus point of interest. The coordinate base of the point is “image”.
floatY: The y of focus point of interest. The coordinate base of the point is “image”.
focusMode: The subsequent focus mode.
setResolution
Sets the resolution of the camera.
setResolution(resolution: EnumResolution)
Parameters
resolution: One of the EnumResolution.
setScanRegion
Sets the scan region of the camera and displays a bordered area on the UI to represent the scan region. To learn how to specify the scan region when using the Barcode Reader, please visit this section of the foundational user guide.
setScanRegion(region: undefined | null | DSRect)
Parameters
region: Specifies the scan region. If null or undefined, cancel the scan region.
See also
setZoomFactor
Sets the zoom factor of the camera.
setZoomFactor(factor: number)
Parameters
factor: The zoom factor.
turnOffTorch
Turns off the camera’s flashlight (if available).
turnOffTorch()
turnOnTorch
Turns on the camera’s flashlight (if available).
turnOnTorch()
getInstance
Get the singleton instance of CameraEnhancer.
static getInstance(): CameraEnhancer
requestCameraPermission
Request the camera permission.
static async requestCameraPermission()