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. |
DCECameraView
Initialize the DCECameraView
object.
DCECameraView(android.content.Context context)
Parameters
context
: An instance to global information about an application environment.
setOverlayVisible
This method controls whether the camera view displays coloured and translucent overlay.
void setOverlayVisible(boolean overlayVisibile)
Parameters
overlayVisibile
: If true, the camera view will draw and display overlay 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 overlay.
void setOverlayColour(int strokeARGB, int fillARGB)
Parameters
strokeARGB
: The colour code of the overlay stroke.
fillARGB
: The colour code of the overlay 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 that 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.