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
@interface DSCameraView: UIView<CALayerDelegate>
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. |
setTorchButton |
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. |
initWithFrame
Create an instance of DSCameraView.
- Objective-C
- Swift
- (instancetype)initWithFrame:(CGRect)frame;
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
DSCameraView *cameraView = [[DSCameraView alloc] initWithFrame:frame];
let cameraView = CameraView(frame: frame)
getDrawingLayer
Get the specified DrawingLayer.
- Objective-C
- Swift
- (DSDrawingLayer *)getDrawingLayer:(NSInteger)layerId;
func getDrawingLayer(_ layerId: Int) -> 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
DSDrawingLayer *drawingLayer = [cameraView getDrawingLayer:layerId];
let drawingLayer = cameraView.getDrawingLayer(layerId)
createDrawingLayer
Create a new DrawingLayer.
- Objective-C
- Swift
- (DSDrawingLayer *)createDrawingLayer;
func createDrawingLayer() -> DSDrawingLayer
Return Value
The object of the layer you created.
Code Snippet
- Objective-C
- Swift
DSDrawingLayer *drawingLayer = [cameraView createDrawingLayer];
let drawingLayer = cameraView.createDrawingLayer()
getVisibleRegionOfVideo
Get the visible region of the video streaming.
- Objective-C
- Swift
- (DSRect *)getVisibleRegionOfVideo;
func getVisibleRegionOfVideo() -> DSRect
Return Value
A DSRect
object (measuredInPercentage = true) that defines the visible region of the video.
Code Snippet
- Objective-C
- Swift
DSRect *visibleRegion = [cameraView getVisibleRegionOfVideo];
let visibleRegion = cameraView.getVisibleRegionOfVideo()
setTorchButton
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
- (void)setTorchButton:(CGRect)frame torchOnImage:(UIImage* _Nullable)torchOnImage torchOffImage:(UIImage* _Nullable)torchOffImage NS_SWIFT_NAME(setTorchButton(frame:torchOnImage:torchOffImage:));
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.
torchButtonVisible
Set/get the visibility of the torch button.
- Objective-C
- Swift
@property (assign, nonatomic) BOOL torchButtonVisible;
var torchButtonVisible: BOOL { get set }
deleteUserDefinedDrawingLayer
Delete the specified drawing layer.
Parameters
frame
: The ID of the layer that you want to delete.
- Objective-C
- Swift
- (void)deleteUserDefinedDrawingLayer:(NSInteger)layerId;
func deleteUserDefinedDrawingLayer(_ layerId:Int)
clearUserDefinedDrawingLayers
Clear all the user-defined drawing layers.
- Objective-C
- Swift
- (void)clearUserDefinedDrawingLayers;
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
- (NSArray<DSDrawingLayer *>*)getAllDrawingLayers;
func getAllDrawingLayers() -> [DrawingLayer]
scanRegionMaskVisible
Set/get the visibility of the scan region mask.
- Objective-C
- Swift
@property (nonatomic, assign) BOOL scanRegionMaskVisible;
var scanRegionMaskVisible: BOOL { get set }
scanLaserVisible
Set/get the visibility of the scan laser.
- Objective-C
- Swift
@property (nonatomic, assign) BOOL scanLaserVisible;
var scanLaserVisible: BOOL { get set }
setScanRegionMaskStyle
Set the style of the scan region mask.
- Objective-C
- Swift
- (void)setScanRegionMaskStyle:(UIColor)strokeColour strokeWidth:(CGFloat)strokeWidth surroundingColour:(UIColor)surroundingColour;
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.
tipConfig
Set/get the tip configurations.
- Objective-C
- Swift
@property (assign, nonatomic) DSTipConfig * tipConfig;
var tipConfig: DSTipConfig { get set }
tipVisible
Set/get the visibility of tip.
- Objective-C
- Swift
@property (assign, nonatomic) BOOL tipVisible;
var tipConfig: BOOL { get set }
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
- (void)updateTipMessage:(NSString*)tipMessage;
func updateTipMessage(_ tipMessage: String)
Parameters
tipMessage
The new message that you want to display.