From 4c8ad93057241b78d341aeb3152552a1a0cb50f2 Mon Sep 17 00:00:00 2001 From: ColonelParrot <65585002+ColonelParrot@users.noreply.github.com> Date: Thu, 13 Apr 2023 16:27:45 -0400 Subject: [PATCH] Add README.md --- README.md | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1fdaca --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +
+
+
+Open-source pure Javascript implemented mobile document scanner. Powered with opencv.js
+Available on npm or via cdn
+
|
|
+|
|
|
+
+## Quickstart
+
+### Import
+
+npm:
+
+```js
+$ npm i jscanify
+import jscanify from 'jscanify'
+```
+
+cdn:
+
+```html
+
+
+
+```
+
+### Highlight Paper in Image
+
+```html
+
+```
+
+```js
+const scanner = new jscanify();
+image.onload = function () {
+ const highlightedCanvas = scanner.highlightPaper(image);
+ document.body.appendChild(highlightedCanvas);
+};
+```
+
+### Extract Paper
+
+```js
+const scanner = new jscanify();
+const paperWidth = 500;
+const paperHeight = 1000;
+image.onload = function () {
+ scanner.extractPaper(image, paperWidth, paperHeight, (resultCanvas) => {
+ document.body.appendChild(resultCanvas);
+ });
+};
+```
+
+### Highlighting Paper in User Camera
+
+The following code continuously reads from the user's camera and highlights the paper:
+
+```html
+
+
+
+```
+
+```js
+const scanner = new jscanify();
+const canvasCtx = canvas.getContext("2d");
+const resultCtx = result.getContext("2d");
+navigator.mediaDevices.getUserMedia({ video: true }).then((stream) => {
+ video.srcObject = stream;
+ video.onloadedmetadata = () => {
+ video.play();
+
+ setInterval(() => {
+ canvasCtx.drawImage(video, 0, 0);
+ const resultCanvas = scanner.highlightPaper(canvas);
+ resultCtx.drawImage(resultCanvas, 0, 0);
+ }, 10);
+ };
+});
+```
+### Notes
+- for optimal paper detection, the paper should be placed on a flat surface with a solid background color
+- we recommend wrapping your code using `jscanify` in a window `load` event listener to ensure OpenCV is loaded
\ No newline at end of file