Compare commits

..

6 Commits

Author SHA1 Message Date
ColonelParrot
9749c97498
Update README.md 2025-02-01 21:12:20 -05:00
ColonelParrot
57bf40f3fb bump to v1.3.3 2025-02-01 21:10:04 -05:00
ColonelParrot
c8e6ab035d Add null check in extractPaper 2025-02-01 21:06:30 -05:00
ColonelParrot
e2af210cf2 port bugfix to node 2025-02-01 21:01:53 -05:00
Leon Scherer
f0428d79ca fix: sending invalid index to opencv 2025-02-01 20:23:48 -05:00
ColonelParrot
a447c90039 add wiki link 2025-01-29 13:01:03 -05:00
4 changed files with 29 additions and 10 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "jscanify",
"version": "1.2.0",
"version": "1.3.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "jscanify",
"version": "1.2.0",
"version": "1.3.3",
"license": "MIT",
"dependencies": {
"canvas": "^2.11.2",

View File

@ -1,6 +1,6 @@
{
"name": "jscanify",
"version": "1.3.2",
"version": "1.3.3",
"description": "Open-source Javascript mobile document scanner.",
"main": "src/jscanify-node.js",
"directories": {

View File

@ -1,4 +1,4 @@
/*! jscanify v1.3.2 | (c) ColonelParrot and other contributors | MIT License */
/*! jscanify v1.3.3 | (c) ColonelParrot and other contributors | MIT License */
const { Canvas, createCanvas, Image, ImageData } = require("canvas");
const { JSDOM } = require("jsdom");
@ -80,7 +80,10 @@ class jscanify {
}
}
const maxContour = contours.get(maxContourIndex);
const maxContour =
maxContourIndex >= 0 ?
contours.get(maxContourIndex) :
null;
imgGray.delete();
imgBlur.delete();
@ -138,6 +141,9 @@ class jscanify {
/**
* Extracts and undistorts the image detected within the frame.
*
* Returns `null` if no paper is detected.
*
* @param {*} image image to process
* @param {*} resultWidth desired result paper width
* @param {*} resultHeight desired result paper height
@ -148,6 +154,11 @@ class jscanify {
const canvas = createCanvas();
const img = cv.imread(image);
const maxContour = this.findPaperContour(img);
if(maxContour == null){
return null;
}
const {
topLeftCorner,
topRightCorner,

View File

@ -1,4 +1,4 @@
/*! jscanify v1.3.2 | (c) ColonelParrot and other contributors | MIT License */
/*! jscanify v1.3.3 | (c) ColonelParrot and other contributors | MIT License */
(function (global, factory) {
typeof exports === "object" && typeof module !== "undefined"
@ -71,7 +71,10 @@
}
}
const maxContour = contours.get(maxContourIndex);
const maxContour =
maxContourIndex >= 0 ?
contours.get(maxContourIndex) :
null;
imgGray.delete();
imgBlur.delete();
@ -129,6 +132,9 @@
/**
* Extracts and undistorts the image detected within the frame.
*
* Returns `null` if no paper is detected.
*
* @param {*} image image to process
* @param {*} resultWidth desired result paper width
* @param {*} resultHeight desired result paper height
@ -137,11 +143,13 @@
*/
extractPaper(image, resultWidth, resultHeight, cornerPoints) {
const canvas = document.createElement("canvas");
const img = cv.imread(image);
const maxContour = this.findPaperContour(img);
if(maxContour == null){
return null;
}
const {
topLeftCorner,
topRightCorner,