-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture_settings.dart
238 lines (201 loc) · 9.45 KB
/
capture_settings.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import 'package:json_annotation/json_annotation.dart';
import 'package:capture_flutter/capture_enums.dart';
part 'package:capture_flutter/capture_settings.g.dart';
/// All available settings for the Capture process.
/// Contains settings for the Capture analyzer, UX and camera configuration settings.
@JsonSerializable()
class CaptureSettings {
/// Settings for the Capture analyzer.
/// See [AnalyzerSettings] for more detailed information.
AnalyzerSettings? analyzerSettings = AnalyzerSettings();
/// Capture UX settings.
/// See [UxSettings] for more detailed information.
UxSettings? uxSettings = UxSettings();
/// Capture Camera settings.
/// See [CameraSettings] for more detailed information.
CameraSettings? cameraSettings = CameraSettings();
/// All available settings for the Capture process.
/// Contains settings for the Capture analyzer, UX and camera configuration settings.
CaptureSettings();
factory CaptureSettings.fromJson(Map<String, dynamic> json) =>
_$CaptureSettingsFromJson(json);
Map<String, dynamic> toJson() => _$CaptureSettingsToJson(this);
}
/// Settings for the Capture analyzer.
/// Used for setting capture strategies and scanning parameters.
@JsonSerializable()
class AnalyzerSettings {
/// Defines whether to capture a single side or capture all possible sides of a
/// document with automatic side detection.
///
/// Default: `false`
bool? captureSingleSide = false;
/// Defines whether to return an image of a cropped and perspective-corrected document.
///
/// Default: `true`
bool? returnTransformedDocumentImage = true;
/// Configures capture strategy used to select the best frame.
/// See [CaptureStrategy] enum for more detailed information.
///
/// Default: `CaptureStrategy.Default`
CaptureStrategy? captureStrategy = CaptureStrategy.Default;
/// Sets the required minimum DPI of the captured document on the transformed image.
/// Affects how close the document needs to be to the camera in order to get captured.
/// Allowed values are from 150 to 400 DPI.
/// Default: `230`
int? minimumDocumentDpi = 230;
/// Defines whether to automatically adjust minimum document dpi.
/// If it is enabled, the minimum dpi is adjusted to the optimal value for the provided input resolution
/// to enable the capture of all document groups.
///
/// Default: `true`
bool? adjustMinimumDocumentDpi = true;
/// Enables document capture with a margin defined as the percentage
/// of the dimensions of the framed document.
/// Both margin and document are required to be fully visible on the camera frame in order to finish capture.
///
/// Allowed values are from 0 to 1. Default: `0.01`
double? documentFramingMargin = 0.01;
/// Defines whether to return an image of the transformed document
/// with applied margin used during document framing.
///
/// Default: `false`
bool? keepMarginOnTransformedDocumentImage = false;
/// Defines whether to preserve the captured document DPI in the transformed document image.
/// If disabled, the document dpi is downscaled to 400 DPI.
///
/// Default: `false`
bool? keepDpiOnTransformedDocumentImage = false;
/// Sets the for lighting estimation.
/// See [LightingThresholds] class for more detailed information.
///
/// Default: `tooDarkThreshold`: `0.99`, `tooBrightThreshold`: `0.99`
LightingThresholds? lightingThresholds = LightingThresholds();
/// Policy used to discard frames with blurred documents.
/// See [BlurPolicy] enum for more detailed information.
///
/// Default: `BlurPolicy.Normal`
BlurPolicy? blurPolicy = BlurPolicy.Normal;
/// Policy used to discard frames with glare detected on the document.
/// See [GlarePolicy] enum for more detailed information.
///
/// Default: `GlarePolicy.Normal`
GlarePolicy? glarePolicy = GlarePolicy.Normal;
/// Defines the percentage of the document area that is allowed to be
/// occluded by hand.
///
/// Allowed values are from 0 to 1. Default: `0.05`
double? handOcclusionThreshold = 0.05;
/// Policy used to detect tilted documents.
/// See [TiltPolicy] enum for more detailed information.
///
/// Default: `TiltPolicy.Normal`
TiltPolicy? tiltPolicy = TiltPolicy.Normal;
/// Enforces a specific document group, overriding the analyzer’s document classification.
/// This setting impacts the number of sides scanned to match the enforced group,
/// and the way document image is transformed.
/// If set to null, the document group won't be enforced and it will be auto-detected.
///
/// Default: `null`
EnforcedDocumentGroup? enforcedDocumentGroup;
/// Settings for the Capture analyzer.
/// Used for setting capture strategies and scanning parameters.
AnalyzerSettings();
factory AnalyzerSettings.fromJson(Map<String, dynamic> json) =>
_$AnalyzerSettingsFromJson(json);
Map<String, dynamic> toJson() => _$AnalyzerSettingsToJson(this);
}
/// Defines the parameters for lighting estimation.
@JsonSerializable()
class LightingThresholds {
/// Threshold used to classify the frame as too dark.
/// If the calculated lighting score is above this threshold, the frame is discarded.
///
/// Allowed values are from 0 to 1. Default: `0.99`
double? tooDarkThreshold = 0.99;
/// Threshold used to classify the frame as too bright.
/// If the calculated lighting score is above this threshold, the frame is discarded.
///
/// Allowed values are from 0 to 1. Default: `0.99`
double? tooBrightThreshold = 0.99;
/// Defines the parameters for lighting estimation.
LightingThresholds();
factory LightingThresholds.fromJson(Map<String, dynamic> json) =>
_$LightingThresholdsFromJson(json);
Map<String, dynamic> toJson() => _$LightingThresholdsToJson(this);
}
/// Various Capture UX settings.
/// Defines the presence of various UI elements, timers, and screen options.
@JsonSerializable()
class UxSettings {
/// Defines whether the introduction dialog will be displayed on capture start.
///
/// Default: `false`
bool? showIntroductionDialog = false;
/// Defines whether onboarding (help) screens will be displayed.
/// If onboarding is disabled, the help button and tooltip won't be displayed.
///
/// Default: `true`
bool? showOnboardingInfo = true;
/// Defines whether the screen will always be ON while the capture screen is in the foreground.
///
/// Default: `true`
bool? keepScreenOn = true;
/// Defines whether to show the tooltip above the help button.
///
/// Default: `true`
bool? showCaptureHelpTooltip = true;
/// Sets the time in milliseconds that needs to pass before the help tooltip is displayed.
///
/// Default: `8000` (8 seconds)
double? showHelpTooltipTimeIntervalMs = 8000;
/// Duration in milliseconds that needs to pass since scanning of the current document side has begun in order to finish side capture.
/// The timeout timer is restarted on the document side flip.
///
/// Please be aware that time counting does not start from the moment when capture process starts.
/// Instead, it starts from the moment when at least one valid frame candidate for the current document side enters the analysis queue.
/// The reason for this is the better user experience in cases when, for example, the timeout is set to 10 seconds and the user starts scanning, leaves the device lying on the
/// table for 9 seconds, and then points the device towards the document it wants to capture: in such a case, it is better to let the user capture the document.
/// To disable side capture timeout set it to null.
///
/// Default: `15000` (15 seconds)
double? sideCaptureTimeoutMs = 15000;
/// Various Capture UX settings.
/// Defines the presence of various UI elements, timers, and screen options.
UxSettings();
factory UxSettings.fromJson(Map<String, dynamic> json) =>
_$UxSettingsFromJson(json);
Map<String, dynamic> toJson() => _$UxSettingsToJson(this);
}
/// Defines Capture's Camera configuration options.
/// Settings for camera resolution, separately for iOS and Android devices.
@JsonSerializable()
class CameraSettings {
/// Sets the camera resolution for Android devices.
///
/// This represents the preferred camera resolution.
/// It does not mean that the exact same resolution will be selected, but SDK will use the nearest one possible.
/// The actual resolution that will be chosen depends on the actual device hardware (camera resolutions available and processing power).
///
/// See [AndroidCameraResolution] for all options.
///
/// Default: `AndroidCameraResolution.Resolution2160P`
AndroidCameraResolution androidCameraResolution =
AndroidCameraResolution.Resolution2160P;
/// Sets the camera resolution for iOS devices.
///
/// This represents the preferred camera resolution.
/// It does not mean that the exact same resolution will be selected, but SDK will use the nearest one possible.
/// The actual resolution that will be chosen depends on the actual device hardware (camera resolutions available and processing power).
///
/// See [IosCameraResolution] for all options.
///
/// Default: `IosCameraResolution.Resolution1080p`
IosCameraResolution iosCameraResolution = IosCameraResolution.Resolution1080p;
/// Defines Capture's Camera configuration options.
/// Settings for camera resolution, separately for iOS and Android devices.
CameraSettings();
factory CameraSettings.fromJson(Map<String, dynamic> json) =>
_$CameraSettingsFromJson(json);
Map<String, dynamic> toJson() => _$CameraSettingsToJson(this);
}