Barcode Reader

This code sample shows how to read a barcode using the Image Capture API and Barcode Detection API. The code works only in a  secure environment (HTTPS).

Readings

ImageCapture – Web APIs | MDN (mozilla.org)
Barcode Detection API – Web APIs | MDN (mozilla.org)

Usage

Click the editbox below, the rear camera of the device is activated, frame the barcode and touch it.


if (!("BarcodeDetector" in window))  else
  log("Barcode Detector supported!");

let track, imageCapture, barcodeDetector;

function frameBarcode() 

function readBarcode(event) 

 Last update 2023-05-31 04:51