Download the PHP package dynamsoft/javascript-barcode without Composer

On this page you can find all versions of the php package dynamsoft/javascript-barcode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package javascript-barcode

Barcode Reader for Your Website - User Guide

Dynamsoft Barcode Reader JavaScript Edition (DBR-JS) is equipped with industry-leading algorithms for exceptional speed, accuracy and read rates in barcode reading. Using its well-designed API, you can turn your web page into a barcode scanner with just a few lines of code.

version downloads jsdelivr

version downloads jsdelivr

Once the DBR-JS SDK gets integrated into your web page, your users can access a camera via the browser and read barcodes directly from its video input.

In this guide, you will learn step by step on how to integrate the DBR-JS SDK into your website.

Table of Contents

Popular Examples

You can also:

Hello World - Simplest Implementation

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.

Basic Requirements

Understand the code

The complete code of the "Hello World" example is shown below

Code in Github   Run via JSFiddle   Run in Dynamsoft


About the code

Read more on Capture Vision Router.

Run the example

You can run the example deployed to the Dynamsoft Demo Server or test it with JSFiddle code editor.

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.

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.

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.

Note:

If you open the web page as file:/// or http:// , the camera may not work correctly because the MediaDevices: getUserMedia() method only works in secure contexts (HTTPS), in some or all supporting browsers.

To make sure your web application can access the camera, please configure your web server to support HTTPS. The following links may help.

  1. NGINX: Configuring HTTPS servers
  2. IIS: How to create a Self Signed Certificate in IIS
  3. Tomcat: Setting Up SSL on Tomcat in 5 minutes
  4. Node.js: npm tls

If the test doesn't go as expected, you can contact us.

Building your own page

Include the SDK

To utilize the SDK, the initial step involves including the corresponding resource files:

For simplification, starting from version 10.2.10, we introduced dbr.bundle.js. Including this file is equivalent to incorporating all six packages.

Use a public CDN

The simplest way to include the SDK is to use either the jsDelivr or UNPKG CDN. The "hello world" example above uses jsDelivr.

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.

However, please DO NOT use download2.dynamsoft.com resources in a production application as they are for temporary testing purposes only. Instead, you can try hosting the SDK yourself.

Host the SDK yourself (optional)

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.

Options to download the SDK:

Depending on how you downloaded the SDK and how you intend to use it, you can typically include it like this

Note:

Prepare the SDK

Before using the SDK, you need to configure a few things.

Specify the license

To enable the SDK's functionality, you must provide a valid license. Utilize the API function initLicense to set your license key.

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 customer portal.

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.

Specify the location of the "engine" files (optional)

This is usually only required with frameworks like Angular or React, etc. where the referenced JavaScript files such as cvr.js, dbr.js are compiled into another file.

The purpose is to tell the SDK where to find the engine files (*.worker.js, *.wasm.js and *.wasm, etc.). The API is called Dynamsoft.Core.CoreModule.engineResourcePaths:

Set up and start image processing

Preload the module

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.

Create a CaptureVisionRouter object

To use the SDK, we first create a CaptureVisionRouter object.

Tip:

When creating a CaptureVisionRouter object within a function which may be called more than once, it's best to use a "helper" variable to avoid double creation such as pRouter in the following code:

Connect an image source

The CaptureVisionRouter object, denoted as router, 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 CameraEnhancer object, identified as cameraEnhancer, which is specifically designed to capture image frames from the video feed and subsequently forward them to router.

To enable video streaming on the webpage, we create a CameraView object referred to as view, which is then passed to cameraEnhancer, and its content is displayed on the webpage.

Register a result receiver

Once the image processing is complete, the results are sent to all the registered CapturedResultReceiver objects. Each CapturedResultReceiver object may encompass one or multiple callback functions associated with various result types. In our particular case, our focus is on identifying barcodes within the images, so it's sufficient to define the callback function onDecodedBarcodesReceived:

You can also write code like this. It is the same.

Check out CapturedResultReceiver for more information.

Start the process

With the setup now complete, we can proceed to process the images in two straightforward steps:

  1. Initiate the image source to commence image acquisition. In our scenario, we invoke the open() method on cameraEnhancer to initiate video streaming and simultaneously initiate the collection of images. These collected images will be dispatched to router as per its request.
  2. Define a preset template to commence image processing. In our case, we utilize the "ReadSingleBarcode" template, specifically tailored for processing images containing a single barcode.

