photoRaw"),points);
        document.getElementById("output").src = canvas.toDataURL();
      }

      async function loadImageToDoc(dataURL) {
        const response = await fetch(dataURL);
        const blob = await response.blob();
        await doc.loadSource(blob);
      }

      function showPerspectiveViewer(points){
        document.getElementById("perspectiveViewer").style.display = "block";
        const quad = [];
        points.forEach(point => {
          quad.push([point.x,point.y]);
        }