code: function scanBarcode() {
    if (isPaused) {
      return;
    }
  
    var data = null,
      context = null,
      width = 0,
      height = 0,
      dbrCanvas = null;
  
    if (isPC) {
      context = ctx;
      width = videoWidth;
      height = videoHeight;
      dbrCanvas = canvas;
    } else {
      context = mobileCtx;
      width = mobileVideoWidth;
      height = mobileVideoHeight;
      dbrCanvas = mobileCanvas;
    }
  
    context.drawImage(videoElement, 0, 0, width, height);
    // convert canvas to base64
    var base64 = dbrCanvas.toDataURL('image/png', 1.0);
    var imgData = base64.replace(/^data:image\/(png|jpeg|jpg);base64,/, "");
    // var imgData = JSON.stringify(data);
    $.ajax({
      url: '/dbr',
      dataType: 'json',
      data: imgData,
      type: 'POST',
      success: function (result) {
        console.log(result);
        if (isPaused) {
          return;
        }
        var barcode_result = document.getElementById('dbr');
        barcode_result.textContent = result;
  
        // display barcode result
        if (result.indexOf("No barcode") == -1) {
          isPaused = true;
          buttonGo.disabled = false;
          if (isPC) {
            canvas.style.display = 'block';
          } else {
            mobileCanvas.style.display = 'block';
          }
        }
        else {
          setTimeout(scanBarcode, 200);
        }
      }
    });
  }
docs: scan barcode