DCECameraView Class
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
Method Name | Description |
---|---|
DCECameraView |
Initialize the DCECameraView object. |
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. |
getDrawingLayer |
Get the DCEDrawingLayer instance with the layer ID. |
createDrawingLayer |
Create a user-defined DCEDrawingLayer instance. |
getVisibleRegionOfVideo |
Get the visible region of the video streaming. |
setOverlayVisible |
Deprecated. This method controls whether the camera view to display coloured and translucent overlay. |
getOverlayVisible |
Deprecated. Get the visibility (true: visible/ false: invisible) of the overlay. |
setOverlayColour |
Deprecated. Set the stroke and fill colour of the overlay. |
setViewfinderVisible |
Deprecated. This method controls whether to display a viewfinder. |
getViewfinderVisible |
Deprecated. Get the visibility (true: visible/ false: invisible) of the viewfinder. |
setViewfinder |
Deprecated. Set the position and the size of the viewfinder. |
DCECameraView
Initialize the DCECameraView
object.
DCECameraView(android.content.Context context)
Parameters
context
: An instance of global information about an application environment.
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();
getDrawingLayer
Get the DCEDrawingLayer
instance with the layer ID.
public DCEDrawingLayer getDrawingLayer(int id);
Parameters
id
: The id of the target DCEDrawingLayer
.
Parameters
id
: The id of the DrawingLayer
.
Available ID List
Layer | ID |
---|---|
DDN_LAYER_ID | 1 |
DBR_LAYER_ID | 2 |
DLR_LAYER_ID | 3 |
USER_DEFINED_LAYER_BASE_ID | 100 |
Code Snippet
DCEDrawingLayer layer = dceCameraView.getDrawingLayer(DCEDrawingLayer.DDN_LAYER_ID);
createDrawingLayer
Create a user-defined DCEDrawingLayer
instance.
public DCEDrawingLayer createDrawingLayer();
Return Value
An instance of DCEDrawingLayer
.
Code Snippet
DCEDrawingLayer layer = dceCameraView.createDrawingLayer();
setOverlayVisible
The method is deprecated
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
The method is deprecated
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
The method is deprecated
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
The method is deprecated
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
The method is deprecated
Get the visibility (true: visible/ false: invisible) of the viewfinder.
boolean getViewfinderVisible()
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
The method is deprecated
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.
getVisibleRegionOfVideo
Get the visible region of the video streaming.
When the shape of your camera view is quite different from the shape of the video streaming, there might exist a large area that is invisible. You can use this method to get the region of this invisible area.
What's Visible Region
Return Value
An iRegionDefinition
object. You can use this object to set the scan region so that the invisible areas will be cropped from the video frames.
Code Snippet
iRegionDefinition visibleRegion = cameraView.getVisibleRegion();
cameraEnhancer.setScanRegion(visibleRegion);