Skip to content

Commit 006e552

Browse files
authored
Merge pull request #236 from Dynamsoft/_dev
Dev
2 parents 6b975dc + 7b9bb40 commit 006e552

File tree

10 files changed

+222
-164
lines changed

10 files changed

+222
-164
lines changed

hello-world/angular/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ ng generate component video-capture
118118
></div>
119119
<br />
120120
Results:
121-
<div #results class="results"></div>
121+
<div class="results">{{resultText}}</div>
122122
```
123123

124124
* In `video-capture.component.ts`, add code for initializing and destroying some instances. For our stylesheet (CSS) specification, please refer to our [source code](#Official-Sample).
@@ -141,7 +141,7 @@ const componentDestroyedErrorMsg = 'VideoCapture Component Destroyed';
141141
})
142142
export class VideoCaptureComponent {
143143
@ViewChild('cameraViewContainer') cameraViewContainer?: ElementRef<HTMLDivElement>;
144-
@ViewChild('results') resultsContainer?: ElementRef<HTMLDivElement>;
144+
resultText = "";
145145

146146
resolveInit?: () => void;
147147
pInit: Promise<void> = new Promise((r) => {
@@ -179,10 +179,10 @@ export class VideoCaptureComponent {
179179
onDecodedBarcodesReceived: (result) => {
180180
if (!result.barcodeResultItems.length) return;
181181

182-
this.resultsContainer!.nativeElement.textContent = '';
182+
this.resultText = '';
183183
console.log(result);
184184
for (let item of result.barcodeResultItems) {
185-
this.resultsContainer!.nativeElement.textContent += `${item.formatString}: ${item.text}\n\n`;
185+
this.resultText += `${item.formatString}: ${item.text}\n\n`;
186186
}
187187
},
188188
});
@@ -200,6 +200,7 @@ export class VideoCaptureComponent {
200200

201201
// Open camera and start scanning single barcode.
202202
await this.cameraEnhancer.open();
203+
cameraView.setScanLaserVisible(true);
203204
if (this.isDestroyed) {
204205
throw Error(componentDestroyedErrorMsg);
205206
}
@@ -235,7 +236,7 @@ export class VideoCaptureComponent {
235236
```
236237
> Note:
237238
>
238-
> If you're looking to customize the UI, the UI customization feature are provided by the auxiliary SDK "Dynamsoft Camera Enhancer". For more details, refer to our [User Guide](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html#customize-the-ui)
239+
> If you're looking to customize the UI, the UI customization feature are provided by the auxiliary SDK "Dynamsoft Camera Enhancer". For more details, refer to our [User Guide](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html#customizing-the-ui)
239240
240241

