Perspective Viewer
Perspective Viewer is used to do page boundaries manual adjustment & perspective transformation. The page data displayed on this viewer is its original data.
const perspectiveViewer = new Dynamsoft.DDV.PerspectiveViewer({
container: document.getElementById("viewer"),
});
perspectiveViewer.openDocument("docUid"); // Open a document which has pages
Quadrilateral selection
Quadrilateral Selection in the perspective viewer means the selection which will be perspective transformed.
In addition to drawing and adjusting the selection through the UI, DDV also provides some additional interfaces to operate the selection.
-
Set a quadrilateral selection on the current page by using
setQuadSelection()
. If the selection is exceeds the bounds of the current page, it won’t take effect.const quad = [ [314,518], [2200,625], [2204,3339], [176,3048] ]; perspectiveViewer.setQuadSelection(quad);
-
Get the quadrilateral selection on the current page by using
getQuadSelection()
.const quad = perspectiveViewer.getQuadSelection();
-
Reset the quadrilateral selection to the original one by using
resetQuadSelection()
. The original selection on the page can be detected by Document Detect during capturing in the capture viewer or set byExtraPageData
inloadSource()
when loading the page. If it is not detected or set before, the original selection would be the whole page range.perspectiveViewer.resetQuadSelection();
Perspective transformation
Perspective transformation in the perspective viewer is to rectify the quadrilateral selection. It is implemented by the method applyPerspective()
.
const quad = perspectiveViewer.getQuadSelection();
await perspectiveViewer.applyPerspective(quad);