ringify(qr) : ''}: ${text}`).join('\n');

    if (digitize.checked) {
      img.data.set(digitized.data);
      ctx.putImageData(img, 0, 0);
    }

    // draw found rectangle
    detected.forEach(({ points }) => {
      ctx.beginPath();
      ctx.strokeStyle = 'red';
      ctx.moveTo(... points[0]);
      ctx.lineTo(... points[1]);
      ctx.lineTo(... points[2]);
      ctx.lineTo(... points[3]);
      ctx.lineTo(... points[0]);
      ctx.stroke();
    });

  } catch (e) {
    console.error(e);
  }
}

file