Skip to content

Commit c30658b

Browse files
Updating new articles, fixing code snippets
1 parent 9a3ee33 commit c30658b

12 files changed

Lines changed: 116 additions & 56 deletions

File tree

programming/android/user-guide/capabilities/add-graphics.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,6 @@ Set the style of the highlight overlays with a user defined style:
107107

108108
2. Create your style with the colour and set to the layer.
109109

110-
```java
111-
// Get the layer first.
112-
DrawingLayer layer = cameraView.getDrawingLayer(DrawingLayer.DBR_LAYER_ID);
113-
// Create a new DrawingStyle via the DrawingStyleManager.
114-
int teal_200_transparent = ResourcesCompat.getColor(MainActivity.this.getResources(), R.color.teal_200_transparent, null);
115-
int teal_200 = ResourcesCompat.getColor(MainActivity.this.getResources(), R.color.teal_200, null);
116-
int style = DrawingStyleManager.createDrawingStyle(teal_200, 1.0f,teal_200_transparent,teal_200);
117-
// Set the newly created DrawingStyle to the layer.
118-
layer.setDefaultStyle(style);
119-
```
120-
121110
<div class="sample-code-prefix"></div>
122111
>- Java
123112
>- Kotlin

programming/android/user-guide/capabilities/scan-region-style.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,30 @@ The scan region mask style includes the stroke color, stroke width, and mask col
4646
<p>Barcode Scanner UI Components</p>
4747
</div>
4848

49+
1. Add your colors to `res/values/colors.xml`.
50+
51+
```xml
52+
<color name="teal_200">#FF03DAC5</color>
53+
<color name="teal_200_transparent">#2003DAC5</color>
54+
```
55+
56+
2. Set colors to the scan region mask style.
57+
4958
<div class="sample-code-prefix"></div>
5059
>- Java
5160
>- Kotlin
5261
>
5362
>1.
5463
```java
55-
cameraView.setScanRegionMaskStyle(R.color.white, R.color.dy_gray, 2);
64+
int teal_200_transparent = ResourcesCompat.getColor(MainActivity.this.getResources(), R.color.teal_200_transparent, null);
65+
int teal_200 = ResourcesCompat.getColor(MainActivity.this.getResources(), R.color.teal_200, null);
66+
cameraView.setScanRegionMaskStyle(teal_200, teal_200_transparent, 2.0f);
5667
```
5768
2.
5869
```kotlin
59-
cameraView.setScanRegionMaskStyle(R.color.white, R.color.dy_gray, 2)
70+
val teal_200_transparent = ResourcesCompat.getColor(this@MainActivity.getResources(), R.color.teal_200_transparent, null)
71+
val teal_200 = ResourcesCompat.getColor(this@MainActivity.getResources(), R.color.teal_200, null)
72+
cameraView.setScanRegionMaskStyle(teal_200, teal_200_transparent, 2.0f)
6073
```
6174

6275
## Laser

programming/objectivec-swift/user-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ region.right = 0.85;
323323
region.bottom = 0.7;
324324
config.scanRegion = region;
325325
// Add the following line to enable the beep sound when a barcode is scanned.
326-
config.isBeepEnabled = true;
326+
config.isBeepEnabled = YES;
327327
// Add the following line if you don't want to display the torch button.
328328
config.isTorchButtonVisible = false;
329329
// Add the following line if you don't want to display the close button.
330330
config.isCloseButtonVisible = false;
331331
// Add the following line if you want to hide the scan laser.
332332
config.isScanLaserVisible = false;
333333
// Add the following line if you want the camera to auto-zoom when the barcode is far away.
334-
config.isAutoZoomEnabled = true;
334+
config.isAutoZoomEnabled = YES;
335335
```
336336
2.
337337
```swift

