1
- import { DSImageData , OriginalImageResultItem , Quadrilateral , EngineResourcePaths } from 'dynamsoft-core' ;
1
+ import { DSImageData , Quadrilateral , OriginalImageResultItem , EngineResourcePaths } from 'dynamsoft-core' ;
2
2
export * from 'dynamsoft-core' ;
3
3
export * from 'dynamsoft-license' ;
4
4
import { CapturedResult , CaptureVisionRouter } from 'dynamsoft-capture-vision-router' ;
@@ -28,7 +28,8 @@ declare enum EnumFlowType {
28
28
MANUAL = "manual" ,
29
29
SMART_CAPTURE = "smartCapture" ,
30
30
AUTO_CROP = "autoCrop" ,
31
- UPLOADED_IMAGE = "uploadedImage"
31
+ UPLOADED_IMAGE = "uploadedImage" ,
32
+ STATIC_FILE = "staticFile"
32
33
}
33
34
type ResultStatus = {
34
35
code : EnumResultStatus ;
@@ -37,7 +38,7 @@ type ResultStatus = {
37
38
interface DocumentResult {
38
39
status : ResultStatus ;
39
40
correctedImageResult ?: NormalizedImageResultItem | DSImageData ;
40
- originalImageResult ?: OriginalImageResultItem [ "imageData" ] ;
41
+ originalImageResult ?: DSImageData ;
41
42
detectedQuadrilateral ?: Quadrilateral ;
42
43
_flowType ?: EnumFlowType ;
43
44
}
@@ -52,61 +53,37 @@ interface ToolbarButton {
52
53
isHidden ?: boolean ;
53
54
}
54
55
55
- interface DocumentCorrectionViewToolbarButtonsConfig {
56
- fullImage ?: ToolbarButtonConfig ;
57
- detectBorders ?: ToolbarButtonConfig ;
58
- apply ?: ToolbarButtonConfig ;
59
- }
60
- interface DocumentCorrectionViewConfig {
61
- container ?: HTMLElement | string ;
62
- toolbarButtonsConfig ?: DocumentCorrectionViewToolbarButtonsConfig ;
63
- templateFilePath ?: string ;
64
- utilizedTemplateNames ?: UtilizedTemplateNames ;
65
- onFinish ?: ( result : DocumentResult ) => void ;
66
- _showResultView ?: boolean ;
67
- }
68
- declare class DocumentCorrectionView {
69
- private resources ;
70
- private config ;
71
- private imageEditorView ;
72
- private layer ;
73
- private currentCorrectionResolver ?;
74
- constructor ( resources : SharedResources , config : DocumentCorrectionViewConfig ) ;
75
- initialize ( ) : Promise < void > ;
76
- private setupDrawingLayerStyle ;
77
- private setupQuadConstraints ;
78
- private getCanvasBounds ;
79
- private addQuadToLayer ;
80
- private setupInitialDetectedQuad ;
81
- private createControls ;
82
- private setupCorrectionControls ;
83
- setFullImageBoundary ( ) : void ;
84
- setBoundaryAutomatically ( ) : Promise < void > ;
85
- confirmCorrection ( ) : Promise < void > ;
86
- launch ( ) : Promise < DocumentResult > ;
87
- hideView ( ) : void ;
88
- /**
89
- * Normalize an image with DDN given a set of points
90
- * @param points - points provided by either users or DDN's detect quad
91
- * @returns normalized image by DDN
92
- */
93
- correctImage ( points : Quadrilateral [ "points" ] ) : Promise < NormalizedImageResultItem > ;
94
- dispose ( ) : void ;
56
+ interface ScanRegion {
57
+ ratio : {
58
+ width : number ;
59
+ height : number ;
60
+ } ;
61
+ regionBottomMargin : number ;
62
+ style : {
63
+ strokeWidth : number ;
64
+ strokeColor : string ;
65
+ } ;
95
66
}
96
-
97
67
interface DocumentScannerViewConfig {
98
68
_showCorrectionView ?: boolean ;
99
69
templateFilePath ?: string ;
100
70
cameraEnhancerUIPath ?: string ;
101
71
container ?: HTMLElement | string ;
102
72
utilizedTemplateNames ?: UtilizedTemplateNames ;
73
+ enableAutoCropMode ?: boolean ;
74
+ enableSmartCaptureMode ?: boolean ;
75
+ scanRegion : ScanRegion ;
76
+ minVerifiedFramesForAutoCapture : number ;
77
+ showSubfooter ?: boolean ;
78
+ showPoweredByDynamsoft ?: boolean ;
103
79
}
104
80
declare class DocumentScannerView {
105
81
private resources ;
106
82
private config ;
107
83
private boundsDetectionEnabled ;
108
84
private smartCaptureEnabled ;
109
85
private autoCropEnabled ;
86
+ private resizeTimer ;
110
87
private crossVerificationCount ;
111
88
private capturedResultItems ;
112
89
private originalImageData ;
@@ -117,6 +94,7 @@ declare class DocumentScannerView {
117
94
private loadingScreen ;
118
95
private showScannerLoadingOverlay ;
119
96
private hideScannerLoadingOverlay ;
97
+ private getMinVerifiedFramesForAutoCapture ;
120
98
constructor ( resources : SharedResources , config : DocumentScannerViewConfig ) ;
121
99
initialize ( ) : Promise < void > ;
122
100
private initializeElements ;
@@ -131,6 +109,9 @@ declare class DocumentScannerView {
131
109
toggleBoundsDetection ( enabled ?: boolean ) : Promise < void > ;
132
110
toggleSmartCapture ( mode ?: boolean ) : Promise < void > ;
133
111
toggleAutoCrop ( mode ?: boolean ) : Promise < void > ;
112
+ private handleResize ;
113
+ private toggleScanGuide ;
114
+ private calculateScanRegion ;
134
115
openCamera ( ) : Promise < void > ;
135
116
closeCamera ( hideContainer ?: boolean ) : void ;
136
117
pauseCamera ( ) : void ;
@@ -148,6 +129,51 @@ declare class DocumentScannerView {
148
129
normalizeImage ( points : Quadrilateral [ "points" ] , originalImageData : OriginalImageResultItem [ "imageData" ] ) : Promise < NormalizedImageResultItem > ;
149
130
}
150
131
132
+ interface DocumentCorrectionViewToolbarButtonsConfig {
133
+ retake ?: ToolbarButtonConfig ;
134
+ fullImage ?: ToolbarButtonConfig ;
135
+ detectBorders ?: ToolbarButtonConfig ;
136
+ apply ?: ToolbarButtonConfig ;
137
+ }
138
+ interface DocumentCorrectionViewConfig {
139
+ container ?: HTMLElement | string ;
140
+ toolbarButtonsConfig ?: DocumentCorrectionViewToolbarButtonsConfig ;
141
+ templateFilePath ?: string ;
142
+ utilizedTemplateNames ?: UtilizedTemplateNames ;
143
+ onFinish ?: ( result : DocumentResult ) => void ;
144
+ _showResultView ?: boolean ;
145
+ }
146
+ declare class DocumentCorrectionView {
147
+ private resources ;
148
+ private config ;
149
+ private scannerView ;
150
+ private imageEditorView ;
151
+ private layer ;
152
+ private currentCorrectionResolver ?;
153
+ constructor ( resources : SharedResources , config : DocumentCorrectionViewConfig , scannerView : DocumentScannerView ) ;
154
+ initialize ( ) : Promise < void > ;
155
+ private setupDrawingLayerStyle ;
156
+ private setupQuadConstraints ;
157
+ private getCanvasBounds ;
158
+ private addQuadToLayer ;
159
+ private setupInitialDetectedQuad ;
160
+ private createControls ;
161
+ private setupCorrectionControls ;
162
+ private handleRetake ;
163
+ setFullImageBoundary ( ) : void ;
164
+ setBoundaryAutomatically ( ) : Promise < void > ;
165
+ confirmCorrection ( ) : Promise < void > ;
166
+ launch ( ) : Promise < DocumentResult > ;
167
+ hideView ( ) : void ;
168
+ /**
169
+ * Normalize an image with DDN given a set of points
170
+ * @param points - points provided by either users or DDN's detect quad
171
+ * @returns normalized image by DDN
172
+ */
173
+ correctImage ( points : Quadrilateral [ "points" ] ) : Promise < NormalizedImageResultItem > ;
174
+ dispose ( preserveResolver ?: boolean ) : void ;
175
+ }
176
+
151
177
interface DocumentResultViewToolbarButtonsConfig {
152
178
retake ?: ToolbarButtonConfig ;
153
179
correct ?: ToolbarButtonConfig ;
@@ -207,6 +233,9 @@ declare class DocumentScanner {
207
233
private resources ;
208
234
private isInitialized ;
209
235
private isCapturing ;
236
+ private loadingScreen ;
237
+ private showScannerLoadingOverlay ;
238
+ private hideScannerLoadingOverlay ;
210
239
constructor ( config : DocumentScannerConfig ) ;
211
240
initialize ( ) : Promise < {
212
241
resources : SharedResources ;
@@ -226,53 +255,25 @@ declare class DocumentScanner {
226
255
private initializeDDSConfig ;
227
256
private createViewContainers ;
228
257
dispose ( ) : void ;
258
+ /**
259
+ * Process a File object to extract image information
260
+ * @param file The File object to process
261
+ * @returns Promise with the processed image blob and dimensions
262
+ */
263
+ private processFileToBlob ;
264
+ /**
265
+ * Processes an uploaded image file
266
+ * @param file The file to process
267
+ * @returns Promise with the document result
268
+ */
269
+ private processUploadedFile ;
229
270
/**
230
271
* Launches the document scanning process.
231
272
*
232
- * Configuration Requirements:
233
- * 1. A container must be provided either through:
234
- * - A main container in config.container, OR
235
- * - Individual view containers in viewConfig.container when corresponding show flags are true
236
- * 2. If no main container is provided:
237
- * - showCorrectionView: true requires correctionViewConfig.container
238
- * - showResultView: true requires resultViewConfig.container
239
- *
240
- * Flow paths based on view configurations and capture method:
241
- *
242
- * 1. All views enabled (Scanner, Correction, Result):
243
- * A. Auto-capture paths:
244
- * - Smart Capture: Scanner -> Correction -> Result
245
- * - Auto Crop: Scanner -> Result
246
- * B. Manual paths:
247
- * - Upload Image: Scanner -> Correction -> Result
248
- * - Manual Capture: Scanner -> Result
249
- *
250
- * 2. Scanner + Result only:
251
- * - Flow: Scanner -> Result
252
- * - Requires: showCorrectionView: false or undefined
253
- *
254
- * 3. Scanner + Correction only:
255
- * - Flow: Scanner -> Correction
256
- * - Requires: showResultView: false or undefined
257
- *
258
- * 4. Special cases:
259
- * - Scanner only: Returns scan result directly
260
- * - Correction only + existing result: Goes to Correction
261
- * - Result only + existing result: Goes to Result
262
- *
263
- * @returns Promise<DocumentResult> containing:
264
- * - status: Success/Failed/Cancelled with message
265
- * - originalImageResult: Raw captured image
266
- * - correctedImageResult: Normalized image (if correction applied)
267
- * - detectedQuadrilateral: Document boundaries
268
- * - _flowType: Internal routing flag for different capture methods
269
- *
270
- * @throws Error if:
271
- * - Capture session is already running
272
- * - Scanner view is required but not configured
273
- * - No container is provided when showCorrectionView or showResultView is true
273
+ * @param file Optional File object to process instead of using the camera
274
+ * @returns Promise<DocumentResult> containing scan results
274
275
*/
275
- launch ( ) : Promise < DocumentResult > ;
276
+ launch ( file ?: File ) : Promise < DocumentResult > ;
276
277
}
277
278
278
279
declare const DDS : {
0 commit comments