Appearance
Mobile Document Scanner API Reference / DocumentNormalizerView
Class: DocumentNormalizerView
Defined in: src/views/DocumentCorrectionView.ts:191
Constructors
Constructor
new DocumentNormalizerView(
resources,config,scannerView?):DocumentCorrectionView
Defined in: src/views/DocumentCorrectionView.ts:222
Parameters
resources
SharedResources
config
scannerView?
Returns
DocumentCorrectionView
Methods
confirmCorrection()
confirmCorrection():
Promise<void>
Defined in: src/views/DocumentCorrectionView.ts:839
Confirm the boundary adjustments and apply perspective correction to the image.
Returns
Promise<void>
Throws
If no quadrilateral boundary is found on the drawing layer
Remarks
Retrieves boundary, performs correction via correctImage, updates result, invokes callback, resolves promise.
correctImage()
correctImage(
points):Promise<DeskewedImageResultItem|undefined>
Defined in: src/views/DocumentCorrectionView.ts:927
Apply perspective correction to the document image using Dynamsoft Document Normalizer (DDN).
Parameters
points
[Point, Point, Point, Point]
The quadrilateral corner points defining the document boundary
Returns
Promise<DeskewedImageResultItem | undefined>
The perspective-corrected (deskewed) image, or undefined if correction fails
Remarks
Configures ROI with quadrilateral points, processes image with normalization template.
dispose()
dispose(
preserveResolver?):void
Defined in: src/views/DocumentCorrectionView.ts:963
Clean up and release resources.
Parameters
preserveResolver?
boolean = false
Whether to preserve the currentCorrectionResolver promise resolver
Returns
void
Remarks
Disposes ImageEditorView, clears layer and container. Optionally preserves resolver for handleRetake.
hideView()
hideView():
void
Defined in: src/views/DocumentCorrectionView.ts:911
Hide the correction view by setting its container display to "none".
Returns
void
Remarks
Sets container display to "none" without disposing resources.
initialize()
initialize():
Promise<void>
Defined in: src/views/DocumentCorrectionView.ts:233
Returns
Promise<void>
launch()
launch():
Promise<DocumentResult>
Defined in: src/views/DocumentCorrectionView.ts:870
Returns
Promise<DocumentResult>
setBoundaryAutomatically()
setBoundaryAutomatically():
Promise<void>
Defined in: src/views/DocumentCorrectionView.ts:796
Automatically detect document boundaries using Dynamsoft Document Normalizer (DDN).
Returns
Promise<void>
Remarks
This method re-runs document boundary detection on the current image using the CaptureVisionRouter and DDN (Dynamsoft Document Normalizer) engine. The process:
- Initializes settings from DocumentCorrectionViewConfig.templateFilePath if provided
- Retrieves the detection template settings via DocumentCorrectionViewConfig.utilizedTemplateNames
- Configures the router to:
- Output the original image for further processing
- Process images at full resolution (no downscaling via
maxImageSideLength = Infinity)
- Captures and analyzes the image to detect document boundaries
- Handles the detection result:
- Boundary detected: Creates a QuadDrawingItem from the detected Quadrilateral and adds it to the layer via
addQuadToLayer - No boundary detected: Falls back to setFullImageBoundary to use full image dimensions
- Boundary detected: Creates a QuadDrawingItem from the detected Quadrilateral and adds it to the layer via
This allows users to retry automatic detection if:
- Manual adjustments were made but proved unsatisfactory
- Initial detection failed due to lighting or positioning issues that were later corrected
- The image was uploaded without initial detection
Triggered by clicking the "Detect Borders" button created in createControls.
See
CaptureVisionRouter- Processes the image for boundary detection- DetectedQuadResultItem - Contains the detected document boundaries
addQuadToLayer- Adds the detected quadrilateral to the drawing layer- setFullImageBoundary - Fallback when no boundaries are detected
SharedResources.cvRouter- The router instance used for detection
setFullImageBoundary()
setFullImageBoundary():
void
Defined in: src/views/DocumentCorrectionView.ts:743
Reset the document boundary to match the full image dimensions.
Returns
void
Throws
If no captured image is available in SharedResources.result
Remarks
This method creates a quadrilateral boundary that encompasses the entire image, effectively disabling perspective correction. The quadrilateral corners are positioned at:
- Top-left: (0, 0)
- Top-right: (width, 0)
- Bottom-right: (width, height)
- Bottom-left: (0, height)
This is useful when:
- The document occupies the entire image with no background visible
- Automatic boundary detection failed or detected incorrect boundaries
- Users want to skip perspective correction and use the original image dimensions
The created quadrilateral is added to the DrawingLayer via addQuadToLayer, replacing any existing boundary. Users can still manually adjust the corners after reset.
Triggered by clicking the "Full Image" button created in createControls.
See
SharedResources.result- Contains the original image dimensions- QuadDrawingItem - The quadrilateral type added to the drawing layer
addQuadToLayer- Adds the full-image quadrilateral to the layer- setBoundaryAutomatically - Alternative method for automatic boundary detection