241242
### Generate and edit the `image-capture` component
@@ -259,7 +260,7 @@ ng generate component image-capture
259260
accept=".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"
260261
/>
261262
</div>
262-
<div class="results" #results></div>
263+
<div class="results">{{resultText}}</div>
263264
</div>
264265
```
265266

@@ -280,41 +281,41 @@ import { CaptureVisionRouter } from 'dynamsoft-capture-vision-router';
280281
standalone: true,
281282
})
282283
export class ImageCaptureComponent {
283-
@ViewChild('results') resultsContainer?: ElementRef<HTMLDivElement>;
284+
resultText = "";
284285

285286
pCvRouter?: Promise<CaptureVisionRouter>;
286287
isDestroyed = false;
287288

288289
captureImage = async (e: Event) => {
289290
let files = [...((e.target! as HTMLInputElement).files as any as File[])];
290291
(e.target! as HTMLInputElement).value = ''; // reset input
291-
this.resultsContainer!.nativeElement.innerText = '';
292+
this.resultText = '';
292293
try {
293294
// ensure cvRouter is created only once
294295
const cvRouter = await (this.pCvRouter =
295296
this.pCvRouter || CaptureVisionRouter.createInstance());
296297
if (this.isDestroyed) return;
297298

298299
for (let file of files) {
299-
// Decode selected image with 'ReadBarcodes_SpeedFirst' template.
300-
const result = await cvRouter.capture(file, 'ReadBarcodes_SpeedFirst');
300+
// Decode selected image with 'ReadBarcodes_ReadRateFirst' template.
301+
const result = await cvRouter.capture(file, 'ReadBarcodes_ReadRateFirst');
302+
console.log(result);
301303
if (this.isDestroyed) return;
302304

303305
// Print file name if there's multiple files
304306
if (files.length > 1) {
305-
this.resultsContainer!.nativeElement.innerText += `\n${file.name}:\n`;
307+
this.resultText += `\n${file.name}:\n`;
306308
}
307309
for (let _item of result.items) {
308310
if (_item.type !== EnumCapturedResultItemType.CRIT_BARCODE) {
309311
continue; // check if captured result item is a barcode
310312
}
311313
let item = _item as BarcodeResultItem;
312-
this.resultsContainer!.nativeElement.innerText += item.text + '\n'; // output the decoded barcode text
313-
console.log(item.text);
314+
this.resultText += item.text + '\n'; // output the decoded barcode text
314315
}
315316
// If no items are found, display that no barcode was detected
316317
if (!result.items.length)
317-
this.resultsContainer!.nativeElement.innerText +=
318+
this.resultText +=
318319
'No barcode found\n';
319320
}
320321
} catch (ex: any) {

hello-world/blazor/README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ window.startVideoDecode = async () => {
156156

157157
// Open camera and start scanning single barcode.
158158
await cameraEnhancer.open();
159+
160+
cameraView.setScanLaserVisible(true);
159161
await cvRouter.startCapturing("ReadSingleBarcode");
160162
} catch (ex) {
161163
let errMsg = ex.message || ex;
@@ -283,45 +285,43 @@ Inside the `wwwroot\index.html` file, we will initialize the license and necessa
283285

284286
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.2002/dist/dbr.bundle.min.js"></script>
285287
<script>
286-
/** LICENSE ALERT - README
287-
* To use the library, you need to first specify a license key using the API "initLicense()" as shown below.
288-
*/
289-
290-
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
291-
292-
/**
293-
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
294-
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
295-
* For more information, see https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html?ver=10.4.2002&cVer=true#specify-the-license&utm_source=samples or contact support@dynamsoft.com.
296-
* LICENSE ALERT - THE END
297-
*/
298-
299-
// Optional. Used to load wasm resources in advance, reducing latency between video playing and barcode decoding.
300-
Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
301-
302-
// Defined globally for easy debugging.
303-
let cameraEnhancer, cvRouter;
304-
let videoModuleLoaded = false;
305-
let imageModuleLoaded = false;
306-
307-
// Lazy load Decode video module until needed
308-
async function loadDecodeVideoModule() {
309-
if (!videoModuleLoaded) {
310-
await import('./decodeVideo.js');
311-
videoModuleLoaded = true;
312-
}
288+
/** LICENSE ALERT - README
289+
* To use the library, you need to first specify a license key using the API "initLicense()" as shown below.
290+
*/
291+
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
292+
293+
/**
294+
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
295+
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
296+
* For more information, see https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html?ver=10.4.2002&cVer=true#specify-the-license&utm_source=samples or contact support@dynamsoft.com.
297+
* LICENSE ALERT - THE END
298+
*/
299+
300+
// Optional. Used to load wasm resources in advance, reducing latency between video playing and barcode decoding.
301+
Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
302+
303+
// Defined globally for easy debugging.
304+
let cameraEnhancer, cvRouter;
305+
let videoModuleLoaded = false;
306+
let imageModuleLoaded = false;
307+
308+
// Lazy load Decode video module until needed
309+
async function loadDecodeVideoModule() {
310+
if (!videoModuleLoaded) {
311+
await import("./decodeVideo.js");
312+
videoModuleLoaded = true;
313313
}
314+
}
314315

315-
// Lazy load decode image module until needed
316-
async function loadDecodeImageModule() {
317-
if (!imageModuleLoaded) {
318-
await import('./decodeImage.js');
319-
imageModuleLoaded = true;
320-
}
316+
// Lazy load decode image module until needed
317+
async function loadDecodeImageModule() {
318+
if (!imageModuleLoaded) {
319+
await import("./decodeImage.js");
320+
imageModuleLoaded = true;
321321
}
322+
}
322323
</script>
323-
</body>
324-
324+
</body>
325325
</html>
326326
```
327327

