Closed YSternlicht closed 1 year ago
Hello!
It seems like you misassigned the paperContour
variable. It should be:
const paperContour = scanner.findPaperContour(cv.imread(image));
getCornerPoints
accepts a contour as the parameter. You're passing the parsed image, not the contour.
Your final code should be:
window.addEventListener("load", () => {
cv['onRuntimeInitialized'] = () => {
const scanner = new jscanify();
const image = document.getElementById("image");
const paperContour = scanner.findPaperContour(cv.imread(image));
const {
topLeftCorner,
topRightCorner,
bottomLeftCorner,
bottomRightCorner,
} = scanner.getCornerPoints(paperContour, image);
console.log("topLeftCorner", topLeftCorner);
console.log("topRightCorner", topRightCorner);
console.log("bottomLeftCorner", bottomLeftCorner);
console.log("bottomRightCorner", bottomRightCorner);
}
})
Hope this helps!
Sorry my bad. Works now. Thanks so much.
I am trying to get the cornerPoints from a scanned image to see how wide the pdf atcually is. However, when
scanner.getCornerPoints(paperContour, image)
the console will throw an ambigous error in theopencv.js
file as followsuncaught (in promise) 23302432
.Below is a minimal example which shows this error (image with pdf not included)