mirror of
https://github.com/ColonelParrot/jscanify.git
synced 2025-12-31 06:31:54 +00:00
Improve recognition algorithm
This commit is contained in:
parent
b6ba8178fc
commit
084b33ff76
@ -44,7 +44,7 @@ class jscanify {
|
|||||||
*/
|
*/
|
||||||
findPaperContour(img) {
|
findPaperContour(img) {
|
||||||
const imgGray = new cv.Mat();
|
const imgGray = new cv.Mat();
|
||||||
cv.cvtColor(img, imgGray, cv.COLOR_RGBA2GRAY);
|
cv.Canny(img, imgGray, 50, 200);
|
||||||
|
|
||||||
const imgBlur = new cv.Mat();
|
const imgBlur = new cv.Mat();
|
||||||
cv.GaussianBlur(
|
cv.GaussianBlur(
|
||||||
@ -69,6 +69,7 @@ class jscanify {
|
|||||||
cv.RETR_CCOMP,
|
cv.RETR_CCOMP,
|
||||||
cv.CHAIN_APPROX_SIMPLE
|
cv.CHAIN_APPROX_SIMPLE
|
||||||
);
|
);
|
||||||
|
|
||||||
let maxArea = 0;
|
let maxArea = 0;
|
||||||
let maxContourIndex = -1;
|
let maxContourIndex = -1;
|
||||||
for (let i = 0; i < contours.size(); ++i) {
|
for (let i = 0; i < contours.size(); ++i) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
class jscanify {
|
class jscanify {
|
||||||
constructor() {}
|
constructor() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the contour of the paper within the image
|
* Finds the contour of the paper within the image
|
||||||
@ -29,7 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
findPaperContour(img) {
|
findPaperContour(img) {
|
||||||
const imgGray = new cv.Mat();
|
const imgGray = new cv.Mat();
|
||||||
cv.cvtColor(img, imgGray, cv.COLOR_RGBA2GRAY);
|
cv.Canny(img, imgGray, 50, 200);
|
||||||
|
|
||||||
const imgBlur = new cv.Mat();
|
const imgBlur = new cv.Mat();
|
||||||
cv.GaussianBlur(
|
cv.GaussianBlur(
|
||||||
@ -47,7 +47,7 @@
|
|||||||
imgThresh,
|
imgThresh,
|
||||||
0,
|
0,
|
||||||
255,
|
255,
|
||||||
cv.THRESH_BINARY + cv.THRESH_OTSU
|
cv.THRESH_OTSU
|
||||||
);
|
);
|
||||||
|
|
||||||
let contours = new cv.MatVector();
|
let contours = new cv.MatVector();
|
||||||
@ -60,6 +60,7 @@
|
|||||||
cv.RETR_CCOMP,
|
cv.RETR_CCOMP,
|
||||||
cv.CHAIN_APPROX_SIMPLE
|
cv.CHAIN_APPROX_SIMPLE
|
||||||
);
|
);
|
||||||
|
|
||||||
let maxArea = 0;
|
let maxArea = 0;
|
||||||
let maxContourIndex = -1;
|
let maxContourIndex = -1;
|
||||||
for (let i = 0; i < contours.size(); ++i) {
|
for (let i = 0; i < contours.size(); ++i) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user