hello-world/electron/README.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ In this guide, we will be using [`dynamsoft-barcode-reader-bundle 10.4.2002`](ht
1818

1919
Make sure you have [node](https://nodejs.org/) installed. `node 16.20.1` and `electron 26.4.1` are used in this article.
2020

21-
## Quick Start
21+
## Quick Start
2222

2323
```cmd
2424
npm install
2525
npm start
2626
```
27+
2728
A window should open to view the sample application
2829

2930
## Creating the sample project
@@ -148,14 +149,14 @@ Dynamsoft.Core.CoreModule.engineResourcePaths = {
148149
license: "./node_modules/dynamsoft-license/dist/",
149150
cvr: "./node_modules/dynamsoft-capture-vision-router/dist/",
150151
dbr: "./node_modules/dynamsoft-barcode-reader/dist/",
151-
dce: "./node_modules/dynamsoft-camera-enhancer/dist/"
152+
dce: "./node_modules/dynamsoft-camera-enhancer/dist/",
152153
};
153154

154155
/** LICENSE ALERT - README
155156
* To use the library, you need to first specify a license key using the API "initLicense()" as shown below.
156157
*/
157158

158-
Dynamsoft.License.LicenseManager.initLicense('DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9', {
159+
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", {
159160
executeNow: true,
160161
});
161162

@@ -170,15 +171,18 @@ Dynamsoft.License.LicenseManager.initLicense('DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMD
170171
Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
171172

172173
(async () => {
174+
// Defined globally for easy debugging.
175+
let cameraEnhancer, cvRouter;
176+
173177
try {
174-
// Create a `CameraEnhancer` instance for camera control and a `CameraView` instance for UI control.
178+
// Create a `CameraView` instance for UI control and a `CameraEnhancer` instance for camera control.
175179
const cameraView = await Dynamsoft.DCE.CameraView.createInstance();
176-
const cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
180+
cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
177181
// Get default UI and append it to DOM.
178182
document.querySelector("#camera-view-container").append(cameraView.getUIElement());
179183

180184
// Create a `CaptureVisionRouter` instance and set `CameraEnhancer` instance as its image source.
181-
const cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
185+
cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
182186
cvRouter.setInput(cameraEnhancer);
183187

184188
// Define a callback for results.
@@ -187,12 +191,12 @@ Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
187191
if (!result.barcodeResultItems.length) return;
188192

189193
const resultsContainer = document.querySelector("#results");
190-
resultsContainer.textContent = '';
194+
resultsContainer.textContent = "";
191195
console.log(result);
192196
for (let item of result.barcodeResultItems) {
193197
resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
194198
}
195-
}
199+
},
196200
});
197201

198202
// Filter out unchecked and duplicate results.
@@ -205,6 +209,7 @@ Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
205209

206210
// Open camera and start scanning single barcode.
207211
await cameraEnhancer.open();
212+
cameraView.setScanLaserVisible(true);
208213
await cvRouter.startCapturing("ReadSingleBarcode");
209214
} catch (ex) {
210215
let errMsg = ex.message || ex;
@@ -221,22 +226,12 @@ Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
221226
Create the `style.css` file at the root folder. Note that this is customizable!
222227

223228
```css
224-
body {
225-
text-align: center;
226-
}
227-
228-
#camera-view-container {
229-
width: 100%;
230-
height: 80vh;
231-
}
232-
233229
#results {
234230
width: 100%;
235231
height: 10vh;
236232
overflow: auto;
237233
white-space: pre-wrap;
238234
}
239-
240235
```
241236

242237
## Run the application

0 commit comments

Comments
 (0)