Resource Base
Table of contents

Regular Camera Methods

You are viewing a history document page of DCE v1.0.3.

Method Description
getDeviceLevel Make an evaluation on the current device and define its level for further use.
setAutoModeLevelParam Set auto mode level parameter.
updateCameraSetting Update camera, filter and focus settings from Json.
getVersion Check current DCE version
getCameraCurrentState Get camera current state.
getCameraDesiredState Get camera desired state.
setCameraDesiredState Set Camera on/off.
pauseCamera Pause Camera.
resumeCamera Resume Camera.
startScanning Start scanning.
stopScanning Stop scanning.
addCameraListener Add camera listener (on preview original, filtered or fast frames).
removeCameraListener Remove camera listener.
getTorchCurrentState Get torch current state.
getTorchDesiredState Get torch desired state.
setTorchDesiredState Set torch state.
addTorchListener Add torch listener.
getCameraPosition Get current camera position.
switchCameraPosition Switch camera position front/back.
getResolution Get current resolution setting.
setResolution Set resolution.
getResolutionList Get all available resolutions

getDeviceLevel

This API can help you make an evaluation on your mobile device. It will be helpful to automatically turn off DCE on high-level mobile devices.

getDeviceLevel()

Return Value

int: Returns the device level. Read more in parameter reference HardwareUtil.

Code Snippet

Java:

mCameraEnhancer.getDeviceLevel();

Kotlin:

mCameraEnhancer!!.deviceLevel

setAutoModeLevelParam

Set auto mode level parameter - cpuMHz1, cpuMHz2, ramMB1, ramMB2. These are settings for device-level.

setAutoModeLevelParam(int, int, int, int)

Parameters

We are defining the devices level by their CPU and RAM performance. You can define the ranges for CPU and RAM performance throw this API.

int (cpuMHz1): The smallest value for CPU processing speed.
int (cpuMHz2): The greatest value for CPU processing speed.
int (ramMB1): The smallest value for RAM size.
int (ramMB2): The greatest value for RAM size.

CPU & RAM If device CPUMHz > cpuMHz2 If device CPUMHz1 < CPUMHz < cpuMHz2 If device CPUMHz < CPUMHz1
If device ramMB > ramMB2 Device-level is high Device-level is mid Device-level is mid
If ramMB1 < device ramMB < ramMB2 Device-level is mid Device-level is mid Device-level is mid
If device ramMB < ramMB1 Device-level is mid Device-level is mid Device-level is low

Code Snippet

Java:

mCameraEnhancer.setAutoModeLevelParam(cpuMHz1,cpuMHz2,ramMB1,ramMB2);

Kotlin:

mCameraEnhancer!!.setAutoModeLevelParam(cpuMHz1,cpuMHz2,ramMB1,ramMB2)

updateCameraSetting

There are some detailed settings that can be updated from JSON.

Update Settings from JSON Object

updateCameraSetting(JSONObject json) throws CameraEnhancerException

Parameters

JSONObject: The camera setting JSON object.

Code Snippet

Java:

mJson = new JSONObject();
try {
    mJson.put("graydiffthreshold", 30);//auto zoom
    mJson.put("conversioncountthreshold", 30);//auto zoom
    mJson.put("sensorvalue", 5);//filter by sensor
    mJson.put("sharpnessthreshold", 0.2);//filter by sharpness
    mJson.put("sharpnessthresholdlarge", 0.4);//filter by sharpness
    mJson.put("abssharpnessthreshold", 200);//filter by sharpness
    mJson.put("absgraythreshold", 35);//filter by sharpness
    mJson.put("claritythreshold", 0.1);//focus by sharpness
    mJson.put("ternimatefocusbysharpness", 0.02);//focus by sharpness
} catch (JSONException e) {
    e.printStackTrace();
}
try {
    mCameraEnhancer.updateCameraSetting(mJson);
} catch (CameraEnhancerException e) {
    e.printStackTrace();
}

Kotlin:

mCameraEnhancer!!.updateCameraSetting("{'sensorvalue':3,'graydiffthreshold':30,'conversioncountthreshold':30,'sharpnessthreshold':0.2,'sharpnessthresholdlarge':0.4,'abssharpnessthreshold':200,'absgraythreshold':35,'claritythreshold':0.1}")

