  
npm install opencv-document-scannerbash
npm install opencv-document-scanner
`
Via CDN:
`html
`
You also need to include OpenCV:
`html
`
Usage
1. Initialize an instance.
`js
const documentScanner = new DocumentScanner();
`
2. Detect the polygon of documents and return the points.
`js
const imgElement = document.getElementById("photoRaw");
const points = documentScanner.detect(imgElement, {useCanny:false}); //detect from an img or canvas element. You can use canny edge detection to detect document with uneven lightings. If the contrast of the background and the document is vivid, then you don't need to enable this.
`
3. Get the cropped document image.
`js
let imgElement = document.getElementById("photoRaw")
const canvas = documentScanner.crop(imgElement); //get cropped image from an img or canvas element
`
4. Live scanning with camera using Dynamsoft Document Viewer.
`html
`
!image
5. Edit the polygon with Dynamsoft Document Viewer.
`js
const points = documentScanner.detect(imgElement);
const quad = [];
points.forEach(point => {
quad.push([point.x,point.y]);
});
perspectiveViewer.setQuadSelection(quad);
``