programming/objectivec-swift/user-guide/capabilities/add-functional-buttons.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ BarcodeScanner provides a set of UI elements that you can easily customize.
3535
>
3636
>1.
3737
```objc
38-
DSCameraView *cameraView = self.cameraView;
39-
[cameraView setTorchButtonVisible:YES];
40-
cameraView.cameraToggleButtonVisible = YES;
38+
@property (nonatomic, strong) DSCameraView *cameraView;
39+
self.cameraView = [[DSCameraView alloc] initWithFrame:self.view.bounds];
40+
[self.cameraView setTorchButtonVisible:YES];
41+
self.cameraView.cameraToggleButtonVisible = YES;
4142
```
4243
2.
4344
```swift

programming/objectivec-swift/user-guide/capabilities/add-graphics.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ noTitleIndex: true
1919
- `DrawingLayer`: The layer for displaying the `DrawingItems`.
2020
- `DrawingStyle`: The style for the `DrawingItem`.
2121

22-
## How to Hide Default Barcode Highlight Overlay
22+
## Hide Barcode Highlight Overlay
2323

2424
Barcode highlight overlay is displayed by default. You can set the layer invisible to disable it:
2525

@@ -32,20 +32,47 @@ Barcode highlight overlay is displayed by default. You can set the layer invisib
3232
// Get the layer first.
3333
DSDrawingLayer *layer = [self.cameraView getDrawingLayer:DSDrawingLayerIdDBR];
3434
// Set the visible property to true or false to control the visibility.
35-
layer.visible = true;
35+
layer.visible = NO;
3636
```
3737
2.
3838
```swift
3939
// Get the layer first.
4040
let layer = cameraView.getDrawingLayer(DrawingLayerId.dbr)
4141
// Set the visible property to true or false to control the visibility.
42-
layer?.visible = true
42+
layer?.visible = false
4343
```
4444

45-
## How to Add User Defined DrawingItem(s)
45+
## Add User-Define DrawingItem(s)
46+
47+
<div class="sample-code-prefix"></div>
48+
>- Objective-C
49+
>- Swift
50+
>
51+
>1.
52+
```objc
53+
DSDrawingLayer *barcodeLayer = [self.cameraView getDrawingLayer:DSDrawingLayerIdDBR];
54+
NSMutableArray<DSDrawingItem *> *drawingItemArrayList = [NSMutableArray array];
55+
DSQuadDrawingItem *quadDrawingItem = [[DSQuadDrawingItem alloc] initWithQuad:nil];
56+
[drawingItemArrayList addObject:quadDrawingItem];
57+
[barcodeLayer setDrawingItems:drawingItemArrayList];
58+
// You can also use the append logic if you don't want to clear the previous items.
59+
// [barcodeLayer addDrawingItems:drawingItemArrayList];
60+
```
61+
2.
62+
```swift
63+
let barcodeLayer = cameraView.getDrawingLayer(DrawingLayerId.dbr)
64+
var drawingItemArrayList: [DrawingItem] = []
65+
let quadDrawingItem = QuadDrawingItem(quad: nil)
66+
drawingItemArrayList.append(quadDrawingItem)
67+
barcodeLayer?.setDrawingItems(drawingItemArrayList)
68+
// You can also use the append logic if you don't want to clear the previous items.
69+
// barcodeLayer?.addDrawingItems(drawingItemArrayList)
70+
```
4671

4772
## How to Change the DrawingStyle
4873

74+
### Use Preset Styles
75+
4976
Set the style of the highlight overlays with a preset style:
5077