Note:

Template Name Function Description
ReadBarcodes_Default Scans a single barcode.
ReadSingleBarcode Quickly scans a single barcode.
ReadBarcodes_SpeedFirst Prioritizes speed in scanning multiple barcodes.
ReadBarcodes_ReadRateFirst Maximizes the number of barcodes read.
ReadBarcodes_Balance Balances speed and quantity in reading multiple barcodes.
ReadDenseBarcodes Specialized in reading barcodes with high information density.
ReadDistantBarcodes Capable of reading barcodes from extended distances.

Read more on the preset CaptureVisionTemplates.

Customize the process

Adjust the preset template settings

When making adjustments to some basic tasks, we often only need to modify SimplifiedCaptureVisionSettings.

Change barcode settings

The preset templates can be updated to meet different requirements. For example, the following code limits the barcode format to QR code.

For a list of adjustable barcode settings, check out SimplifiedBarcodeReaderSettings.

Retrieve the original image

Additionally, we have the option to modify the template to retrieve the original image containing the barcode.

Limit the barcode format to QR code, and retrieve the original image containing the barcode, at the same time.

Please be aware that it is necessary to update the CapturedResultReceiver object to obtain the original image. For instance:

Change reading frequency to save power

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:

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.

Specify a scan region

You can use the parameter roi (region of interest) together with the parameter roiMeasuredInPercentage to configure the SDK to only read a specific region on the image frames. For example, the following code limits the reading in the center 25%( = 50% * 50%) of the image frames:

While the code above accomplishes the task, a more effective approach is to restrict the scan region directly at the image source, as demonstrated in the following code snippet.

  • With the region configured at the image source, the images are cropped right before they are gathered for processing, eliminating the necessity to modify the processing settings further.
  • cameraEnhancer elevates interactivity by overlaying a mask on the video, providing a clear delineation of the scanning region.
  • See also: CameraEnhancer::setScanRegion

Edit the preset templates directly

The preset templates have a lot more settings that can be customized to best suit your use case. If you download the SDK from Dynamsoft website, you can find the templates under

Upon completing the template editing, you can invoke the initSettings method and provide it with the template path as an argument.

Filter the results (Important)

While processing video frames, it's common for the same barcode to be detected multiple times. To enhance the user experience, we can use MultiFrameResultCrossFilter object, having two options currently at our disposal:

Option 1: Verify results across multiple frames

Note:

Option 2: Eliminate redundant results detected within a short time frame

Note:

Initially, the filter is set to forget a result 3 seconds after it is first received. During this time frame, if an identical result appears, it is ignored.

It's important to know that in version 9.x or earlier, the occurrence of an identical result would reset the timer, thus reinitiating the 3-second count at that point. However, in version 10.2.10 and later, an identical result no longer resets the timer but is instead disregarded, and the duration count continues uninterrupted.

Under certain circumstances, this duration can be extended with the method setDuplicateForgetTime().

You can also enable both options at the same time:

Add feedback

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".

The following code snippet adds a "beep" sound for when a barcode is found:

Customize the UI

The UI is part of the auxiliary SDK "Dynamsoft Camera Enhancer", read more on how to customize the UI.

API Documentation

You can check out the detailed documentation about the APIs of the SDK at https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.2.10.

System Requirements

DBR requires the following features to work:

The following table is a list of supported browsers based on the above requirements:

Browser Name Version
Chrome v78+1
Firefox v62+1
Edge v79+
Safari v14+

1 devices running iOS needs to be on iOS 14.3+ for camera video streaming to work in Chrome, Firefox or other Apps using webviews.

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.

How to Upgrade

If you want to upgrade the SDK from an old version to a newer one, please see how to upgrade.

Release Notes

Learn about what are included in each release at https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html.

Next Steps

Now that you have got the SDK integrated, you can choose to move forward in the following directions

  1. Check out the Official Samples and Demo
  2. Learn about the APIs of the SDK

All versions of javascript-barcode with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dynamsoft/javascript-barcode contains the following files

Loading the files please wait ....