Update Settings from JSON file

updateCameraSetting(String path) throws CameraEnhancerException

Parameters

String: A string that refers to the file path.

Java:

mCameraEnhancer.updateCameraSetting("Your file path here.");

Kotlin:

mCameraEnhancer!!.updateCameraSetting("Your file path here.")

JSON file template:

{
    //Absolute sharpness value, A threshold value for controlling filter
    "abssharpnessthreshold":200,
    //Sensor value, A threshold value for controlling filter
    "sensorvalue":3,        
    //A threshold value for gray scale analysis
    "graydiffthreshold":30,
    //A threshold for judging whether the device is shaking
    "sharpnessthreshold":0.2,
    //A threshold for judging whether the device is shaking violently
    "sharpnessthresholdlarge":0.4,
    //A threshold value for calculating sharpness
    "absgraythreshold":35,
    //A threshold value for controlling auto zoom
    "conversioncountthreshold":30,
    //A threshold value that controlling auto focus
    "claritythreshold":0.1
}

getVersion

Users can check the current DCE version by using this API.

getVersion()

Return Value

String: The version number.

Code Snippet

Java:

mCameraEnhancer.getVersion();

Kotlin:

mCameraEnhancer!!.version

getCameraCurrentState

Get the current camera status.

getCameraCurrentState()

Return Value

CameraState: An argument that stands for the camera state. One of the CameraState value.

Code Snippet

mCameraEnhancer.getCameraCurrentState();

Kotlin:

mCameraEnhancer!!.cameraCurrentState

getCameraDesiredState

Get the camera desired status.

getCameraDesiredState()

Return Value

CameraState: An argument that stands for the camera state. One of the CameraState value.

Code Snippet

Java:

mCameraEnhancer.getCameraDesiredState();

Kotlin:

mCameraEnhancer!!.cameraDesiredState

setCameraDesiredState

Set the camera status.

setCameraDesiredState(CameraState)

Parameters

CameraState: An argument that stands for the camera state. One of the CameraState value.

Code Snippet

Java:

mCameraEnhancer.setCameraDesireState(CameraState.CAMERA_STATE_OFF);
// Or
mCameraEnhancer.setCameraDesireState(CameraState.CAMERA_STATE_ON);

Kotlin:

mCameraEnhancer!!.setCameraDesiredState(CameraState.CAMERA_STATE_ON)
// Or
mCameraEnhancer!!.setCameraDesiredState(CameraState.CAMERA_STATE_OFF)

pauseCamera and resumeCamera

Note: these APIs are created for pausing & resuming the camera but the camera module will still be working when paused. If you want to shut down the camera module please use stopScanning.

void pauseCamera()
void resumeCamera()

Code Snippet

Java:

mCameraEnhancer.pauseCamera();
mCameraEnhancer.resumeCamera();

Kotlin:

mCameraEnhancer!!.pauseCamera()
mCameraEnhancer!!.resumeCamera()

stopScanning and startScanning

Control the stopping & starting of the camera module.

void stopScanning()
void startScanning()

Code Snippet

Java:

mCameraEnhancer.startScanning();
mCameraEnhancer.stopScanning();

Kotlin:

mCameraEnhancer!!.startScanning()
mCameraEnhancer!!.stopScanning()

addCameraListener

Add the Camera Listener. From the camera listener, you can get three different kinds of frames for further usage.

addCameraListener(CameraListener)

Parameters

CameraListener: The interface CameraListener.

Return Value

Frame: The video frame captured by camera. View in class Frame.

Code Snippet

Java:

mCameraEnhancer.addCameraListener(new CameraListener() {
    @Override
    public void onPreviewOriginalFrame(Frame frame) {}
    @Override
    public void onPreviewFilterFrame(Frame frame) {}
    @Override
    public void onPreviewFastFrame(Frame frame) {}
});

Kotlin:

mCameraEnhancer!!.addCameraListener(object : CameraListener {
    override fun onPreviewOriginalFrame(frame: Frame) {}
    override fun onPreviewFilterFrame(frame: Frame) {}
    override fun onPreviewFastFrame(frame: Frame) {}
})

removeCameraListener