5178
<div class="sample-code-prefix"></div>
@@ -67,7 +94,9 @@ let layer = cameraView.getDrawingLayer(DrawingLayerId.dbr)
6794
layer?.setDefaultStyle(DrawingStyleId.blueStroke)
6895
```
6996

70-
Set the style of the highlight overlays with a use defined style:
97+
### Use User Defined Styles
98+
99+
Set the style of the highlight overlays with a user defined style:
71100

72101
1. Create colours in the **values/colours.xml** file.
73102

programming/objectivec-swift/user-guide/capabilities/barcode-formats.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Example:
3636
>
3737
>1.
3838
```objc
39+
@property (nonatomic, strong) DSCaptureVisionRouter *cvr;
40+
self.cvr = [[DSCaptureVisionRouter alloc] init];
3941
NSError *error = nil;
4042
DSSimplifiedCaptureVisionSettings *settings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error];
4143
DSSimplifiedBarcodeReaderSettings *barcodeSettings = settings.barcodeSettings;
@@ -44,11 +46,15 @@ barcodeSettings.barcodeFormatIds = DSBarcodeFormatQRCode | DSBarcodeFormatDataMa
4446
```
4547
2.
4648
```swift
49+
guard let settings = try? cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue) else {
50+
return
51+
}
52+
settings.barcodeSettings?.barcodeFormatIds = BarcodeFormat.qrCode.rawValue | BarcodeFormat.dataMatrix.rawValue
53+
try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: settings)
4754
do {
48-
let settings = try cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue)
49-
settings.barcodeSettings?.barcodeFormatIds = BarcodeFormat.qrCode.rawValue | BarcodeFormat.dataMatrix.rawValue
50-
try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: settings)
55+
try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings:settings)
5156
} catch {
57+
print("update runtimeSettings error:\(error.localizedDescription)")
5258
}
5359
```
5460

@@ -72,7 +78,7 @@ config.barcodeFormats = DSBarcodeFormatQRCode | DSBarcodeFormatDataMatrix;
7278
```swift
7379
let config = BarcodeScannerConfig()
7480
// QR Code + DataMatrix
75-
config.barcodeFormats = BarcodeFormat.qrCode.rawValue | BarcodeFormat.dataMatrix.rawValue
81+
config.barcodeFormats = [.qrCode, .dataMatrix]
7682
```
7783

7884
> [!Note]

programming/objectivec-swift/user-guide/capabilities/config-simplified-settings.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ captureVisionSettings.barcodeSettings.expectedBarcodesCount = 1;
3434
```
3535
2.
3636
```swift
37+
guard let captureVisionSettings = try? cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue) else {
38+
return
39+
}
40+
captureVisionSettings.minImageCaptureInterval = 200
41+
captureVisionSettings.timeout = 200
42+
captureVisionSettings.barcodeSettings?.barcodeFormatIds = BarcodeFormat.qrCode.rawValue | BarcodeFormat.dataMatrix.rawValue
43+
captureVisionSettings.barcodeSettings?.expectedBarcodesCount = 1
3744
do {
38-
let captureVisionSettings = try cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue)
39-
captureVisionSettings.minImageCaptureInterval = 200
40-
captureVisionSettings.timeout = 200
41-
captureVisionSettings.barcodeSettings?.barcodeFormatIds = BarcodeFormat.qrCode.rawValue | BarcodeFormat.dataMatrix.rawValue
42-
captureVisionSettings.barcodeSettings?.expectedBarcodesCount = 1
4345
try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: captureVisionSettings)
4446
} catch {
4547
// Handle error

programming/objectivec-swift/user-guide/capabilities/init-customized-template.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ NSError *error = nil;
3333
```
3434
2.
3535
```swift
36-
try cvr.initSettingsFromFile("ReadQRCodes.json")
36+
do {
37+
try cvr.initSettingsFromFile("ReadQRCodes.json")
38+
} catch {
39+
print("initSettingsFromFile error:\(error.localizedDescription)")
40+
}
3741
```
3842

3943
## Initialize with BarcodeScanner APIs

