Resource Base
Table of contents

DCECameraView

DCECameraView is the class that enables users to add elements on camera view conveniently.

  • Objective-C
  • Swift
  1. @interface DCECameraView: UIView<CALayerDelegate>
    
  2. class DCECameraView : UIView, CALayerDelegate
    
Method/Property Name Description
initWithFrame Init the DCECameraView.
cameraWithFrame Init the DCECameraView with a static method.
setTorchButton Set the position, size and image of the torch button.
torchButtonVisible The property controls the visibility of the torch Button.
getDrawingLayer Get the DCEDrawingLayer instance with the layer ID.
createDrawingLayer Create a user-defined DCEDrawingLayer instance.
getVisibleRegionOfVideo Get the region of video that is visible on the camera. It help you to set the scan region when the shape of DCECameraView is quite different from the video streaming.
overlayVisible Deprecated. The property stores the BOOL value that controls the visibility of the overlays.
setOverlayColour Deprecated. Set the stroke and fill in colour of the overlay(s).
viewfinderVisible Deprecated. The property stores the BOOL value that controls the visibility of the viewfinder.
setViewfinder Deprecated. Set the attribute of the viewfinder. Currently only available for position and size setting.

 

initWithFrame

Init the DCECameraView.

  • Objective-C
  • Swift
  1. - (instancetype)initWithFrame:(CGRect)frame;
    
  2. init(frame: CGRect)
    

Code Snippet

  • Objective-C
  • Swift
  1. _dceView = [[DCECameraView alloc] initWithFrame:self.view.bounds]
    
  2. let dceView = DCECameraView.init(frame self.view.bounds)
    

 

cameraWithFrame

Statically init the DCECameraView.

  • Objective-C
  • Swift
  1. + (instancetype)cameraWithFrame:(CGRect)frame NS_SWIFT_NAME(init(frame:));
    
  2. init(frame: CGRect)
    

Code Snippet

  • Objective-C
  • Swift
  1. _dceView = [DCECameraView cameraWithFrame:self.view.bounds];
    
  2. let dceView = DCECameraView.init(frame self.view.bounds)
    

 

setTorchButton

Set the position, size and image for the torch button.

  • Objective-C
  • Swift
  1. - (void)setTorchButton:(CGRect)torchButton torchOnImage:(UIImage*)torchOnImage torchOffImage:(UIImage*)torchOffImage;
    
  2. func setTorchButton(frame: CGRect, torchOnImage: UIImage?, torchOffImage: UIImage?)
    

Parameters

frame: The frame of torch button. It includes the width, height and top-left corner coordinate of the torch button. You can input a nil value to apply no changes on the frame of 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

  • Objective-C
  • Swift
  1. CGRect rect = {0, 0, 30, 30};
    [_dceView setTorchButton:(rect) torchOnImage: image torchOffImage: image];
    
  2. _dceView.setTorchButton(CGRect.init(x: 0, y: 0, width: 500, height: 500), torchOnImage: image, torchOffImage:image)
    

Remarks

Method - (void)setTorchButton:(CGPoint)torchButtonPosition is deprecated. Please use the new setTorchButton method.

 

torchButtonVisible

torchButtonVisible is a property that controls the visibility of the torchButton. 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.

  • Objective-C
  • Swift
  1. @property (assign, nonatomic) BOOL torchVisible;
    
  2. var torchButtonVisible: Bool { get set }
    

Parameters

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

 

getDrawingLayer

  • Objective-C
  • Swift
  1. - (DCEDrawingLayer*) getDrawingLayer:(NSInteger)id;
    
  2. func getDrawingLayer(_ layerId: Int) -> DCEDrawingLayer
    

Parameters

id: The id of the drawing layer.

Available ID List

Layer ID
DDN_LAYER_ID 1
DBR_LAYER_ID 2
DLR_LAYER_ID 3
USER_DEFINED_LAYER_BASE_ID 100

Return Value

The targeting instance of DCEDrawingLayer.

Code Snippet

  • Objective-C
  • Swift
  1. DCEDrawingLayer *drawingLayer = [_dceView getDrawingLayer:DBR_LAYER_ID];
    
  2. do{
       let drawingLayer = try dceView.getDrawingLayer(DBR_LAYER_ID)
    }catch{
       // Add your code to deal with the exceptions.
    }
    

 