Remove the camera listener.

removeCameraListener()

Code Snippet

Java:

mCameraEnhancer.removeCameraListener();

Kotlin:

mCameraEnhancer!!.removeCameraListener()

getTorchCurrentState

Get the current torch state.

getTorchCurrentState()

Return Value

TorchState: An argument that stands for the torch state. One of the TorchState value.

Code Snippet

Java:

mCameraEnhancer.getTorchCurrentState();

Kotlin:

mCameraEnhancer!!.torchCurrentState()

getTorchDesiredState

Get the desired torch state.

getTorchDesiredState()

Return Value

TorchState: An argument that stands for the torch state. One of the TorchState value.

Code Snippet

Java:

mCameraEnhancer.getTorchDesiredState();

Kotlin:

mCameraEnhancer!!.torchDesiredState

setTorchDesiredState

Set the desired torch state.

setTorchDesiredState(TorchState)

Parameters

TorchState: An argument that stands for the torch state. One of the TorchState value.

Code Snippet

Java:

mCameraEnhancer.setTorchDesiredState(TorchState.TORCH_STATE_AUTO);
mCameraEnhancer.setTorchDesiredState(TorchState.TORCH_STATE_ON);
mCameraEnhancer.setTorchDesiredState(TorchState.TORCH_STATE_OFF);

Kotlin:

mCameraEnhancer!!.setTorchDesiredState(TorchState.TORCH_STATE_AUTO)
mCameraEnhancer!!.setTorchDesiredState(TorchState.TORCH_STATE_ON)
mCameraEnhancer!!.setTorchDesiredState(TorchState.TORCH_STATE_OFF)

addTorchListener

Add the torch listener.

addTorchListener(TorchListener)

Parameters

TorchListener: The interface TorchListener

Code Snippet

Java:

mCameraEnhancer.addTorchListener(new TorchListener() {
    @Override
    public void onTorchStateChanged(TorchState torchState) {
                
    }
});

Kotlin:

mCameraEnhancer!!.addTorchListener(object : TorchListener {
    override fun onTorchStateChanged(TorchState: torchState) {}
})

getCameraPosition

DCE will use the back camera of your mobile device by default. You can use getCameraPosition to check which camera is activated and use switchCameraPosition to change the setting.

getCameraPosition()

Return Value

CameraPosition: An argument that stands for which camera is selected. One of the CameraPosition value.

Code Snippet

Java:

mCameraEnhancer.getCameraPosition();

Kotlin:

mCameraEnhancer!!.cameraPosition

switchCameraPosition

Change the camera position. Switch between the front or back camera.

switchCameraPosition(CameraPosition)

Parameters

CameraPosition: An argument that stands for which camera is selected. One of the CameraPosition value.

Code Snippet

Java:

mCameraEnhancer.switchCameraPosition(CameraPosition.CAMERA_POSITION_USER);
mCameraEnhancer.switchCameraPosition(CameraPosition.CAMERA_POSITION_WORLD);

Kotlin:

mCameraEnhancer!!.switchCameraPosition(CameraPosition.CAMERA_POSITION_USER)
mCameraEnhancer!!.switchCameraPosition(CameraPosition.CAMERA_POSITION_WORLD)

getResolution

Get the current resolution settings.

getResolution()

Return Value

Resolution: One of the Resolution value.

Code Snippet

Java:

mCameraEnhancer.getResolution();

Kotlin:

mCameraEnhancer!!.resolution

setResolution

Set the resolution.

setResolution(Resolution)

Parameters

Resolution: One of the Resolution value.

Code Snippet

Java:

mCameraEnhancer.setResolution(Resolution.RESOLUTION_1080P);

Kotlin:

mCameraEnhancer!!.setResolution(Resolution.RESOLUTION_1080P)

getResolutionList

Get all the available resolution value of the device.

getResolutionList()

Return Value

List<Size>: The device available Resolution: The device available resolution list. This resolution list might be different from the value of parameter Resolution.

Code Snippet

Java:

mCameraEnhancer.getResolutionList();

Kotlin:

mCameraEnhancer!!.resolutionList

Remarks

If the pre-set resolution is unavailable for the current device, the SDK will select the highest available resolution below the pre-set value.

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 +