-
Notifications
You must be signed in to change notification settings - Fork 79
API
These are the methods offered by the jscanify API.
This reference gives you a better understanding of the library's capabilities.
Tip
any parameter of type jscanifyImage is a value that cv.imread can process. This includes the HTMLImageElement, HTMLCanvasElement and File.
Method signature:
findPaperContour(mat: cv.Mat): cv.MatThis method finds the contour of the paper within the image matrix.
Returns an image matrix containing the contour, to be passed to getCornerPoints.
Method signature:
highlightPaper(image: jscanifyImage, options: object): HTMLCanvasElementThis method detects the paper in the image and returns a canvas with the image highlighted.
The options allow the color and thickness of the highlight to be customized:
{
"color": "#FFFFFF",
"thickness": 15
}Method signature:
extractPaper(image: jscanifyImage, resultWidth: width, resultHeight: width, cornerPoints?: object): HTMLCanvasElement | nullThis method extracts the paper in the image with dimensions resultWidth x resultHeight and returns a canvas of it.
Optionally, you can provide custom corner points. If custom points are supplied, the detection is skipped, saving compute, and only the perspective correction is applied.
Method signature:
getCornerPoints(contour: cv.Mat): objectCalculates the corner points of a contour, returning a result in the following format:
{
topLeftCorner: { x: ..., y: ... },
topRightCorner: { x: ..., y: ... },
bottomLeftCorner: { x: ..., y: ... },
bottomRightCorner: { x: ..., y: ... },
}