Resource Base
Table of contents

CameraEnhancer

The CameraEnhancer class is the primary class of Dynamsoft Camera Enhancer that defines the camera controlling APIs. It is a subclass of ImageSourceAdapter.

Definition

Assembly: package com.dynamsoft.dce

class CameraEnhancer extends ImageSourceAdapter

Methods

Method Description
addListener Add a VideoFrameListener to receive callback when video frames are output.
removeListener Remove a VideoFrameListener.
takePhoto Take a photo.
getCameraPosition Get the camera position.
setZoomFactor Set the zoom factor of the camera. You can use getCapabilities to check the maximum available zoom factor.
getZoomFactor Get the zoom factor of the camera.
getFocusMode Get the currently actived focus mode.
initSystemSettingsFromFile Initialize system settings from a JSON file. The system settings contain more precise camera control parameters.
initSystemSettings Initialize system settings from a JSON string. The system settings contain more precise camera control parameters.
resetSystemSettings Reset the system settings to default value.
initEnhancedSettingsFromFile Initialize enhanced settings from a JSON file. The enhanced settings contain auxiliary parameters of enhanced features.
initEnhancedSettings Initialize enhanced settings from a JSON string. The enhanced settings contain auxiliary parameters of enhanced features.
outputEnhancedSettings Output the enhanced settings to a JSON string. The enhanced settings contain auxiliary parameters of enhanced features.
outputEnhancedSettingsToFile Output the enhanced settings to a JSON file. The enhanced settings contain auxiliary parameters of enhanced features.
resetEnhancedSettings Reset the enhanced settings to default value.
getCapabilities Get the device capabilities including zoom factor, ISO, exposure time, etc.
getCameraState Get the device capabilities including zoom factor, ISO, exposure time, etc.
setCameraStateListener Set a CameraStateListener to receive callback when the camera state changed.
enableEnhancedFeatures Enable the specified enhanced features. View EnumEnhancedFeatures for more details.
disableEnhancedFeatures Disable the specified enhanced features. View EnumEnhancedFeatures for more details.
initWithView Create an instance of CameraEnhancer.
init Create an instance of CameraEnhancer.
setScanRegion Set a scan region. The video frame is cropped based on the scan region.
getScanRegion Get a scan region.
open Open the camera.
close Close the camera.
setResolution Set the resolution. If the targeting resolution is not available for your device, a closest available resolutionll be selected.
getResolution Get the current resolution.
getAllCameras Get the IDs of all available cameras.
selectCamera Select a camera with a camera ID.
selectCamera(position) Select a camera with a camera position.
getSelectedCamera Get the currently actived camera.
getFrameRate Get the frame rate.
turnOnTorch Turn on the torch.
turnOffTorch Turn off the torch.
setFocus Set the focus point of interest and trigger an one-off auto-focus.
setFocus(subsequentFocusMode) Set the focus point of interest and trigger an one-off auto-focus. After the focus, you can either lock the focalngth or keep the continuous auto focus enabled by configuring the subsequent focus mode.
convertRectToViewCoordinates Convert the coordinates of a DSRect under video coordinate system to a CGRect under camera view coordinate system.
convertPointToViewCoordinates Convert the coordinates of a CGPoint under video coordinate system to another CGPoint under camera view coordinate system.
setImageCaptureDistanceMode Set/get the capture distance property of the video frame. The capture distance property will be recorded by VideoFrameTag.
getImageCaptureDistanceMode Set/get the capture distance property of the video frame. The capture distance property will be recorded by VideoFrameTag.
setAutoZoomRange Set the range of auto zoom.
getAutoZoomRange Get the range of auto zoom.
cameraView Set/get the CameraView instance that bind with this CameraEnhancer instance.

Inherited Methods

The following methods are inherited from superclass ImageSourceAdapter

