Resource Base
Table of contents

DSCameraView

The DSCameraView class is used to display the camera preview and provides UI controlling APIs. Users can add interactable UI elements on the view.

Definition

Assembly: DynamsoftCameraSDK.xcframework

@interface DSCameraView: UIView<CALayerDelegate>
  • Objective-C
  • Swift
  1. @interface DSCameraView: UIView<CALayerDelegate>
    
  2. class CameraView: UIView {}
    

Attributes

Attributes Type Description
torchButtonVisible BOOL Set/get the visibility of the torch button.
scanRegionMaskVisible BOOL Set/get the visibility of the scan region mask.
scanLaserVisible BOOL Set/get the visibility of the scan laser.
tipConfig DSTipConfig Set/get the tip configurations.
tipVisible BOOL Set/get the visibility of tip.

Methods

Method Description
initWithFrame Create an instance of DSCameraView.
getDrawingLayer Get the specified DrawingLayer.
createDrawingLayer Create a new DrawingLayer.
getVisibleRegionOfVideo Get the visible region of the video streaming.
setTorchButtonWithFrame Add a torch button on your view.
deleteUserDefinedDrawingLayer Delete the specified drawing layer.
clearUserDefinedDrawingLayers Clear all the user-defined drawing layers.
getAllDrawingLayers Get all the drawing layers on the view.
setScanRegionMaskStyle Set the style of the scan region mask.
updateTipMessage Update the tip message.
setDrawingItemClickListener Set a DrawingItemClickListener to receive callback when DrawingItems on the view are clicked.

torchButtonVisible

Set/get the visibility of the torch button.

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

scanRegionMaskVisible

Set/get the visibility of the scan region mask.

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

scanLaserVisible

Set/get the visibility of the scan laser.

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

tipConfig

Set/get the tip configurations.

  • Objective-C
  • Swift
  1. @property (assign, nonatomic) DSTipConfig * tipConfig;
    
  2. var tipConfig: DSTipConfig { get set }
    

tipVisible

Set/get the visibility of tip.

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

initWithFrame

Create an instance of DSCameraView.

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

    Parameters

frame: A CGRect value that defines the position of the view.

Return Value

An instance of DSCameraView.

Code Snippet

  • Objective-C
  • Swift
  1. DSCameraView *cameraView = [[DSCameraView alloc] initWithFrame:frame];
    
  2. let cameraView = CameraView(frame: frame)
    

getDrawingLayer

Get the specified DrawingLayer.

  • Objective-C
  • Swift
  1. - (nullable DSDrawingLayer *)getDrawingLayer:(NSUInteger)layerId;
    
  2. func getDrawingLayer(_ layerId: UInt) -> DSDrawingLayer?
    

Parameters

layerId: The ID of the layer that you want to get.

Return Value

The object of the targeting layer.

Code Snippet

  • Objective-C
  • Swift
  1. DSDrawingLayer *drawingLayer = [cameraView getDrawingLayer:layerId];
    
  2. let drawingLayer = cameraView.getDrawingLayer(layerId)
    

createDrawingLayer

Create a new DrawingLayer.

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

    Return Value

The object of the layer you created.

Code Snippet

  • Objective-C
  • Swift
  1. DSDrawingLayer *drawingLayer = [cameraView createDrawingLayer];
    
  2. let drawingLayer = cameraView.createDrawingLayer()
    

getVisibleRegionOfVideo

Get the visible region of the video streaming.

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

    Return Value

A DSRect object (measuredInPercentage = true) that defines the visible region of the video.

Code Snippet

  • Objective-C
  • Swift
  1. DSRect *visibleRegion = [cameraView getVisibleRegionOfVideo];
    
  2. let visibleRegion = cameraView.getVisibleRegionOfVideo()
    

setTorchButtonWithFrame

Add a torch button on your view. If you are using enhanced feature - smart torch, the style of this torch button will be applied to the smart torch as well.

  • Objective-C
  • Swift
  1. - (void)setTorchButtonWithFrame:(CGRect)frame
                   torchOnImage:(UIImage* _Nullable)torchOnImage
                  torchOffImage:(UIImage* _Nullable)torchOffImage
    NS_SWIFT_NAME(setTorchButton(frame:torchOnImage:torchOffImage:));
    
  2. func setTorchButton(_ frame: CGRect, torchOnImage: UIImage, torchOffImage: UIImage)
    

Parameters

frame: The place that you want to locate the torch button.
torchOnImage: The torch button image that you want to display when the torch is on.
torchOffImage: The torch button image that you want to display when the torch is off.

deleteUserDefinedDrawingLayer

Delete the specified drawing layer.

Parameters

frame: The ID of the layer that you want to delete.

  • Objective-C
  • Swift
  1. - (void)deleteUserDefinedDrawingLayer:(NSUInteger)layerId;
    
  2. func deleteUserDefinedDrawingLayer(_ layerId:UInt)
    

clearUserDefinedDrawingLayers

Clear all the user-defined drawing layers.

  • Objective-C
  • Swift
  1. - (void)clearUserDefinedDrawingLayers;
    
  2. func deleteUserDefinedDrawingLayer()
    

getAllDrawingLayers

Get all the drawing layers on the view.

Return Value

All the drawing layers. The return value includes both system drawing layers and user defined drawing layers.

  • Objective-C
  • Swift
  1. - (NSArray<DSDrawingLayer *>*)getAllDrawingLayers;
    
  2. func getAllDrawingLayers() -> [DrawingLayer]
    

setScanRegionMaskStyle

Set the style of the scan region mask.

  • Objective-C
  • Swift
  1. - (void)setScanRegionMaskStyle:(UIColor)strokeColour
                   strokeWidth:(CGFloat)strokeWidth
             surroundingColour:(UIColor)surroundingColour;
    
  2. func setScanRegionMaskStyle(_ strokeColour: UIColor, strokeWidth: CGFloat, surroundingColour: UIColor)
    

Parameters

strokeColour The stroke colour of the scan region box.
strokeWidth The width of the stroke.
surroundingColour The colour of the mask around the scan region.

updateTipMessage

Update the tip message. The new tip message will be immediately displayed on the view. Generally, tip messages are uploaded internally.

  • Objective-C
  • Swift
  1. - (void)updateTipMessage:(NSString*)message;
    
  2. func updateTipMessage(_ message: String)
    

Parameters

tipMessage The new message that you want to display.

setDrawingItemClickListener

Set a DrawingItemClickListener to receive callback when DrawingItems on the view are clicked.

  • Objective-C
  • Swift
  1. - (void)setDrawingItemClickListener:(nullable id<DSDrawingItemClickListener>)clickListener;
    
  2. func setDrawingItemClickListener(_ clickListener: DrawingItemClickListener?)
    

Parameters

clickListener: A protocol instance of DrawingItemClickListener.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: