Streamline node & web flip

This commit is contained in:
ColonelParrot 2023-05-09 19:17:09 -04:00
parent 90cf5246c8
commit c1ed3c8339

View File

@ -20,7 +20,7 @@
}
class jscanify {
constructor() { }
constructor() {}
/**
* Finds the contour of the paper within the image
@ -184,26 +184,15 @@
);
cv.imshow(canvas, warpedDst);
const canvasContext = canvas.getContext("2d");
canvasContext.save()
canvasContext.scale(1, -1)
canvasContext.drawImage(canvas, 0, -resultHeight)
canvasContext.restore()
const newImg = document.createElement("img");
newImg.src = canvas.toDataURL();
newImg.onload = function () {
// flip unwarped image
let ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
canvas.width = resultWidth;
canvas.height = resultHeight;
ctx.setTransform(1, 0, 0, -1, 0, canvas.height);
ctx.drawImage(newImg, 0, 0);
ctx.setTransform(1, 0, 0, 1, 0, 0);
img.delete();
warpedDst.delete();
onComplete(canvas);
};
img.delete()
warpedDst.delete()
onComplete(canvas)
}
/**
@ -264,7 +253,6 @@
bottomRightCorner,
};
}
}
return jscanify;