Method Description
hasNextImageToFetch Determines whether there are more images left to fetch.
setMaxImageCount Set the maximum capability of the Video Buffer.
getMaxImageCount Get the property defines the maximum capability of the Video Buffer.
setBufferOverflowProtectionMode Sets a mode that determines the action to take when there is a new incoming image and the buffer is full. You can either block the Video Buffer or push out the oldest image and append a new one.
getBufferOverflowProtectionMode Get the buffer overflow protection mode.
getImageCount Get the current image count in the Video Buffer.
isBufferEmpty Check whether the Video Buffer is empty.
setColourChannelUsageType Set the usage type of a color channel in an image.
getColourChannelUsageType Get the usage type of a color channel in an image.
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.
getImage Get an image from the Video Buffer.
setNextImageToReturn(imageId) Specify the next image that is returned by method getImage.
setNextImageToReturn(imageId,keepInBuffer) Specify the next image that is returned by method getImage.
hasImage Check the availability of the specified image.
addImageToBuffer Adds an image to the buffer of the adapter.
clearBuffer Clears the image buffer.
setErrorListener Register an error listener to receive callback when error occurs in the ImageSourceAdapter.

addListener

Add a VideoFrameListener to receive callback when video frames are output.

void addListener(VideoFrameListener listener){}

Parameters

listener: A delegate object of VideoFrameListener to receive video frame as a ImageData.

removeListener

Remove a VideoFrameListener.

void removeListener(VideoFrameListener listener){}

Parameters

listener: A delegate object of VideoFrameListener.

takePhoto

Take a photo.

void takePhoto(PhotoListener listener) throws CameraEnhancerException{}

Parameters

photolistener: A delegate object of PhotoListener to receive the captured photo.

getCameraPosition

Get the camera position.

EnumCameraPosition getCameraPosition(){}

Return Value

The camera position.

setZoomFactor

Set the zoom factor of the camera. You can use getCapabilities to check the maximum available zoom factor.

void setZoomFactor(float factor) throws CameraEnhancerException{}

Parameters

factor: The zoom factor.

getZoomFactor

Get the zoom factor of the camera.

float getZoomFactor() throws CameraEnhancerException{}

Return Value

The zoom factor.

getFocusMode

Get the currently actived focus mode.

EnumFocusMode getFocusMode(){}

Return Value

The focus mode.

initSystemSettingsFromFile

Initialize system settings from a JSON file. The system settings contain more precise camera control parameters.

void initSystemSettingsFromFile(String filePath) throws CameraEnhancerException{}

Parameters

filePath: The path of the JSON file.
error: A NSError pointer. An error occurs when the file path is not available or the JSON datacludes invalid keys or values.

Return Value

A bool value that indicates whether the system settings are initialized successfully.

initSystemSettings

Initialize system settings from a JSON string. The system settings contain more precise camera control parameters.

void initSystemSettings(String jsonString) throws CameraEnhancerException{}

Parameters

JsonString: The JSON string. error: A NSError pointer. An error occurs when the JSON data includes invalid keys or values.

Return Value

A bool value that indicates whether the system settings are initialized successfully.

resetSystemSettings

Reset the system settings to default value.

void resetSystemSettings(){}

initEnhancedSettingsFromFile

Initialize enhanced settings from a JSON file. The enhanced settings contain auxiliary parameters of enhanced features.

void initEnhancedSettingsFromFile(String filePath) throws CameraEnhancerException{}

Parameters

filePath: The JSON string. error: A NSError pointer. An error occurs when the file path is not available or the JSON data includes invalid keys or values.

Return Value

A bool value that indicates whether the enhanced settings are initialized successfully.

initEnhancedSettings

Initialize enhanced settings from a JSON string. The enhanced settings contain auxiliary parameters of enhanced features.

void initEnhancedSettings(String jsonString) throws CameraEnhancerException{}

Parameters

JsonString: The JSON string. error: A NSError pointer. An error occurs when the JSON data includes invalid keys or values.

Return Value

A bool value that indicates whether the enhanced settings are initialized successfully.