createDrawingLayer

  • Objective-C
  • Swift
  1. - (DCEDrawingLayer*) createDrawingLayer;
    
  2. func createDrawingLayer() -> DCEDrawingLayer
    

Return Value

A user-defined drawing layer.

Code Snippet

  • Objective-C
  • Swift
  1. DCEDrawingLayer *drawingLayer = [_dceView createDrawingLayer:1];
    
  2. do{
       let drawingLayer = try dceView.createDrawingLayer(1)
    }catch{
       // Add your code to deal with the exceptions.
    }
    

 

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.

visible-region

What's Visible Region

  • Objective-C
  • Swift
  1. - (iRegionDefinition*) getVisibleRegionOfVideo;
    
  2. func getVisbleRegionOfVideo() -> iRegionDefinition
    

Return Value

An object of iRegionDefinition. You can use this iRegionDefinition object to set the scan region.

Code Snippet

  • Objective-C
  • Swift
  1. iRegionDefinition *region = [_dceView getVisibleRegionOfVideo];
    [_dce setScanRegion:region error:nil];
    
  2. let region = dceView.getVisibleRegionOfVideo()
    dce.setScanRegion(region, error: &error)
    

 

overlayVisible

The method is deprecated

The property stores the BOOL value that controls the visibility of the overlays.

  • Objective-C
  • Swift
  1. @property (assign, nonatomic) BOOL overlayVisible;
    
  2. var overlayVisible: Bool { get set }
    

Remarks

If the property value is true, the cameraView will try to draw and display overlays on the interest areas. Otherwise, the cameraView will not draw overlays.

Code Snippet

  • Objective-C
  • Swift
  1. [_dceView setOverlayVisible:true];
    
  2. dceView.overlayVisible = true
    

 

setOverlayColour

The method is deprecated

Set the stroke and fill in colour of the overlay(s).

  • Objective-C
  • Swift
  1. - (void)setOverlayColour:(UIColor*)stroke fill:(UIColor*)fill;
    
  2. func setOverlayColour(_ stroke: UIColor, fill: UIColor)
    

Parameters

stroke: The stroke colour of the overlay.
fill: The fill in colour of the overlay.

Code Snippet

  • Objective-C
  • Swift
  1. // RGB 0 ~ 255, alpha 0 ~ 1
    UIColor* strokeColor = [UIColor colorWithRed:0 green:245 blue:255 alpha:0.5];
    UIColor* fillColor = [UIColor colorWithRed:0 green:245 blue:255 alpha:0.5];
    [_dceView setOverlayColour:strokeColor fill:fillColor];
    
  2. // RGB 0 ~ 255, alpha 0 ~ 1
    let strokeColour = UIColor(red: 0, green: 245, blue: 255, alpha: 0.5)
    let fillColour = UIColor(red: 0, green: 245, blue: 255, alpha: 0.5)
    _dceView.setOverlayColour(strokeColour, fill: fillcolour)
    

 

viewfinderVisible

The method is deprecated

The property stores the BOOL value that controls the visibility of the viewfinder.

  • Objective-C
  • Swift
  1. @property (assign, nonatomic) BOOL viewfinderVisible;
    
  2. var viewfinderVisible: Bool { get set }
    

Remarks

If the property value is true, the cameraView will try to create and display a viewfinder. Otherwise, the cameraView will not create the viewfinder.

 

setViewfinder

The method is deprecated

Set the attribute of the viewfinder. Currently only available for position and size setting.

  • Objective-C
  • Swift
  1. - (void)setViewfinder:(CGFloat)left top:(CGFloat)top right:(CGFloat)right bottom:(CGFloat)bottom error:(NSError * _Nullable * _Nullable)error;
    
  2. func setViewFinder(_ left: CGFloat, top: CGFloat, right: CGFloat, bottom: CGFloat, error: NSErrorPointer)
    

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

  • Objective-C
  • Swift
  1. [_dceView setViewfinder:0.1 top: 0.3 right: 0.9 bottom: 0.7];
    
  2. _dceView.setViewfinder(0.1, top: 0.3, right: 0.9, bottom: 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.

 

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

version 3.0.3

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