Resource Base
Table of contents

DCECameraView

The camera view is the main UI view of the DCE SDK. It is designed to display the video preview, overlay, viewfinder, etc.

class com.dynamsoft.dce.DCECameraView extends RelativeLayout
Method Name Description
DCECameraView Initialize the DCECameraView object.
setOverlayVisible This method controls whether the camera view to display coloured and translucent overlay.
getOverlayVisible Get the visibility (true: visible/ false: invisible) of the overlay.
setOverlayColour Set the stroke and fill colour of the overlay.
setViewfinderVisible This method controls whether to display a viewfinder.
getViewfinderVisible Get the visibility (true: visible/ false: invisible) of the viewfinder.
setViewfinder Set the position and the size of the viewfinder.
setTorchButton Set the position, size and image of the torch button.
setTorchButtonVisible Set the visibility of the torch button. The torch button icon is pre-set in the SDK.
getTorchButtonVisible Get the visibility setting of the torch button. When it returns true, a torch button should be displayed on the screen.

 

DCECameraView

Initialize the DCECameraView object.

DCECameraView(android.content.Context context)

Parameters

context: An instance of global information about an application environment.

 

setOverlayVisible

This method controls whether the camera view displays coloured and translucent overlays.

void setOverlayVisible(boolean overlayVisibile)

Parameters

overlayVisibile: If true, the camera view will draw and display overlays according to the position and colour settings. Otherwise, the overlay will be hidden.

Code Snippet

//Suppose dceCameraView is an object of `DCECameraView`
dceCameraView.setOverlayVisible(true);

 

getOverlayVisible

Get the visibility (true: visible/ false: invisible) of the overlay.

boolean getOverlayVisible()

Return Value

The visibility (true: visible/ false: invisible) of the overlay.

Code Snippet

//Suppose dceCameraView is an object of `DCECameraView`
boolean isVisible = dceCameraView.getOverlayVisible();

 

setOverlayColour

Set the stroke and fill colour of the overlays.

void setOverlayColour(int strokeARGB, int fillARGB)

Parameters

strokeARGB: The colour code of the overlays stroke. fillARGB: The colour code of the overlays stroke.

Code Snippet

//Suppose dceCameraView is an object of `DCECameraView`
dceCameraView.setOverlayColour(0xff00ff00, 0x00000000);

 

setViewfinderVisible

This method controls whether to display a viewfinder.

void setViewfinderVisible(boolean viewfinderVisible)

Parameters

viewfinderVisible: A boolean value that means whether the viewfinder is visible or not. Users can define the position and size of the viewfinder via method setViewfinder. The viewfinder will be created based on the default value if the setViewfinder has never been triggered.

Code Snippet

//Suppose dceCameraView is an object of `DCECameraView`
dceCameraView.setViewfinderVisible(true);

 

getViewfinderVisible

Get the visibility (true: visible/ false: invisible) of the viewfinder.

Return Value

A boolean value means whether the viewfinder is visible.

Code Snippet

//Suppose dceCameraView is an object of `DCECameraView`
boolean flag = dceCameraView.getViewfinderVisible();

 

setViewfinder

Set the position and the size of the viewfinder.

void setViewfinder(float left, float top, float right, float bottom) throws CameraEnhancerException

Parameters

left: The distance (by percentage) between the left border of the viewfinder and the left side of the screen. The default value is 0.15.
top: The distance (by percentage) between the top border of the viewfinder and the top side of the screen. The default value is 0.3.
right: The distance (by percentage) between the right border of the viewfinder and the left side of the screen. The default value is 0.85.
bottom: The distance (by percentage) between the bottom border of the viewfinder and the top side of the screen. The default value is 0.7.

Code Snippet

//Suppose dceCameraView is an object of `DCECameraView`
dceCameraView.setViewfinder(0.2, 0.3, 0.8, 0.7);

Remarks

The viewfinder is built based on the screen coordinate system. The origin of the coordinate is the left-top point of the mobile device. The left border of the viewfinder always means the closest border that parallels to the left side of the mobile device no matter how the mobile device is rotated.

 

setTorchButton

Set the styles of the button with the position, size and images.

void setTorchButton(Point torchButtonPosition, int width, int height, Drawable torchOnImage, Drawable torchOffImage)

Parameters

torchButtonPosition: The coordinate of the top-left corner of the torch button. You can input a null value to apply no changes to the position of the torch button.
width: The width of the torch button. You can input a null value to apply no changes to the width of the torch button.
height: The height of the torch button. You can input a null value to apply no changes to the height of the torch button.
torchOnImage: Display this image when the torch is on. You can input a null value to apply no changes to the image of the torch button when the torch is on.
torchOffImage: Display this image when the torch is off. You can input a null value to apply no changes to the image of the torch button when the torch is off.

Code Snippet

cameraView.setTorchButton(new Point(100,100), 50,50, getDrawable(R.drawable.torch_on_image), getDrawable(R.drawable.torch_off_image));

Remarks

Method setTorchButton(Point torchButtonPosition) is deprecated. Please use the new setTorchButton method.

 

setTorchButtonVisible

Set the visibility of the torch button. The torch button icon is preset in the SDK. If the torchButtonPosition has never been configured, the torchButton will be displayed on the default position. Currently, the icon and the size of the button are not available for setting.

void setTorchButtonVisible(boolean isTorchButtonVisible)

Parameters

isTorchButtonVisible: When the value is true, the torch button should be displayed. Otherwise, the torch button should be hidden.

Code Snippet

dceCameraView.setTorchButtonVisible(true);

 

getTorchButtonVisible

Get the visibility setting of the torch button. When it returns true, a torch button should be displayed on the screen.

boolean getTorchButtonVisible()

Return Value

A boolean value. When the value is true, the torch button should be displayed. Otherwise, the torch button should be hidden.

Code Snippet

boolean isTorchButtonVisible = dceCameraView.getTorchButtonVisible();

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

version 2.3.5

  • 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 +