outputEnhancedSettings

Output the enhanced settings to a JSON string. The enhanced settings contain auxiliary parameters of enhanced features.

String outputEnhancedSettings() throws CameraEnhancerException;

Parameters

error: A NSError pointer. An error occurs when the JSON data includes invalid keys or values.

Return Value

The enhanced settings in a JSON string.

outputEnhancedSettingsToFile

Output the enhanced settings to a JSON file. The enhanced settings contain auxiliary parameters of enhanced features.

void outputEnhancedSettingsToFile(String filePath) throws CameraEnhancerException;

Parameters

file The path that you want to output the JSON file. error A NSError pointer. An error occurs when the file path is not available.

Return Value

A bool value that indicates whether the enhanced settings are output successfully.

resetEnhancedSettings

Reset the enhanced settings to default value.

void resetEnhancedSettings(){}

getCapabilities

Get the device capabilities including zoom factor, ISO, exposure time, etc.

Capabilities getCapabilities(){}

Return Value

A Capabilities object.

getCameraState

Tells you whether the camera is open, opening, closing, or closed - each state being represented by a member of the CameraState enumeration.

EnumCameraState getCameraState(){}

Return Value

The camera state.

setCameraStateListener

Set a CameraStateListener to receive callback when the camera state changes.

void setCameraStateListener (CameraStateListener listener){}

Parameters

listener: A delegate object of CameraStateListener to the camera state.

enableEnhancedFeatures

Enable the specified enhanced features. View EnumEnhancedFeatures to learn about these enhanced features. By default, these enhanced features are all disabled.

void enableEnhancedFeatures(int enhancedFeatures) throws CameraEnhancerException{}

Parameters

enhancedFeatures: A combined value of EnumEnhancedFeatures which indicates a series of enhanced features.

Return Value

A bool value that indicates whether the enhanced features are enabled successfully.

disableEnhancedFeatures

Disable any enhanced features that have been previously enabled. View EnumEnhancedFeatures to learn about these enhanced features.

void disableEnhancedFeatures(int enhancerFeatures){}

Parameters

enhancedFeatures: A combined value of EnhancedFeatures which indicates a series of enhanced features.

CameraEnhancer(view,activity)

Create an instance of CameraEnhancer with a CameraView object.

CameraEnhancer(CameraView view, Activity activity){}

Parameters

view: A CameraView instance. activity: An activity object.

Return Value

An instance of CameraEnhancer.

CameraEnhancer

Create an instance of CameraEnhancer.

CameraEnhancer(Activity activity){}

Return Value

An instance of CameraEnhancer.

setScanRegion

Set a scan region. The video frame is cropped based on the scan region. To learn the full code to setting a scan region, please refer to the scan region article.

void setScanRegion(DSRect scanRegion) throws CameraEnhancerException{}

Parameters

scanRegion: A DSRect object. error: A NSError pointer. An error occurs when the DSRect data is invalid.

Return Value

A bool value that indicates whether the scan region has been successfully set or not.

Code Snippet

getScanRegion

Get the scan region if one has been set.

DSRect getScanRegion(){}

Return Value

A DSRect object that represent the scan region area.

open

Open the camera.

void open() throws CameraEnhancerException{}

close

Close the camera.

void close() throws CameraEnhancerException{}

setResolution

Set the resolution. If the targeted resolution is not available for your device, the closest available resolution will be selected.

void setResolution(EnumResolution resolution) throws CameraEnhancerException{}

Parameters

resolution One of the EnumResolution value.

getResolution

Get the current resolution.

Size getResolution(){}

Return Value

The current resolution.

getAvailableResolutions

Get all available resolutions.

List<Size> getAvailableResolutions(){}

Return Value

All available resolutions in a list.

getAllCameras

Get the IDs of all available cameras.

String[] getAllCameras(){}

Return Value

An array of camera IDs.

selectCamera

Select a camera with a camera ID.

void selectCamera(String cameraID) throws CameraEnhancerException{}

