How to use the jsqr.decodeQRFromImage function in jsqr

To help you get started, we’ve selected a few jsqr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jywarren / image-sequencer / src / modules / DecodeQr / Module.js View on Github external
getPixels(input.src,function(err,pixels){

      if(err) throw err;

      var w = pixels.shape[0];
      var h = pixels.shape[1];
      var decoded = jsQR.decodeQRFromImage(pixels.data,w,h);

      // This output is accessible to Image Sequencer
      step.output = input;
      step.output.data = decoded;

      // Tell Image Sequencer that this step is complete
      callback();
      options.step.qrval = decoded;

    });
github NGRP / node-red-contrib-viseo / node-red-contrib-qrcode / node-qrcode.js View on Github external
jimp.read(buffer, (err, image) => {
    if (err){ return callback(err); }
    
    // 2. Decode QRCode
    let data = jsQr.decodeQRFromImage(image.bitmap.data, image.bitmap.width, image.bitmap.height);

    // 3. Check is JSON
    try { 
      let json = JSON.parse(data); 
      return callback(undefined, json);
    } catch (ex) { /* exception */ }

    // 4. Is string
    if (data.indexOf('http') !== 0) {
      return callback(undefined, { 'text' : data });
    }
    
    // 5. Parse URL parameters
    let qs  = data.indexOf('?')
    if (qs  < 0) return callback(undefined, { url : data });
github NGRP / node-red-contrib-viseo / node-red-contrib-qrDecode / node-qrDecode.js View on Github external
jimp.read(buffer, (err, image) => {
    if(err){
      return node.error(err);
    }

    //Decode
    let jsonQrData = jsQr.decodeQRFromImage(image.bitmap.data, image.bitmap.width, image.bitmap.height);
    //safe parsing of qrCode message to json object
    try {
      msg[node.output] = JSON.parse(jsonQrData);
    } catch (ex) {
      //if it is an URL
      if(jsonQrData.match(/^http(s)?:\/\//)){
        //Save the full URL
        let urlTab, params, paramsTab, url = jsonQrData;
        msg[node.output] = {};
        msg[node.output].url = url;
        urlTab = url.split('?');
        if(urlTab.length > 1){
          params = urlTab[1];
          msg[node.output].params = {};
          paramsTab = params.split('&');
          //Save every params of the URL in an object
github ArkEcosystem / desktop-wallet / client / app / src / components / qr-scanner / qr-scanner.controller.js View on Github external
var scan = function (evt) {
      if ($window.localMediaStream) {
        var size = 250

        context.drawImage(video, 0, 0, size, size)
        var imageData = context.getImageData(0, 0, size, size)
        var decoded = jsqr.decodeQRFromImage(imageData.data, size, size)

        if (typeof (decoded) !== 'undefined' && decoded.length > 0) {
          cancel()
          $scope.onSuccess(parseDecoded(decoded))
        }
      }
    }

jsqr

A pure javascript QR code reading library that takes in raw images and will locate, extract and parse any QR code found within.

Apache-2.0
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis

Similar packages