programming/objectivec-swift/user-guide/capabilities/read-from-an-image.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let capturedResult = try cvr.captureFromFile("Your-file-path", templateName: Pre
6464

6565
For details, see [Parameters and Settings - Use a Customized Template](parameters-and-settings.md#use-a-customized-template).
6666

67-
## Code Snippet
67+
## How to Extract Barcode Info
6868

6969
<div class="sample-code-prefix"></div>
7070
>- Objective-C

programming/objectivec-swift/user-guide/capabilities/read-from-camera.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ needGenerateH3Content: true
88
needAutoGenerateSidebar: true
99
---
1010

11-
# Read from camera
11+
# Read from Camera
1212

1313
> [!Important]
1414
> This page is for **Foundational APIs** only. Refer to [Quick Start](../../user-guide.md) for how to scan from camera with `BarcodeScanner` component.
@@ -31,9 +31,11 @@ Follow these three steps to read barcodes from the camera:
3131
>
3232
>1.
3333
```objc
34-
DSCameraEnhancer *cameraEnhancer = [[DSCameraEnhancer alloc] init];
35-
DSCameraView *cameraView = [[DSCameraView alloc] initWithFrame:self.view.bounds];
36-
cameraEnhancer.cameraView = cameraView;
34+
@property (nonatomic, strong) DSCameraEnhancer *dce;
35+
@property (nonatomic, strong) DSCameraView *cameraView;
36+
self.dce = [[DSCameraEnhancer alloc] init];
37+
self.cameraView = [[DSCameraView alloc] initWithFrame:self.view.bounds];
38+
self.dce.cameraView = self.cameraView;
3739
```
3840
2.
3941
```swift
@@ -50,9 +52,10 @@ Follow these three steps to read barcodes from the camera:
5052
>
5153
>1.
5254
```objc
53-
DSCaptureVisionRouter *cvr = [[DSCaptureVisionRouter alloc] init];
55+
@property (nonatomic, strong) DSCaptureVisionRouter *cvr;
56+
self.cvr = [[DSCaptureVisionRouter alloc] init];
5457
NSError *error = nil;
55-
[cvr setInput:cameraEnhancer error:&error];
58+
[self.cvr setInput:self.dce error:&error];
5659
```
5760
2.
5861
```swift
@@ -71,7 +74,7 @@ To use another camera source, complete the following steps so the library can pr
7174
2. Convert the raw camera input to a `com.dynamsoft.core.basic_structures.ImageData` object.
7275
3. Use `addImageToBuffer` to add the `ImageData` object to the buffer.
7376

74-
## Result receiver
77+
## Result Receiver
7578

7679
Use `CapturedResultReceiver` to receive capture results. The callback is triggered each time an image is processed, regardless of whether a barcode is decoded.
7780

@@ -81,20 +84,25 @@ Use `CapturedResultReceiver` to receive capture results. The callback is trigger
8184
>
8285
>1.
8386
```objc
84-
[cvr addResultReceiver:self];
85-
// Implement DSCapturedResultReceiver callback:
87+
@interface ViewController () <DSCapturedResultReceiver>
88+
- (void)setUpDCV {
89+
[self.cvr addResultReceiver:self];
90+
}
8691
- (void)onDecodedBarcodesReceived:(DSDecodedBarcodesResult *)result {
8792
}
8893
```
8994
2.
9095
```swift
91-
cvr.addResultReceiver(self)
92-
// Implement CapturedResultReceiver callback:
93-
func onDecodedBarcodesReceived(_ result: DecodedBarcodesResult) {
96+
class ViewController: UIViewController, CapturedResultReceiver {
97+
func setUpDCV() {
98+
cvr.addResultReceiver(self)
99+
}
100+
func onDecodedBarcodesReceived(_ result: DecodedBarcodesResult) {
101+
}
94102
}
95103
```
96104

97-
## Start capturing
105+
## Start Capturing
98106

99107
Use `startCapturing` and `stopCapturing` to control when barcode decoding starts and stops.
100108

@@ -104,9 +112,15 @@ Use `startCapturing` and `stopCapturing` to control when barcode decoding starts
104112
>
105113
>1.
106114
```objc
107-
[cvr startCapturing:DSPresetTemplateReadBarcodes completionHandler:nil];
115+
[self.cvr startCapturing:DSPresetTemplateReadBarcodes completionHandler:nil];
108116
```
109117
2.
110118
```swift
111-
try? cvr.startCapturing(PresetTemplate.readBarcodes.rawValue)
119+
cvr.startCapturing(PresetTemplate.readBarcodes.rawValue) { isSuccess, error in
120+
if (!isSuccess) {
121+
if let error = error {
122+
self.showResult("Error", error.localizedDescription)
123+
}
124+
}
125+
}
112126
```

0 commit comments

Comments
 (0)