diff --git a/src/jscanify-node.js b/src/jscanify-node.js index 2351ee8..7dbb3de 100644 --- a/src/jscanify-node.js +++ b/src/jscanify-node.js @@ -187,11 +187,6 @@ class jscanify { ); cv.imshow(canvas, warpedDst); - const canvasContext = canvas.getContext("2d"); - canvasContext.save(); - canvasContext.scale(1, -1); - canvasContext.drawImage(canvas, 0, -resultHeight); - canvasContext.restore(); img.delete(); warpedDst.delete(); @@ -222,25 +217,25 @@ class jscanify { for (let i = 0; i < contour.data32S.length; i += 2) { const point = { x: contour.data32S[i], y: contour.data32S[i + 1] }; const dist = distance(point, center); - if (point.x < center.x && point.y > center.y) { + if (point.x < center.x && point.y < center.y) { // top left if (dist > topLeftCornerDist) { topLeftCorner = point; topLeftCornerDist = dist; } - } else if (point.x > center.x && point.y > center.y) { + } else if (point.x > center.x && point.y < center.y) { // top right if (dist > topRightCornerDist) { topRightCorner = point; topRightCornerDist = dist; } - } else if (point.x < center.x && point.y < center.y) { + } else if (point.x < center.x && point.y > center.y) { // bottom left if (dist > bottomLeftCornerDist) { bottomLeftCorner = point; bottomLeftCornerDist = dist; } - } else if (point.x > center.x && point.y < center.y) { + } else if (point.x > center.x && point.y > center.y) { // bottom right if (dist > bottomRightCornerDist) { bottomRightCorner = point; diff --git a/src/jscanify.js b/src/jscanify.js index 47f6706..b2c0541 100644 --- a/src/jscanify.js +++ b/src/jscanify.js @@ -184,11 +184,6 @@ ); cv.imshow(canvas, warpedDst); - const canvasContext = canvas.getContext("2d"); - canvasContext.save() - canvasContext.scale(1, -1) - canvasContext.drawImage(canvas, 0, -resultHeight) - canvasContext.restore() img.delete() warpedDst.delete() @@ -219,25 +214,25 @@ for (let i = 0; i < contour.data32S.length; i += 2) { const point = { x: contour.data32S[i], y: contour.data32S[i + 1] }; const dist = distance(point, center); - if (point.x < center.x && point.y > center.y) { + if (point.x < center.x && point.y < center.y) { // top left if (dist > topLeftCornerDist) { topLeftCorner = point; topLeftCornerDist = dist; } - } else if (point.x > center.x && point.y > center.y) { + } else if (point.x > center.x && point.y < center.y) { // top right if (dist > topRightCornerDist) { topRightCorner = point; topRightCornerDist = dist; } - } else if (point.x < center.x && point.y < center.y) { + } else if (point.x < center.x && point.y > center.y) { // bottom left if (dist > bottomLeftCornerDist) { bottomLeftCorner = point; bottomLeftCornerDist = dist; } - } else if (point.x > center.x && point.y < center.y) { + } else if (point.x > center.x && point.y > center.y) { // bottom right if (dist > bottomRightCornerDist) { bottomRightCorner = point;