0

I am using QuaggaJS. On the home page there, it has basic descriptions of its main methods, as well as an example html folder in its downloadable zip. My problem, is that one of the example HTMLs is called static_images. This takes in image src's for its scanning procedure, but I cannot figure out how to give it a custom single src that I specify. (The example HTML seems to use a pre-set list of images in the folder).

I read (on QuaggaJS git homepage) that the method Quagga.decodeSingle(config, callback) does exactly what I want.

In contrast to the calls described above, this method does not rely on getUserMedia and operates on a single image instead. The provided callback is the same as in onDetected and contains the result data object.

But I cannot figure out how to implement that method into his example code. Can someone guide me, and explain, how I am to implement that method within QuaggaJS? (quagga/example/static_images.html/js)

Austin
  • 3,010
  • 23
  • 62
  • 97

1 Answers1

1

The method Quagga.decodeSingle takes an object as the first parameter (config) that has a property called "src". You can pass your src to this property.

The example the author gives is:

Quagga.decodeSingle({
          readers: ['code_128_reader'],
  locate: true, // try to locate the barcode in the image
  src: '/test/fixtures/code_128/image-001.jpg' // or 'data:image/jpg;base64,' + data
}, function(result){
  console.log(result);
});

where the readers property indicates the method will only decode code_128 barcodes. You can add the other barcode types in this array, which are basically the names of the protocols with underscores instead of spaces with "_reader" at the end (e.g., ["code_128_reader", "code_39_reader", "code_39_vin_reader", "ean_reader", "ean_8_reader", "upc_reader", "upc_e_reader", "codabar_reader"]).

longestwayround
  • 979
  • 9
  • 13