Parameters

position: One of the Camera IDs. error: A NSError pointer. An error occurs when failed to switch the camera.

Return Value

A bool value that indicates whether the camera selection is successful.

selectCamera(position)

Select a camera with a camera position.

selectCamera(EnumCameraPosition position){}

Parameters

position: One of the EnumCameraPosition value. error: A NSError pointer. An error occurs when failed to switch the camera.

Return Value

A bool value that indicates whether the camera selection is successful.

getSelectedCamera

Get the currently actived camera.

String getSelectedCamera(){}

Return Value

The ID of the currently actived camera.

getFrameRate

Get the frame rate.

int getFrameRate(){}

Return Value

The current frame rate.

turnOnTorch

Turn on the torch.

void turnOnTorch() throws CameraEnhancerException{}

turnOffTorch

Turn off the torch.

void turnOffTorch() throws CameraEnhancerException{}

setFocus

Set the focus point of interest and trigger an one-off auto-focus.

void setFocus(android.graphics.PointF focusPoint) throws CameraEnhancerException{}

Parameters

focusPoint: The focus point of interest. The coordinate base of the point is “image”.

setFocus(subsequentFocusMode)

Set the focus point of interest and trigger an one-off auto-focus. After the focus, you can either lock the focalngth or keep the continuous auto focus enabled by configuring the subsequent focus mode.

void setFocus(android.graphics.PointF focusPoint, EnumFocusMode subsequentFocusMode) throws CameraEnhancerException{}

Parameters

focusPoint: The focus point of interest. The coordinate base of the point is “image”.
subsequentFocusMode: The subsequent focus mode.

convertRectToViewCoordinates

Convert the coordinates of a DSRect under video coordinate system to a CGRect under camera view coordinate system.

android.graphics.Rect convertRectToViewCoordinates(com.dynamsoft.core.basic_structure.DSRect videoRect){}

Parameters

videoRect: The DSRect that you want to convert.

Return Value

A CGRect (coordinate measured in PT) converted from the DSRect.

convertPointToViewCoordinates

Convert the coordinates of a CGPoint under video coordinate system to another CGPoint under camera view coordinate system.

Point convertPointToViewCoordinates(Point point){}

Parameters

point: The CGPoint that you want to convert.

Return Value

A CGPoint (coordinate measured in PT) converted from the video CGPoint measured in PT.

setImageCaptureDistanceMode

Set the capture distance property of the video frame. The capture distance property will be recorded by VideoFrameTag.

void setImageCaptureDistanceMode(EnumImageCaptureDistanceMode mode){}

getImageCaptureDistanceMode

Get the capture distance property of the video frame. The capture distance property will be recorded by VideoFrameTag.

EnumImageCaptureDistanceMode getImageCaptureDistanceMode(){}

setAutoZoomRange

Set the range of auto zoom.

void setAutoZoomRange(android.util.Range ){}

Parameters

zoomRange: The zoom range of the auto zoom feature.

getAutoZoomRange

Get the range of auto zoom.

Range getAutoZoomRange(){}

Return Value

The zoom range of the auto zoom feature.

setCameraView

Bind a CameraView instance with this CameraEnhancer instance.

void setCameraView(CameraView view){}

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 4.x
    • Version 4.2.0
    • Version 4.0.2
    • Version 4.0.1
    • Version 4.0.0
  • Version 3.x
    • Version 3.0.3
    • Version 3.0.2
    • Version 3.0.1
    • Version 3.0.0
  • Version 2.x
    • Version 2.3.21
    • Version 2.3.20
    • Version 2.3.12
    • Version 2.3.11
    • Version 2.3.10
    • Version 2.3.5
    • Version 2.3.4
    • Version 2.3.3
    • Version 2.3.2
    • Version 2.3.1
    • Version 2.3.0
    • Version 2.1.4
    • Version 2.1.3
    • Version 2.1.1
    • Version 2.0.0
Change +