dynamsoft-barcode-reader-bundle 10.4.2002 → 10.4.3100-beta-202412302226
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.html +181 -188
- package/README.md +152 -148
- package/dist/dbr.bundle.js +2 -2
- package/dist/dbr.bundle.mjs +2 -2
- package/dist/dbr.no-content-bundle.esm.js +2 -2
- package/package.json +9 -9
package/README.html
CHANGED
|
@@ -236,61 +236,61 @@
|
|
|
236
236
|
<li><a href="#understand-the-code">Understand the code</a></li>
|
|
237
237
|
<li><a href="#about-the-code">About the code</a></li>
|
|
238
238
|
<li><a href="#run-the-example">Run the example</a></li></ul></li>
|
|
239
|
-
<li><a href="#
|
|
240
|
-
<li><a href="#include-the-sdk">Include the SDK</a></li>
|
|
241
|
-
<li><a href="#use-a-public-cdn">Use a public CDN</a></li>
|
|
242
|
-
<li><a href="#host-the-sdk-yourself-optional">Host the SDK yourself (optional)</a></li>
|
|
243
|
-
<li><a href="#prepare-the-sdk">Prepare the SDK</a></li>
|
|
244
|
-
<li><a href="#specify-the-license">Specify the license</a></li>
|
|
245
|
-
<li><a href="#specify-the-location-of-the-engine-files
|
|
246
|
-
<li><a href="#
|
|
247
|
-
<li><a href="#preload-the-module">Preload the module</a></li>
|
|
248
|
-
<li><a href="#create-a-capturevisionrouter-object">Create a CaptureVisionRouter object</a></li>
|
|
249
|
-
<li><a href="#connect-an-image-source">Connect an image source</a></li>
|
|
250
|
-
<li><a href="#register-a-result-receiver">Register a result receiver</a></li>
|
|
251
|
-
<li><a href="#start-
|
|
252
|
-
<li><a href="#
|
|
253
|
-
<li><a href="#adjust-the-preset-template-settings">Adjust the preset template settings</a
|
|
254
|
-
<li><a href="#change-barcode-settings">Change barcode settings</a></li>
|
|
255
|
-
<li><a href="#retrieve-the-original-image">Retrieve the original image</a></li>
|
|
256
|
-
<li><a href="#change-reading-frequency-to-save-power">Change reading frequency to save power</a></li>
|
|
257
|
-
<li><a href="#specify-a-scan-region">Specify a scan region</a></li
|
|
258
|
-
<li><a href="#edit-the-preset-templates-directly">Edit the preset templates directly</a></li>
|
|
259
|
-
<li><a href="#filter-the-results
|
|
260
|
-
<li><a href="#
|
|
261
|
-
<li><a href="#
|
|
262
|
-
<li><a href="#add-feedback">Add feedback</a></li>
|
|
263
|
-
<li><a href="#
|
|
264
|
-
<li><a href="#
|
|
265
|
-
<li><a href="#
|
|
239
|
+
<li><a href="#preparing-the-sdk">Preparing the SDK</a><ul>
|
|
240
|
+
<li><a href="#step-1-include-the-sdk">Step 1: Include the SDK</a></li>
|
|
241
|
+
<li><a href="#option-1-use-a-public-cdn">Option 1: Use a public CDN</a></li>
|
|
242
|
+
<li><a href="#option-2-host-the-sdk-yourself-optional">Option 2: Host the SDK yourself (optional)</a></li>
|
|
243
|
+
<li><a href="#step-2-prepare-the-sdk">Step 2: Prepare the SDK</a></li>
|
|
244
|
+
<li><a href="#1-specify-the-license">1. Specify the license</a></li>
|
|
245
|
+
<li><a href="#2-optional-specify-the-location-of-the-engine-files">2. [Optional] Specify the location of the "engine" files</a></li></ul></li>
|
|
246
|
+
<li><a href="#using-the-sdk">Using the SDK</a><ul>
|
|
247
|
+
<li><a href="#step-1-preload-the-module">Step 1: Preload the module</a></li>
|
|
248
|
+
<li><a href="#step-2-create-a-capturevisionrouter-object">Step 2: Create a CaptureVisionRouter object</a></li>
|
|
249
|
+
<li><a href="#step-3-connect-an-image-source">Step 3: Connect an image source</a></li>
|
|
250
|
+
<li><a href="#step-4-register-a-result-receiver">Step 4: Register a result receiver</a></li>
|
|
251
|
+
<li><a href="#step-5-start-process-video-frames">Step 5: Start process video frames</a></li></ul></li>
|
|
252
|
+
<li><a href="#customizing-the-process">Customizing the process</a><ul>
|
|
253
|
+
<li><a href="#1-adjust-the-preset-template-settings">1. Adjust the preset template settings</a></li>
|
|
254
|
+
<li><a href="#11-change-barcode-settings">1.1. Change barcode settings</a></li>
|
|
255
|
+
<li><a href="#12-retrieve-the-original-image">1.2. Retrieve the original image</a></li>
|
|
256
|
+
<li><a href="#13-change-reading-frequency-to-save-power">1.3. Change reading frequency to save power</a></li>
|
|
257
|
+
<li><a href="#14-specify-a-scan-region">1.4. Specify a scan region</a></li>
|
|
258
|
+
<li><a href="#2-edit-the-preset-templates-directly">2. Edit the preset templates directly</a></li>
|
|
259
|
+
<li><a href="#3-important-filter-the-results">3. [Important] Filter the results</a></li>
|
|
260
|
+
<li><a href="#method-1-verify-results-across-multiple-frames">Method 1: Verify results across multiple frames</a></li>
|
|
261
|
+
<li><a href="#method-2-eliminate-redundant-results-detected-within-a-short-time-frame">Method 2: Eliminate redundant results detected within a short time frame</a></li>
|
|
262
|
+
<li><a href="#4-add-feedback">4. Add feedback</a></li></ul></li>
|
|
263
|
+
<li><a href="#customizing-the-ui">Customizing the UI</a></li>
|
|
264
|
+
<li><a href="#documentation">Documentation</a><ul>
|
|
265
|
+
<li><a href="#api-reference">API Reference</a></li>
|
|
266
266
|
<li><a href="#how-to-upgrade">How to Upgrade</a></li>
|
|
267
|
-
<li><a href="#release-notes">Release Notes</a></li>
|
|
267
|
+
<li><a href="#release-notes">Release Notes</a></li></ul></li>
|
|
268
268
|
<li><a href="#next-steps">Next Steps</a></li>
|
|
269
269
|
</ul>
|
|
270
270
|
<p><strong>Popular Examples</strong></p>
|
|
271
271
|
<ul>
|
|
272
|
-
<li>Hello World - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
273
|
-
<li>Angular App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
274
|
-
<li>React App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
275
|
-
<li>Vue App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
276
|
-
<li>PWA App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
277
|
-
<li>WebView in Android and iOS - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.4.
|
|
278
|
-
<li>Read Driver Licenses - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
279
|
-
<li>Fill A Form - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
280
|
-
<li>Show result information on the video - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
281
|
-
<li>Debug Camera and Collect Video Frame - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
272
|
+
<li>Hello World - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/hello-world/hello-world.html">Github</a> | <a href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.31&utm_source=npm">Run</a></li>
|
|
273
|
+
<li>Angular App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/hello-world/angular">Github</a></li>
|
|
274
|
+
<li>React App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/hello-world/react">Github</a></li>
|
|
275
|
+
<li>Vue App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/hello-world/vue">Github</a></li>
|
|
276
|
+
<li>PWA App - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/hello-world/pwa">Github</a> | <a href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/pwa/helloworld-pwa.html?ver=10.4.31&utm_source=npm">Run</a></li>
|
|
277
|
+
<li>WebView in Android and iOS - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.4.31/hello-world/webview">Github</a></li>
|
|
278
|
+
<li>Read Driver Licenses - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/use-case/read-a-drivers-license/index.html">Github</a> | <a href="https://demo.dynamsoft.com/Samples/DBR/JS/use-case/read-a-drivers-license/index.html?ver=10.4.31&utm_source=npm">Run</a></li>
|
|
279
|
+
<li>Fill A Form - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/use-case/fill-a-form-with-barcode-reading.html">Github</a> | <a href="https://demo.dynamsoft.com/Samples/DBR/JS/use-case/fill-a-form-with-barcode-reading.html?ver=10.4.31&utm_source=npm">Run</a></li>
|
|
280
|
+
<li>Show result information on the video - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/use-case/show-result-texts-on-the-video.html">Github</a> | <a href="https://demo.dynamsoft.com/Samples/DBR/JS/use-case/show-result-texts-on-the-video.html?ver=10.4.31&utm_source=npm">Run</a></li>
|
|
281
|
+
<li>Debug Camera and Collect Video Frame - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/others/debug">Github</a></li>
|
|
282
282
|
</ul>
|
|
283
283
|
<p>You can also:</p>
|
|
284
284
|
<ul>
|
|
285
|
-
<li>Try the Official Demo - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-demo/">Github</a> | <a href="https://demo.dynamsoft.com/barcode-reader-js/?ver=10.4.
|
|
286
|
-
<li>Try Online Examples - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.4.
|
|
285
|
+
<li>Try the Official Demo - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-demo/">Github</a> | <a href="https://demo.dynamsoft.com/barcode-reader-js/?ver=10.4.31&utm_source=npm">Run</a></li>
|
|
286
|
+
<li>Try Online Examples - <a href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.4.31/">Github</a></li>
|
|
287
287
|
</ul>
|
|
288
288
|
<h2 id="hello-world---simplest-implementation">Hello World - Simplest Implementation</h2>
|
|
289
289
|
<p>Let's start with the "Hello World" example of the DBR-JS SDK which demonstrates how to use the minimum code to enable a web page to read barcodes from a live video stream. </p>
|
|
290
290
|
<p><strong>Basic Requirements</strong></p>
|
|
291
291
|
<ul>
|
|
292
292
|
<li>Internet connection</li>
|
|
293
|
-
<li
|
|
293
|
+
<li>A supported browser</li>
|
|
294
294
|
<li>Camera access</li>
|
|
295
295
|
</ul>
|
|
296
296
|
<h3 id="understand-the-code">Understand the code</h3>
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
<span class="hljs-tag"><<span class="hljs-name">body</span>></span>
|
|
301
301
|
<span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"camera-view-container"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 100%; height: 60vh"</span>></span><span class="hljs-tag"></<span class="hljs-name">div</span>></span>
|
|
302
302
|
<span class="hljs-tag"><<span class="hljs-name">textarea</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"results"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 100%; min-height: 10vh; font-size: 3vmin; overflow: auto"</span> <span class="hljs-attr">disabled</span>></span><span class="hljs-tag"></<span class="hljs-name">textarea</span>></span>
|
|
303
|
-
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.
|
|
303
|
+
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.3100/dist/dbr.bundle.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
304
304
|
<span class="hljs-tag"><<span class="hljs-name">script</span>></span><span class="javascript">
|
|
305
305
|
Dynamsoft.License.LicenseManager.initLicense(<span class="hljs-string">"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"</span>);
|
|
306
306
|
Dynamsoft.Core.CoreModule.loadWasm([<span class="hljs-string">"dbr"</span>]);
|
|
@@ -313,8 +313,8 @@
|
|
|
313
313
|
cvRouter.setInput(cameraEnhancer);
|
|
314
314
|
|
|
315
315
|
<span class="hljs-keyword">const</span> resultsContainer = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">"#results"</span>);
|
|
316
|
-
cvRouter.addResultReceiver({ <span class="hljs-attr">
|
|
317
|
-
<span class="hljs-keyword">if</span> (result.barcodeResultItems
|
|
316
|
+
cvRouter.addResultReceiver({ <span class="hljs-attr">onCapturedResultReceived</span>: <span class="hljs-function">(<span class="hljs-params">result</span>) =></span> {
|
|
317
|
+
<span class="hljs-keyword">if</span> (result.barcodeResultItems?.length) {
|
|
318
318
|
resultsContainer.textContent = <span class="hljs-string">''</span>;
|
|
319
319
|
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item <span class="hljs-keyword">of</span> result.barcodeResultItems) {
|
|
320
320
|
resultsContainer.textContent += <span class="hljs-string">`<span class="hljs-subst">${item.formatString}</span>: <span class="hljs-subst">${item.text}</span>\n\n`</span>;
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
</code></pre>
|
|
337
337
|
<!--TOM: Update the code links-->
|
|
338
338
|
<p align="center" style="text-align:center; white-space: normal; ">
|
|
339
|
-
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.
|
|
339
|
+
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.31/hello-world/hello-world.html" title="Code in Github" style="text-decoration:none;">
|
|
340
340
|
<img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/github.svg" alt="Code in Github" width="20" height="20" style="width:20px;height:20px;">
|
|
341
341
|
</a>
|
|
342
342
|
|
|
@@ -344,7 +344,7 @@
|
|
|
344
344
|
<img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/jsfiddle.svg" alt="Run via JSFiddle" width="20" height="20" style="width:20px;height:20px;" >
|
|
345
345
|
</a>
|
|
346
346
|
|
|
347
|
-
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.
|
|
347
|
+
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.31&utm_source=npm" title="Run in Dynamsoft" style="text-decoration:none;">
|
|
348
348
|
<img src="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.0.0/svgs/solid/circle-play.svg" alt="Run in Dynamsoft" width="20" height="20" style="width:20px;height:20px;">
|
|
349
349
|
</a>
|
|
350
350
|
</p>
|
|
@@ -389,123 +389,106 @@ cvRouter.addResultFilter(filter);
|
|
|
389
389
|
<p>Read more on <a href="https://www.dynamsoft.com/capture-vision/docs/core/architecture/#capture-vision-router">Capture Vision Router</a>.</p>
|
|
390
390
|
</blockquote>
|
|
391
391
|
<h3 id="run-the-example">Run the example</h3>
|
|
392
|
-
<p>You can run the example deployed to <a href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.
|
|
392
|
+
<p>You can run the example deployed to <a href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.31&utm_source=npm">the Dynamsoft Demo Server</a> or test it with <a href="https://jsfiddle.net/DynamsoftTeam/csm2f9wb/">JSFiddle code editor</a>. </p>
|
|
393
393
|
<p>You will be asked to allow access to your camera, after which the video will be displayed on the page. After that, you can point the camera at a barcode to read it.</p>
|
|
394
394
|
<p>When a barcode is decoded, you will see the result text show up under the video and the barcode location will be highlighted in the video feed.</p>
|
|
395
395
|
<p>Alternatively, you can test locally by copying and pasting the code shown above into a local file (e.g. "hello-world.html") and opening it in your browser.</p>
|
|
396
|
-
<
|
|
397
|
-
<p>
|
|
398
|
-
<p>
|
|
399
|
-
<
|
|
400
|
-
<
|
|
401
|
-
|
|
402
|
-
<
|
|
403
|
-
<
|
|
404
|
-
</
|
|
405
|
-
<p>If the test doesn't go as expected, you can <a href="https://www.dynamsoft.com/company/contact/?ver=10.4.20&utm_source=npm&product=dbr&package=js">contact us</a>.</p>
|
|
406
|
-
<h2 id="building-your-own-page">Building your own page</h2>
|
|
407
|
-
<h3 id="include-the-sdk">Include the SDK</h3>
|
|
408
|
-
<p>To utilize the SDK, the initial step involves including the corresponding resource files:</p>
|
|
409
|
-
<ul>
|
|
410
|
-
<li><code>core.js</code> encompasses common classes, interfaces, and enumerations shared across all Dynamsoft SDKs.</li>
|
|
411
|
-
<li><code>license.js</code> introduces the <code>LicenseManager</code> class, which manages the licensing for all Dynamsoft SDKs.</li>
|
|
412
|
-
<li><code>utility.js</code> encompasses auxiliary classes shared among all Dynamsoft SDKs.</li>
|
|
413
|
-
<li><code>dbr.js</code> defines interfaces and enumerations tailored to the barcode reader module.</li>
|
|
414
|
-
<li><code>cvr.js</code> introduces the <code>CaptureVisionRouter</code> class, which governs the entire image processing workflow.</li>
|
|
415
|
-
<li><code>dce.js</code> comprises classes that offer camera support and basic user interface functionalities.</li>
|
|
416
|
-
</ul>
|
|
417
|
-
<p>To simplify things, starting from version 10.0.21, we introduced <code>dbr.bundle.js</code>, which combines all six of the above files. In the following chapters, we will use <code>dbr.bundle.js</code>.</p>
|
|
418
|
-
<h4 id="use-a-public-cdn">Use a public CDN</h4>
|
|
396
|
+
<blockquote>
|
|
397
|
+
<p><em>Secure Contexts</em>:</p>
|
|
398
|
+
<p>If you open the web page as <code>http://</code> , our SDK may not work correctly because the <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia">MediaDevices: getUserMedia()</a> and other methods only work in <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts">secure contexts</a> (HTTPS, <code>localhost</code>, <code>127.0.0.1</code>, <code>file://</code>), in some or all supporting browsers.</p>
|
|
399
|
+
<p>Regarding configuring https on your server, these guides for <a href="https://nginx.org/en/docs/http/configuring_https_servers.html">nginx</a> / <a href="https://aboutssl.org/how-to-create-a-self-signed-certificate-in-iis/">IIS</a> / <a href="https://dzone.com/articles/setting-ssl-tomcat-5-minutes">tomcat</a> / <a href="https://nodejs.org/docs/v0.4.1/api/tls.html">nodejs</a> might help.</p>
|
|
400
|
+
<p>If the test doesn't go as expected, you can <a href="https://www.dynamsoft.com/company/contact/?ver=10.4.31&utm_source=npm&product=dbr&package=js">contact us</a>.</p>
|
|
401
|
+
</blockquote>
|
|
402
|
+
<h2 id="preparing-the-sdk">Preparing the SDK</h2>
|
|
403
|
+
<h3 id="step-1-include-the-sdk">Step 1: Include the SDK</h3>
|
|
404
|
+
<h4 id="option-1-use-a-public-cdn">Option 1: Use a public CDN</h4>
|
|
419
405
|
<p>The simplest way to include the SDK is to use either the <a href="https://jsdelivr.com/">jsDelivr</a> or <a href="https://unpkg.com/">UNPKG</a> CDN. The "hello world" example above uses <strong>jsDelivr</strong>.</p>
|
|
420
406
|
<ul>
|
|
421
407
|
<li>jsDelivr</li>
|
|
422
408
|
</ul>
|
|
423
|
-
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.
|
|
409
|
+
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.3100/dist/dbr.bundle.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
424
410
|
</code></pre>
|
|
425
411
|
<ul>
|
|
426
412
|
<li>UNPKG</li>
|
|
427
413
|
</ul>
|
|
428
|
-
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/dynamsoft-barcode-reader-bundle@10.4.
|
|
414
|
+
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/dynamsoft-barcode-reader-bundle@10.4.3100/dist/dbr.bundle.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
429
415
|
</code></pre>
|
|
430
416
|
<ul>
|
|
431
417
|
<li>In some rare cases (such as some restricted areas), you might not be able to access the CDN. If this happens, you can use the following files for the test.</li>
|
|
432
418
|
</ul>
|
|
433
|
-
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader-bundle@10.4.
|
|
419
|
+
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader-bundle@10.4.3100/dist/dbr.bundle.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
434
420
|
</code></pre>
|
|
435
421
|
<p>However, please <strong>DO NOT</strong> use <code>download2.dynamsoft.com</code> resources in a production application as they are for temporary testing purposes only. Instead, you can try hosting the SDK yourself.</p>
|
|
436
422
|
<ul>
|
|
437
|
-
<li>In frameworks like React and
|
|
423
|
+
<li>In frameworks like React, Vue and Angular, you may want to add the package as a dependency.</li>
|
|
438
424
|
</ul>
|
|
439
|
-
<pre><code class="hljs sh language-sh"> npm i dynamsoft-barcode-reader-bundle@10.4.
|
|
425
|
+
<pre><code class="hljs sh language-sh"> npm i dynamsoft-barcode-reader-bundle@10.4.3100 -E
|
|
440
426
|
<span class="hljs-comment"># or</span>
|
|
441
|
-
yarn add dynamsoft-barcode-reader-bundle@10.4.
|
|
427
|
+
yarn add dynamsoft-barcode-reader-bundle@10.4.3100 -E
|
|
442
428
|
</code></pre>
|
|
443
429
|
<p>NOTE that in frameworks, you need to <a href="#specify-the-location-of-the-engine-files-optional">specify the engineResourcePaths</a>.</p>
|
|
444
|
-
<h4 id="host-the-sdk-yourself-optional">Host the SDK yourself (optional)</h4>
|
|
430
|
+
<h4 id="option-2-host-the-sdk-yourself-optional">Option 2: Host the SDK yourself (optional)</h4>
|
|
445
431
|
<p>Besides using the public CDN, you can also download the SDK and host its files on your own server or a commercial CDN before including it in your application.</p>
|
|
446
|
-
<p>There are two options for downloading the SDK, and the usage for each is slightly different</p>
|
|
447
432
|
<ul>
|
|
448
433
|
<li><p>From the website</p>
|
|
449
|
-
<p><a href="https://www.dynamsoft.com/barcode-reader/downloads/?ver=10.4.
|
|
450
|
-
<p>The resources are located at path <code>dynamsoft/distributables/<pkg>@<version></code
|
|
434
|
+
<p><a href="https://www.dynamsoft.com/barcode-reader/downloads/?ver=10.4.31&utm_source=npm&product=dbr&package=js">Download Dynamsoft Barcode Reader JavaScript Package</a></p>
|
|
435
|
+
<p>The resources are located at path <code>dynamsoft/distributables/<pkg>@<version></code>.</p></li>
|
|
436
|
+
<li><p>From npm</p></li>
|
|
451
437
|
</ul>
|
|
452
|
-
<pre><code class="hljs
|
|
453
|
-
</code></pre>
|
|
454
|
-
<ul>
|
|
455
|
-
<li>npm</li>
|
|
456
|
-
</ul>
|
|
457
|
-
<pre><code class="hljs sh language-sh"> npm i dynamsoft-barcode-reader-bundle@10.4.2002 -E
|
|
438
|
+
<pre><code class="hljs sh language-sh"> npm i dynamsoft-barcode-reader-bundle@10.4.3100 -E
|
|
458
439
|
<span class="hljs-comment"># Compared with using CDN, you need to set up more resources.</span>
|
|
459
|
-
npm i dynamsoft-capture-vision-std@1.4.
|
|
460
|
-
npm i dynamsoft-image-processing@2.4.
|
|
440
|
+
npm i dynamsoft-capture-vision-std@1.4.21 -E
|
|
441
|
+
npm i dynamsoft-image-processing@2.4.31 -E
|
|
461
442
|
</code></pre>
|
|
462
|
-
<p>The resources are located at the path <code>node_modules/<pkg></code>, without <code>@<version></code
|
|
463
|
-
<pre><code class="hljs html language-html"> <span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"node_modules/dynamsoft-barcode-reader-bundle/dist/dbr.bundle.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
464
|
-
</code></pre>
|
|
465
|
-
<p>Since the version tags (<code>@<version></code>) are missing, you need to <a href="#specify-the-location-of-the-engine-files-optional">specify the engineResourcePaths</a> so that the SDK can find the resources correctly.</p>
|
|
443
|
+
<p>The resources are located at the path <code>node_modules/<pkg></code>, without <code>@<version></code>. You must copy "dynamsoft-xxx" packages elsewhere and add <code>@<version></code>. The <code><version></code> can be obtained from <code>package.json</code> of each package. Another thing to do is to <a href="#2-optional-specify-the-location-of-the-engine-files">specify the engineResourcePaths</a> so that the SDK can correctly locate the resources.</p>
|
|
466
444
|
<blockquote>
|
|
467
|
-
<p>
|
|
445
|
+
<p>Since "node<em>modules" is reserved for Node.js dependencies, and in our case the package is used only as static resources, we recommend either renaming the "node</em>modules" folder or moving the "dynamsoft-" packages to a dedicated folder for static resources in your project to facilitate self-hosting.</p>
|
|
468
446
|
</blockquote>
|
|
447
|
+
<p>You can typically include SDK like this:</p>
|
|
448
|
+
<pre><code class="hljs html language-html"><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"path/to/dynamsoft-barcode-reader-bundle@10.4.3100/dist/dbr.bundle.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
449
|
+
</code></pre>
|
|
469
450
|
<p><em>Note</em>:</p>
|
|
470
451
|
<ul>
|
|
471
452
|
<li>Certain legacy web application servers may lack support for the <code>application/wasm</code> mimetype for .wasm files. To address this, you have two options:</li>
|
|
472
453
|
</ul>
|
|
473
454
|
<ol>
|
|
474
455
|
<li>Upgrade your web application server to one that supports the <code>application/wasm</code> mimetype.</li>
|
|
475
|
-
<li>Manually define the mimetype on your server. You can refer to the
|
|
476
|
-
<li><a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side/Apache_Configuration_htaccess#media_types_and_character_encodings">Apache</a></li>
|
|
477
|
-
<li><a href="https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/mimemap">IIS</a></li>
|
|
478
|
-
<li><a href="https://www.nginx.com/resources/wiki/start/topics/examples/full/#mime-types">Nginx</a></li></ol></li>
|
|
456
|
+
<li>Manually define the mimetype on your server. You can refer to the guides for <a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side/Apache_Configuration_htaccess#media_types_and_character_encodings">apache</a> / <a href="https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/mimemap">IIS</a> / <a href="https://www.nginx.com/resources/wiki/start/topics/examples/full/#mime-types">nginx</a>.</li>
|
|
479
457
|
</ol>
|
|
480
458
|
<ul>
|
|
481
459
|
<li>To work properly, the SDK requires a few engine files, which are relatively large and may take quite a few seconds to download. We recommend that you set a longer cache time for these engine files, to maximize the performance of your web application.</li>
|
|
482
460
|
</ul>
|
|
483
|
-
<pre><code class="hljs
|
|
461
|
+
<pre><code>hljs <span class="hljs-keyword">Cache</span><span class="hljs-params">-Control</span>: <span class="hljs-keyword">max</span><span class="hljs-params">-age</span>=<span class="hljs-number">31536000</span>
|
|
484
462
|
</code></pre>
|
|
485
463
|
<p>Reference: <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control">Cache-Control</a>.</p>
|
|
486
|
-
<h3 id="prepare-the-sdk">Prepare the SDK</h3>
|
|
464
|
+
<h3 id="step-2-prepare-the-sdk">Step 2: Prepare the SDK</h3>
|
|
487
465
|
<p>Before using the SDK, you need to configure a few things.</p>
|
|
488
|
-
<h4 id="specify-the-license">Specify the license</h4>
|
|
466
|
+
<h4 id="1-specify-the-license">1. Specify the license</h4>
|
|
489
467
|
<p>To enable the SDK's functionality, you must provide a valid license. Utilize the API function initLicense to set your license key.</p>
|
|
490
468
|
<pre><code class="hljs javascript language-javascript">Dynamsoft.License.LicenseManager.initLicense(<span class="hljs-string">"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"</span>);
|
|
491
469
|
</code></pre>
|
|
492
|
-
<p>As previously stated, the key "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" serves as a test license valid for 24 hours, applicable to any newly authorized browser. To test the SDK further, you can request a 30-day free trial license via the <a href="https://www.dynamsoft.com/customer/license/trialLicense?ver=10.4.
|
|
470
|
+
<p>As previously stated, the key "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" serves as a test license valid for 24 hours, applicable to any newly authorized browser. To test the SDK further, you can request a 30-day free trial license via the <a href="https://www.dynamsoft.com/customer/license/trialLicense?ver=10.4.31&utm_source=npm&product=dbr&package=js" target="_blank">Request a Trial License</a> link.</p>
|
|
493
471
|
<blockquote>
|
|
494
472
|
<p>Upon registering a Dynamsoft account and obtaining the SDK package from the official website, Dynamsoft will automatically create a 30-day free trial license and embed the corresponding license key into all the provided SDK samples.</p>
|
|
495
473
|
</blockquote>
|
|
496
|
-
<h4 id="specify-the-location-of-the-engine-files
|
|
497
|
-
<p>This is usually only required with frameworks like Angular
|
|
498
|
-
<p>The purpose is to tell the SDK where to find the engine files (*.worker.js, *.wasm.js and *.wasm, etc.)
|
|
499
|
-
<pre><code class="hljs
|
|
474
|
+
<h4 id="2-optional-specify-the-location-of-the-engine-files">2. [Optional] Specify the location of the "engine" files</h4>
|
|
475
|
+
<p>This is usually only required with frameworks like Angular, React or Vue.</p>
|
|
476
|
+
<p>The purpose is to tell the SDK where to find the engine files (*.worker.js, *.wasm.js and *.wasm, etc.).</p>
|
|
477
|
+
<pre><code class="hljs ts language-ts"><span class="hljs-comment">// in framework</span>
|
|
478
|
+
<span class="hljs-keyword">import</span> { CoreModule } <span class="hljs-keyword">from</span> <span class="hljs-string">"dynamsoft-barcode-reader-bundle"</span>;
|
|
500
479
|
CoreModule.engineResourcePaths.rootDirectory = <span class="hljs-string">"https://cdn.jsdelivr.net/npm/"</span>;
|
|
501
480
|
</code></pre>
|
|
502
|
-
<
|
|
503
|
-
<
|
|
481
|
+
<pre><code class="hljs js language-js"><span class="hljs-comment">// in pure js</span>
|
|
482
|
+
Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory = <span class="hljs-string">"https://cdn.jsdelivr.net/npm/"</span>;
|
|
483
|
+
</code></pre>
|
|
484
|
+
<p>These code uses the jsDelivr CDN as an example, feel free to change it to your own location.</p>
|
|
485
|
+
<h2 id="using-the-sdk">Using the SDK</h2>
|
|
486
|
+
<h3 id="step-1-preload-the-module">Step 1: Preload the module</h3>
|
|
504
487
|
<p>The image processing logic is encapsulated within .wasm library files, and these files may require some time for downloading. To enhance the speed, we advise utilizing the following method to preload the libraries.</p>
|
|
505
488
|
<pre><code class="hljs js language-js"><span class="hljs-comment">// Preload the .wasm files</span>
|
|
506
489
|
<span class="hljs-keyword">await</span> Dynamsoft.Core.CoreModule.loadWasm([<span class="hljs-string">"dbr"</span>]);
|
|
507
490
|
</code></pre>
|
|
508
|
-
<
|
|
491
|
+
<h3 id="step-2-create-a-capturevisionrouter-object">Step 2: Create a CaptureVisionRouter object</h3>
|
|
509
492
|
<p>To use the SDK, we first create a <code>CaptureVisionRouter</code> object.</p>
|
|
510
493
|
<pre><code class="hljs javascript language-javascript">Dynamsoft.License.LicenseManager.initLicense(<span class="hljs-string">"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"</span>);
|
|
511
494
|
|
|
@@ -531,7 +514,7 @@ CoreModule.engineResourcePaths.rootDirectory = <span class="hljs-string">"https:
|
|
|
531
514
|
}
|
|
532
515
|
});
|
|
533
516
|
</code></pre>
|
|
534
|
-
<
|
|
517
|
+
<h3 id="step-3-connect-an-image-source">Step 3: Connect an image source</h3>
|
|
535
518
|
<p>The <code>CaptureVisionRouter</code> object, denoted as <code>cvRouter</code>, is responsible for handling images provided by an image source. In our scenario, we aim to detect barcodes directly from a live video stream. To facilitate this, we initialize a <code>CameraEnhancer</code> object, identified as <code>cameraEnhancer</code>, which is specifically designed to capture image frames from the video feed and subsequently forward them to <code>cvRouter</code>.</p>
|
|
536
519
|
<p>To enable video streaming on the webpage, we create a <code>CameraView</code> object referred to as <code>cameraView</code>, which is then passed to <code>cameraEnhancer</code>, and its content is displayed on the webpage.</p>
|
|
537
520
|
<pre><code class="hljs html language-html"><span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"camera-view-container"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 100%; height: 100vh"</span>></span><span class="hljs-tag"></<span class="hljs-name">div</span>></span>
|
|
@@ -541,12 +524,13 @@ CoreModule.engineResourcePaths.rootDirectory = <span class="hljs-string">"https:
|
|
|
541
524
|
<span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">"#camera-view-container"</span>).append(cameraView.getUIElement());
|
|
542
525
|
cvRouter.setInput(cameraEnhancer);
|
|
543
526
|
</code></pre>
|
|
544
|
-
<
|
|
545
|
-
<p>Once the image processing is complete, the results are sent to all the registered <code>CapturedResultReceiver</code> objects. Each <code>CapturedResultReceiver</code> object may encompass one or multiple callback functions associated with various result types.
|
|
527
|
+
<h3 id="step-4-register-a-result-receiver">Step 4: Register a result receiver</h3>
|
|
528
|
+
<p>Once the image processing is complete, the results are sent to all the registered <code>CapturedResultReceiver</code> objects. Each <code>CapturedResultReceiver</code> object may encompass one or multiple callback functions associated with various result types. This time we use <code>onCapturedResultReceived</code>:</p>
|
|
529
|
+
<!--In our particular case, our focus is on identifying barcodes within the images, so it's sufficient to define the callback function `onDecodedBarcodesReceived`:-->
|
|
546
530
|
<pre><code class="hljs javascript language-javascript"><span class="hljs-keyword">const</span> resultsContainer = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">"#results"</span>);
|
|
547
531
|
<span class="hljs-keyword">const</span> resultReceiver = <span class="hljs-keyword">new</span> Dynamsoft.CVR.CapturedResultReceiver();
|
|
548
|
-
resultReceiver.
|
|
549
|
-
<span class="hljs-keyword">if</span> (result.barcodeResultItems
|
|
532
|
+
resultReceiver.onCapturedResultReceived = <span class="hljs-function">(<span class="hljs-params">result</span>) =></span> {
|
|
533
|
+
<span class="hljs-keyword">if</span> (result.barcodeResultItems?.length) {
|
|
550
534
|
resultsContainer.textContent = <span class="hljs-string">''</span>;
|
|
551
535
|
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item <span class="hljs-keyword">of</span> result.barcodeResultItems) {
|
|
552
536
|
<span class="hljs-comment">// In this example, the barcode results are displayed on the page below the video.</span>
|
|
@@ -558,8 +542,8 @@ cvRouter.addResultReceiver(resultReceiver);
|
|
|
558
542
|
</code></pre>
|
|
559
543
|
<p>You can also write code like this. It is the same.</p>
|
|
560
544
|
<pre><code class="hljs javascript language-javascript"><span class="hljs-keyword">const</span> resultsContainer = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">"#results"</span>);
|
|
561
|
-
cvRouter.addResultReceiver({ <span class="hljs-attr">
|
|
562
|
-
<span class="hljs-keyword">if</span> (result.barcodeResultItems
|
|
545
|
+
cvRouter.addResultReceiver({ <span class="hljs-attr">onCapturedResultReceived</span>: <span class="hljs-function">(<span class="hljs-params">result</span>) =></span> {
|
|
546
|
+
<span class="hljs-keyword">if</span> (result.barcodeResultItems?.length) {
|
|
563
547
|
resultsContainer.textContent = <span class="hljs-string">''</span>;
|
|
564
548
|
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item <span class="hljs-keyword">of</span> result.barcodeResultItems) {
|
|
565
549
|
<span class="hljs-comment">// In this example, the barcode results are displayed on the page below the video.</span>
|
|
@@ -569,7 +553,7 @@ cvRouter.addResultReceiver({ <span class="hljs-attr">onDecodedBarcodesReceived</
|
|
|
569
553
|
}});
|
|
570
554
|
</code></pre>
|
|
571
555
|
<p>Check out <a href="https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/captured-result-receiver.html">CapturedResultReceiver</a> for more information.</p>
|
|
572
|
-
<
|
|
556
|
+
<h3 id="step-5-start-process-video-frames">Step 5: Start process video frames</h3>
|
|
573
557
|
<p>With the setup now complete, we can proceed to process the images in two straightforward steps:</p>
|
|
574
558
|
<ol>
|
|
575
559
|
<li>Initiate the image source to commence image acquisition. In our scenario, we invoke the <code>open()</code> method on <code>cameraEnhancer</code> to initiate video streaming and simultaneously initiate the collection of images. These collected images will be dispatched to <code>cvRouter</code> as per its request.</li>
|
|
@@ -622,10 +606,10 @@ cvRouter.addResultReceiver({ <span class="hljs-attr">onDecodedBarcodesReceived</
|
|
|
622
606
|
</tbody>
|
|
623
607
|
</table>
|
|
624
608
|
<p>Read more on the <a href="https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/preset-templates.html">preset CaptureVisionTemplates</a>.</p>
|
|
625
|
-
<
|
|
626
|
-
<
|
|
609
|
+
<h2 id="customizing-the-process">Customizing the process</h2>
|
|
610
|
+
<h3 id="1-adjust-the-preset-template-settings">1. Adjust the preset template settings</h3>
|
|
627
611
|
<p>When making adjustments to some basic tasks, we often only need to modify <a href="https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/interfaces/simplified-capture-vision-settings.html">SimplifiedCaptureVisionSettings</a>.</p>
|
|
628
|
-
<
|
|
612
|
+
<h4 id="11-change-barcode-settings">1.1. Change barcode settings</h4>
|
|
629
613
|
<p>The preset templates can be updated to meet different requirements. For example, the following code limits the barcode format to QR code.</p>
|
|
630
614
|
<pre><code class="hljs javascript language-javascript"><span class="hljs-keyword">let</span> settings = <span class="hljs-keyword">await</span> cvRouter.getSimplifiedSettings(<span class="hljs-string">"ReadSingleBarcode"</span>);
|
|
631
615
|
settings.barcodeSettings.barcodeFormatIds =
|
|
@@ -634,7 +618,7 @@ settings.barcodeSettings.barcodeFormatIds =
|
|
|
634
618
|
<span class="hljs-keyword">await</span> cvRouter.startCapturing(<span class="hljs-string">"ReadSingleBarcode"</span>);
|
|
635
619
|
</code></pre>
|
|
636
620
|
<p>For a list of adjustable barcode settings, check out <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/interfaces/simplified-barcode-reader-settings.html">SimplifiedBarcodeReaderSettings</a>.</p>
|
|
637
|
-
<
|
|
621
|
+
<h4 id="12-retrieve-the-original-image">1.2. Retrieve the original image</h4>
|
|
638
622
|
<p>Additionally, we have the option to modify the template to retrieve the original image containing the barcode.</p>
|
|
639
623
|
<pre><code class="hljs javascript language-javascript"><span class="hljs-keyword">let</span> settings = <span class="hljs-keyword">await</span> cvRouter.getSimplifiedSettings(<span class="hljs-string">"ReadSingleBarcode"</span>);
|
|
640
624
|
settings.capturedResultItemTypes |=
|
|
@@ -653,8 +637,7 @@ settings.capturedResultItemTypes =
|
|
|
653
637
|
<p>Please be aware that it is necessary to update the <code>CapturedResultReceiver</code> object to obtain the original image. For instance:</p>
|
|
654
638
|
<pre><code class="hljs javascript language-javascript"><span class="hljs-keyword">const</span> EnumCRIT = Dynamsoft.Core.EnumCapturedResultItemType;
|
|
655
639
|
resultReceiver.onCapturedResultReceived = <span class="hljs-function">(<span class="hljs-params">result</span>) =></span> {
|
|
656
|
-
<span class="hljs-keyword">
|
|
657
|
-
<span class="hljs-keyword">if</span> (barcodes.length > <span class="hljs-number">0</span>) {
|
|
640
|
+
<span class="hljs-keyword">if</span> (result.barcodeResultItems?.length) {
|
|
658
641
|
<span class="hljs-comment">// Use a filter to get the image on which barcodes are found.</span>
|
|
659
642
|
<span class="hljs-keyword">let</span> image = result.items.filter(
|
|
660
643
|
<span class="hljs-function"><span class="hljs-params">item</span> =></span> item.type === EnumCRIT.CRIT_ORIGINAL_IMAGE
|
|
@@ -662,7 +645,7 @@ resultReceiver.onCapturedResultReceived = <span class="hljs-function">(<span cla
|
|
|
662
645
|
}
|
|
663
646
|
};
|
|
664
647
|
</code></pre>
|
|
665
|
-
<
|
|
648
|
+
<h4 id="13-change-reading-frequency-to-save-power">1.3. Change reading frequency to save power</h4>
|
|
666
649
|
<p>The SDK is initially configured to process images sequentially without any breaks. Although this setup maximizes performance, it can lead to elevated power consumption, potentially causing the device to overheat. In many cases, it's possible to reduce the reading speed while still satisfying business requirements. The following code snippet illustrates how to adjust the SDK to process an image every 500 milliseconds:</p>
|
|
667
650
|
<blockquote>
|
|
668
651
|
<p>Please bear in mind that in the following code, if an image's processing time is shorter than 500 milliseconds, the SDK will wait for the full 500 milliseconds before proceeding to process the next image. Conversely, if an image's processing time exceeds 500 milliseconds, the subsequent image will be processed immediately upon completion.</p>
|
|
@@ -672,7 +655,7 @@ settings.minImageCaptureInterval = <span class="hljs-number">500</span>;
|
|
|
672
655
|
<span class="hljs-keyword">await</span> cvRouter.updateSettings(<span class="hljs-string">"ReadSingleBarcode"</span>, settings);
|
|
673
656
|
<span class="hljs-keyword">await</span> cvRouter.startCapturing(<span class="hljs-string">"ReadSingleBarcode"</span>);
|
|
674
657
|
</code></pre>
|
|
675
|
-
<
|
|
658
|
+
<h4 id="14-specify-a-scan-region">1.4. Specify a scan region</h4>
|
|
676
659
|
<p>We can specify a scan region to allow the SDK to process only part of the image, improving processing speed. The code snippet below demonstrates how to do this using the <code>cameraEnhancer</code> image source.</p>
|
|
677
660
|
<pre><code class="hljs javascript language-javascript">cameraEnhancer = <span class="hljs-keyword">await</span> Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
|
|
678
661
|
<span class="hljs-comment">// In this example, we set the scan region to cover the central 25% of the image.</span>
|
|
@@ -718,18 +701,18 @@ settings.timeout = <span class="hljs-number">500</span>;
|
|
|
718
701
|
<span class="hljs-keyword">await</span> cvRouter.startCapturing(<span class="hljs-string">"ReadSingleBarcode"</span>);
|
|
719
702
|
</code></pre>
|
|
720
703
|
-->
|
|
721
|
-
<
|
|
704
|
+
<h3 id="2-edit-the-preset-templates-directly">2. Edit the preset templates directly</h3>
|
|
722
705
|
<p>The preset templates have many more settings that can be customized to suit your use case best. If you <a href="https://www.dynamsoft.com/barcode-reader/downloads/1000003-confirmation/">download the SDK from Dynamsoft website</a>, you can find the templates under</p>
|
|
723
706
|
<ul>
|
|
724
|
-
<li>"/dynamsoft-barcode-reader-js-10.4.
|
|
707
|
+
<li>"/dynamsoft-barcode-reader-js-10.4.3100/dynamsoft/templates/"</li>
|
|
725
708
|
</ul>
|
|
726
709
|
<p>Upon completing the template editing, you can invoke the <code>initSettings</code> method and provide it with the template path as an argument.</p>
|
|
727
710
|
<pre><code class="hljs javascript language-javascript"><span class="hljs-keyword">await</span> cvRouter.initSettings(<span class="hljs-string">"PATH-TO-THE-FILE"</span>); <span class="hljs-comment">// E.g. "https://your-website/ReadSingleBarcode.json")</span>
|
|
728
711
|
<span class="hljs-keyword">await</span> cvRouter.startCapturing(<span class="hljs-string">"ReadSingleBarcode"</span>); <span class="hljs-comment">// Make sure the name matches one of the CaptureVisionTemplates in the template JSON file.</span>
|
|
729
712
|
</code></pre>
|
|
730
|
-
<
|
|
731
|
-
<p>
|
|
732
|
-
<
|
|
713
|
+
<h3 id="3-important-filter-the-results">3. [Important] Filter the results</h3>
|
|
714
|
+
<p>When processing video frames, the same barcode is often detected multiple times. To improve the user experience, we can use the <a href="https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/multi-frame-result-cross-filter.html">MultiFrameResultCrossFilter</a> object. This object provides two methods for handling duplicate detections, which can be used independently or together, depending on what best suits your application needs:</p>
|
|
715
|
+
<h4 id="method-1-verify-results-across-multiple-frames">Method 1: Verify results across multiple frames</h4>
|
|
733
716
|
<pre><code class="hljs js language-js"><span class="hljs-keyword">let</span> filter = <span class="hljs-keyword">new</span> Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
734
717
|
filter.enableResultCrossVerification(<span class="hljs-string">"barcode"</span>, <span class="hljs-literal">true</span>);
|
|
735
718
|
<span class="hljs-keyword">await</span> cvRouter.addResultFilter(filter);
|
|
@@ -738,7 +721,7 @@ filter.enableResultCrossVerification(<span class="hljs-string">"barcode"</span>,
|
|
|
738
721
|
<ul>
|
|
739
722
|
<li><code>enableResultCrossVerification</code> was designed to cross-validate the outcomes across various frames in a video streaming scenario, enhancing the reliability of the final results. This validation is particularly crucial for barcodes with limited error correction capabilities, such as 1D codes.</li>
|
|
740
723
|
</ul>
|
|
741
|
-
<
|
|
724
|
+
<h4 id="method-2-eliminate-redundant-results-detected-within-a-short-time-frame">Method 2: Eliminate redundant results detected within a short time frame</h4>
|
|
742
725
|
<pre><code class="hljs js language-js"><span class="hljs-keyword">let</span> filter = <span class="hljs-keyword">new</span> Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
743
726
|
filter.enableResultDeduplication(<span class="hljs-string">"barcode"</span>, <span class="hljs-literal">true</span>);
|
|
744
727
|
<span class="hljs-keyword">await</span> cvRouter.addResultFilter(filter);
|
|
@@ -763,7 +746,7 @@ filter.enableResultDeduplication(<span class="hljs-string">"barcode"</span>, <sp
|
|
|
763
746
|
filter.setDuplicateForgetTime(<span class="hljs-number">5000</span>);
|
|
764
747
|
<span class="hljs-keyword">await</span> cvRouter.addResultFilter(filter);
|
|
765
748
|
</code></pre>
|
|
766
|
-
<
|
|
749
|
+
<h3 id="4-add-feedback">4. Add feedback</h3>
|
|
767
750
|
<p>When a barcode is detected within the video stream, its position is immediately displayed within the video. Furthermore, utilizing the "Dynamsoft Camera Enhancer" SDK, we can introduce feedback mechanisms, such as emitting a "beep" sound or triggering a "vibration".</p>
|
|
768
751
|
<p>The following code snippet adds a "beep" sound for when a barcode is found:</p>
|
|
769
752
|
<pre><code class="hljs js language-js"><span class="hljs-keyword">const</span> resultReceiver = <span class="hljs-keyword">new</span> Dynamsoft.CVR.CapturedResultReceiver();
|
|
@@ -774,69 +757,79 @@ resultReceiver.onDecodedBarcodesReceived = <span class="hljs-function">(<span cl
|
|
|
774
757
|
};
|
|
775
758
|
cvRouter.addResultReceiver(resultReceiver);
|
|
776
759
|
</code></pre>
|
|
777
|
-
<
|
|
760
|
+
<h2 id="customizing-the-ui">Customizing the UI</h2>
|
|
761
|
+
<pre><code class="hljs javascript language-javascript"><span class="hljs-comment">// Create a CameraView instance with default settings</span>
|
|
762
|
+
<span class="hljs-keyword">let</span> cameraView = <span class="hljs-keyword">await</span> Dynamsoft.DCE.CameraView.createInstance();
|
|
763
|
+
<span class="hljs-comment">// Create a CameraView instance with a specified HTML file path, typically a local or remote URL</span>
|
|
764
|
+
<span class="hljs-keyword">let</span> cameraView1 = <span class="hljs-keyword">await</span> Dynamsoft.DCE.CameraView.createInstance(<span class="hljs-string">'@engineResourcePath/dce.mobile-native.ui.html'</span>);
|
|
765
|
+
<span class="hljs-comment">// Create a CameraView instance within a specified DOM element</span>
|
|
766
|
+
<span class="hljs-keyword">let</span> cameraView2 = <span class="hljs-keyword">await</span> Dynamsoft.DCE.CameraView.createInstance(<span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'my-ui'</span>));
|
|
767
|
+
<span class="hljs-comment">// Create a CameraView instance using a custom UI file path</span>
|
|
768
|
+
<span class="hljs-keyword">let</span> cameraView3 = <span class="hljs-keyword">await</span> Dynamsoft.DCE.CameraView.createInstance(<span class="hljs-string">'url/to/my/ui.html'</span>);
|
|
769
|
+
|
|
770
|
+
<span class="hljs-comment">// Get the UI element associated with the cameraView instance</span>
|
|
771
|
+
<span class="hljs-keyword">let</span> uiElement = cameraView.getUIElement();
|
|
772
|
+
<span class="hljs-comment">// Remove the camera selection dropdown from the CameraView's UI element</span>
|
|
773
|
+
uiElement.shadowRoot.querySelector(<span class="hljs-string">'.dce-sel-camera'</span>).remove();
|
|
774
|
+
<span class="hljs-comment">// Remove the resolution selection dropdown from the CameraView's UI element</span>
|
|
775
|
+
uiElement.shadowRoot.querySelector(<span class="hljs-string">'.dce-sel-resolution'</span>).remove();
|
|
776
|
+
</code></pre>
|
|
778
777
|
<p>The UI is part of the auxiliary SDK "Dynamsoft Camera Enhancer", read more on how to <a href="https://www.dynamsoft.com/barcode-reader/docs/core/programming/features/ui-customization-js.html?lang=js">customize the UI</a>.</p>
|
|
779
|
-
<h2 id="
|
|
778
|
+
<h2 id="documentation">Documentation</h2>
|
|
779
|
+
<h3 id="api-reference">API Reference</h3>
|
|
780
780
|
<p>You can check out the detailed documentation about the APIs of the SDK at<br />
|
|
781
|
-
<a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
</
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
<
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
<
|
|
824
|
-
<
|
|
825
|
-
</
|
|
826
|
-
</
|
|
827
|
-
</table>
|
|
828
|
-
<p><sup>1</sup> devices running iOS needs to be on iOS 14.3+ for camera video streaming to work in Chrome, Firefox or other Apps using webviews.</p>
|
|
829
|
-
<p>Apart from the browsers, the operating systems may impose some limitations of their own that could restrict the use of the SDK. Browser compatibility ultimately depends on whether the browser on that particular operating system supports the features listed above.</p>
|
|
830
|
-
<h2 id="how-to-upgrade">How to Upgrade</h2>
|
|
831
|
-
<p>If you want to upgrade the SDK from an old version to a newer one, please see <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/upgrade-guide/index.html?ver=10.4.2002&utm_source=npm">how to upgrade</a>.</p>
|
|
832
|
-
<h2 id="release-notes">Release Notes</h2>
|
|
833
|
-
<p>Learn about what are included in each release at <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html?ver=10.4.20&utm_source=npm">https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html</a>.</p>
|
|
781
|
+
<a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.3100">https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.3100</a>.</p>
|
|
782
|
+
<!-- Compatibility is basically not an issue. Pls remove to another place
|
|
783
|
+
|
|
784
|
+
## System Requirements
|
|
785
|
+
|
|
786
|
+
DBR requires the following features to work:
|
|
787
|
+
|
|
788
|
+
- Secure context (HTTPS deployment)
|
|
789
|
+
|
|
790
|
+
When deploying your application / website for production, make sure to serve it via a secure HTTPS connection. This is required for two reasons
|
|
791
|
+
|
|
792
|
+
- Access to the camera video stream is only granted in a security context. Most browsers impose this restriction.
|
|
793
|
+
> Some browsers like Chrome may grant the access for `http://127.0.0.1` and `http://localhost` or even for pages opened directly from the local disk (`file:///...`). This can be helpful for temporary development and test.
|
|
794
|
+
|
|
795
|
+
- Dynamsoft License requires a secure context to work.
|
|
796
|
+
|
|
797
|
+
- `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`
|
|
798
|
+
|
|
799
|
+
The above four features are required for the SDK to work.
|
|
800
|
+
|
|
801
|
+
- `MediaDevices`/`getUserMedia`
|
|
802
|
+
|
|
803
|
+
This API is required for in-browser video streaming.
|
|
804
|
+
|
|
805
|
+
- `getSettings`
|
|
806
|
+
|
|
807
|
+
This API inspects the video input which is a `MediaStreamTrack` object about its constrainable properties.
|
|
808
|
+
|
|
809
|
+
The following table is a list of supported browsers based on the above requirements:
|
|
810
|
+
|
|
811
|
+
| Browser Name | Version |
|
|
812
|
+
| :----------: | :--------------: |
|
|
813
|
+
| Chrome | v78+<sup>1</sup> |
|
|
814
|
+
| Firefox | v68+<sup>1</sup> |
|
|
815
|
+
| Edge | v79+ |
|
|
816
|
+
| Safari | v14+ |
|
|
817
|
+
|
|
818
|
+
<sup>1</sup> devices running iOS needs to be on iOS 14.3+ for camera video streaming to work in Chrome, Firefox or other Apps using webviews.
|
|
819
|
+
|
|
820
|
+
Apart from the browsers, the operating systems may impose some limitations of their own that could restrict the use of the SDK. Browser compatibility ultimately depends on whether the browser on that particular operating system supports the features listed above.
|
|
821
|
+
|
|
822
|
+
-->
|
|
823
|
+
<h3 id="how-to-upgrade">How to Upgrade</h3>
|
|
824
|
+
<p>If you want to upgrade the SDK from an old version to a newer one, please see <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/upgrade-guide/index.html?ver=10.4.3100&utm_source=npm">how to upgrade</a>.</p>
|
|
825
|
+
<h3 id="release-notes">Release Notes</h3>
|
|
826
|
+
<p>Learn about what are included in each release at <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html?ver=10.4.31&utm_source=npm">https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html</a>.</p>
|
|
834
827
|
<h2 id="next-steps">Next Steps</h2>
|
|
835
828
|
<p>Now that you have got the SDK integrated, you can choose to move forward in the following directions</p>
|
|
836
829
|
<ol>
|
|
837
830
|
<li>Learn how to <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/use-in-framework.html">Use in Framework</a></li>
|
|
838
|
-
<li>Check out the <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html?ver=10.4.
|
|
839
|
-
<li>Learn about the <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/index.html?ver=10.4.
|
|
831
|
+
<li>Check out the <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html?ver=10.4.31">Official Samples and Demo</a></li>
|
|
832
|
+
<li>Learn about the <a href="https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/index.html?ver=10.4.3100">APIs of the SDK</a></li>
|
|
840
833
|
</ol>
|
|
841
834
|
</div>
|
|
842
835
|
</body>
|