You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: programming/android/user-guide.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -244,7 +244,7 @@ class MainActivity : AppCompatActivity() {
244
244
> [!Note]
245
245
>
246
246
> - The license string here grants a time-limited free trial which requires network connection to work.
247
-
> - You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=guide&package=ios){:target="_blank"} link.
247
+
> - You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=guide&package=android){:target="_blank"} link.
248
248
> - If you download the <ahref="https://www.dynamsoft.com/barcode-reader/downloads/?utm_source=docs#mobile"target="_blank">Installation Package</a>, it comes with a 30-day trial license by default.
Copy file name to clipboardExpand all lines: programming/flutter/driver-license-user-guide.md
+69-78Lines changed: 69 additions & 78 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,24 +10,20 @@ noTitleIndex: true
10
10
11
11
# Driver License Scanner Integration Guide
12
12
13
-
This guide will focus on the specific use case of scanning driver licenses to quickly retrieve one's ID info. Similar to the [Foundational Integration Guide](foundational-user-guide.md), this guide will utilize the [`Capture Vision Foundational API`]({{ site.dcv_flutter_api }}) to get the driver license scanner up and running.
14
-
15
-
> [!NOTE]
16
-
> The Driver License Scanner is composed of two foundational Dynamsoft products - the [Dynamsoft Barcode Reader](https://www.dynamsoft.com/barcode-reader/sdk-mobile/) and the Dynamsoft Code Parser. The Barcode Reader is responsible for capturing and decoding the PDF417 barcodes of the driver licenses. Afterwards, the barcode result needs to be parsed into human-readable fields, which is where the Code Parser comes into play.
13
+
This guide walks you through integrating a Driver License Scanner to quickly extract ID information from driver licenses.
17
14
18
15
## Supported Driver License Types
19
16
20
-
Driver licenses come with a PDF417 barcode (usually on the back) that encodes the holder's information. These driver licenses can come in different formats, which means different ways that the information is encoded into the barcode, or even the type of information that is encoded.
17
+
Most driver licenses include a PDF417 barcode (usually on the back) that encodes personal information. Different regions use different formats, meaning the contained fields and encoding structure can vary.
21
18
22
19
### AAMVA Driver License
23
20
24
-
AAMVA - the American Association of Motor Vehicle Administrators - defines the standard that the majority of North American driver licenses need to adhere to. You can learn more about AAMVA on their [website](https://www.aamva.org/).
25
-
26
-
All versions of the AAMVA DL/ID specification (2000, 2003, 2005, 2009, 2010, 2011, 2012, 2013, 2016) are supported by the Dynamsoft Barcode Reader.
21
+
The American Association of Motor Vehicle Administrators (AAMVA) defines the standard used across most North American driver licenses.
22
+
All AAMVA DL/ID specification versions (2000–2016) are supported.
27
23
28
24
### South Africa Driver License
29
25
30
-
Support for South African driver licenses is limited - which means that the library is able to extract only a portion of the personal info that is encoded onto the driver license. Parsing of the full info from the driver license will come in a future version of the library.
26
+
South African driver license barcodes are partially supported. [View supported fields]({{ site.code_types }}za-dl.html).
31
27
32
28
## System Requirements
33
29
@@ -41,56 +37,29 @@ Support for South African driver licenses is limited - which means that the libr
41
37
* Supported ABI: arm64 and x86_64
42
38
* Development Environment: Xcode 13+ (Xcode 14.1+ recommended)
43
39
44
-
> [!TIP]
45
-
> If you are downloading Xcode or Android Studio for the first time, please remember to also install the command-line tools.
46
-
47
-
> [!NOTE]
48
-
> Please note that the sample projects that we offer were last tested with Flutter 3.35.7
49
-
50
-
## Including the Library
40
+
## Adding the Library
51
41
52
-
Run the following command in the root directory of your flutter project to add `dynamsoft_barcode_reader_bundle_flutter` to the dependencies:
Then run the following command to install all the dependencies:
59
-
60
-
```bash
61
46
flutter pub get
62
47
```
63
48
64
49
> [!NOTE]
65
-
> Including the `dynamsoft_barcode_reader_bundle_flutter`library will also include the `dynamsoft_capture_vision_flutter` library, which will be the one that is actually imported and used.
50
+
> Adding `dynamsoft_barcode_reader_bundle_flutter`automatically includes `dynamsoft_capture_vision_flutter`, which is the library you'll interact with directly.
66
51
67
52
## Building the Driver License Scanner Widget
68
53
69
-
Now that the package is added, it's time to start building the Driver License Scanner widget. Unlike the default implementation of the Barcode Reader that is explored in the other guides, building the driver license scanner requires a few more steps and classes to be implemented to fully represent the parsed result that is produced by the library.
70
-
71
-
These steps include importing the library, implementing the scanner page, creating the *DriverLicenseScanResult* class, and then putting them all together in `main.dart`.
72
-
73
-
### Importing the Library
74
-
75
-
To use the Capture Vision API, please import `dynamsoft_capture_vision_flutter` into the three files that we will be implementing (`main.dart`/`scan_page.dart`/`driver_license_scan_result.dart`):
- Defining the result extraction APIs (e.g., `DriverLicenseScanResult`, `DriverLicenseData`)
58
+
- Invoking the scanner from main.dart
80
59
81
60
### Create the Scan Page
82
61
83
-
Let's tackle the first and main component, the `ScannerPage` class which will be implemented in `scan_page.dart`. In order to implement the full driver license scanner workflow, the following needs to be done in order:
84
-
85
-
- Define a valid license via the [`LicenseManager`]({{ site.dcv_flutter_api }}license/license-manager.html)
86
-
- Initialize the [`CameraEnhancer`]({{ site.dce_flutter_api }}camera-enhancer.html) object
87
-
- Initialize the [`CaptureVisionRouter`]({{ site.dcv_flutter_api }}capture-vision-router/capture-vision-router.html) object
88
-
- Bind the `CameraEnhancer` object to the `CaptureVisionRouter` object
89
-
- Register a [`CapturedResultReceiver`]({{ site.dcv_flutter_api }}capture-vision-router/captured-result-receiver.html) object to listen for parsed driver license barcode results via the callback function [`onParsedResultsReceived`]({{ site.dcv_flutter_api }}capture-vision-router/captured-result-receiver.html#onparsedresultsreceived)
90
-
- Open the camera
91
-
- Start scanning via the [`startCapturing`]({{ site.dcv_flutter_api }}capture-vision-router/capture-vision-router.html#startcapturing) method while being configured to the `ReadDriversLicense` template.
92
-
93
-
The code snippet below shows the simplest implementation of *ScannerPage* that will set up and launch the Driver License Scanner. Please note that in order to use the Driver License Scanner, a **valid license must be defined in the code**.
62
+
Create scan_page.dart and insert the full workflow:
@@ -137,10 +114,14 @@ class _ScannerPageState extends State<ScannerPage> with RouteAware {
137
114
}
138
115
139
116
void initSdk() async {
117
+
// Bind the Camera instance with the CaptureVisionRouter instance.
140
118
await _cvr.setInput(_camera);
119
+
// Bind the result receiver with the CaptureVisionRouter instance.
141
120
_cvr.addResultReceiver(_receiver);
121
+
// Open the camera
142
122
_camera.open();
143
123
try {
124
+
// Start the capturing process.
144
125
await _cvr.startCapturing(_templateName);
145
126
} catch (e) {
146
127
Navigator.of(context).pop(
@@ -155,6 +136,7 @@ class _ScannerPageState extends State<ScannerPage> with RouteAware {
155
136
@override
156
137
void dispose() {
157
138
super.dispose();
139
+
// Stop capturing, close the camera, and remove the result receiver when disposing.
158
140
_cvr.stopCapturing();
159
141
_camera.close();
160
142
_cvr.removeResultReceiver(_receiver);
@@ -184,18 +166,19 @@ class _ScannerPageState extends State<ScannerPage> with RouteAware {
184
166
185
167
> [!NOTE]
186
168
>
187
-
> -`DriverLicenseData.fromParsedResultItem()` is a helper function to convert a [`ParsedResultItem`]({{ site.dcp_flutter_api }}parsed-result-item.html) into a more user-friendly structure (`DriverLicenseData`). You can get the source code from [driver_license_scan_result.dart](https://github.com/Dynamsoft/barcode-reader-flutter-samples/blob/main/ScanDriversLicense/lib/driver_license_scan_result.dart).
188
169
>- The license string here grants a time-limited free trial which requires network connection to work.
189
-
>- You can request a 30-day trial license via the [Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=guide&package=mobile) portal.
170
+
>- You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=guide&package=flutter){:target="_blank"} link.
190
171
191
-
### Define the Result Classes and Related APIs
172
+
Related APIs:
192
173
193
-
The next step in building this app is to create the `DriverLicenseScanResult` class which will be used to represent the parsed information that is output by the library. **For the full implementation of this class, please refer to [*driver_license_scan_result.dart*](https://github.com/Dynamsoft/barcode-reader-flutter-samples/blob/main/ScanDriversLicense/lib/driver_license_scan_result.dart). Here is a quick breakdown of the `DriverLicenseScanResult` class:
-`resultStatus` represents whether the result was produced successfully, if the scan operation was cancelled, or if an error occurred during the scanning process.
196
-
-`data` is a `DriverLicenseData` object that represents the parsed information as different string fields which can then be accessed via these key fields and presented to the user in a friendly manner.
197
-
-`DriverLicenseData` is created from a [`ParsedResultItem`]({{ site.dcp_flutter_api }}parsed-result-item.html) object via the `fromParsedResultItem()` function that is defined in the `DriverLicenseData` class.
198
-
-`errorString` is the error message that is produced should the `resultStatus` be `exception`.
179
+
### Define Result Models
180
+
181
+
Create `driver_license_scan_result.dart` and include the data structures used to represent parsed driver license fields.
// Represents whether the result was produced successfully, if the scan operation was cancelled, or if an error occurred during the scanning process.
210
194
EnumResultStatus resultStatus;
195
+
// When the resultStatus is "exception". You will receive the error message here.
211
196
String? errorString = "";
197
+
// A DriverLicenseData object that represents the parsed information as different string fields. Created from a ParsedResultItem.
212
198
DriverLicenseData? data;
213
199
DriverLicenseScanResult({
214
200
required this.resultStatus,
@@ -315,9 +301,9 @@ class DriverLicenseData {
315
301
}
316
302
```
317
303
318
-
### Direct From the User Page to the Scan Page
304
+
### Navigating to Scan Page
319
305
320
-
Now that the main Scanner widget and the `DriverLicenseScanResult` class are implemented, it's time to bring them together in the *main.dart* of the project. For the full implementation of *main.dart*, please see the code below:
306
+
Add navigation logic in `main.dart` to trigger the scanner and display results.
321
307
322
308
```dart
323
309
import 'package:flutter/material.dart';
@@ -398,21 +384,16 @@ class _MyHomePageState extends State<MyHomePage> {
398
384
}
399
385
```
400
386
401
-
## Customize the Driver License Scanner
402
-
403
-
Even though the Driver License Scanner comes with a template that is optimized for the typical driver license scanning scenario, there could be situations that require a different approach in order to get handled properly. The Driver License Scanner comes with a wide range of customizations, whether it is UI related, performance related, or a mix of both.
387
+
### Customize the Driver License Scanner (Optional)
404
388
405
-
In this next section we will explore one of the ways in which the Driver License Scanner can be customized - specifying a scan region.
389
+
Although the Driver License Scanner template is optimized for common scenarios, you may customize performance or UI behavior as needed.
406
390
407
-
### Specify the Scan Region
391
+
####Specify the Scan Region
408
392
409
-
You can limit the scan region of the library so that it doesn't exhaust resources trying to read from the entire image or frame.
393
+
Restricting the scan region can reduce processing time and avoid reading unwanted areas:
410
394
411
395
```dart
412
-
final CameraEnhancer _camera = CameraEnhancer.instance;
Before the project can be deployed to a *iOS* device, the camera permissions and the developer signature must first be set. To add the camera permissions to the iOS portion of the app, we recommend first installing the **pods** dependencies to generate the **.xcworkspace** project under the ios folder (`ios/Runner.xcworkspace`). Please run the following commands from the root directory:
426
-
427
-
```bash
428
-
cd ios/
429
-
pod install --repo-update
430
-
```
406
+
1. Install CocoaPods dependencies
431
407
432
-
#### Camera Permissions
408
+
Before the project can be deployed to a *iOS* device, the camera permissions and the developer signature must first be set. To add the camera permissions to the iOS portion of the app, we recommend first installing the **pods** dependencies to generate the **.xcworkspace** project under the ios folder (`ios/Runner.xcworkspace`). Please run the following commands from the root directory:
433
409
434
-
Once the pods are installed, *Runner.xcworkspace* should now be generated in the *ios* folder. To add the camera permissions, open the generated *Runner.xcworkspace* and navigate to the *Info* section of the project settings. Then you must add the "Privacy - Camera Usage Description" key to the list (where you can also assign a string message to show in the alert box).
410
+
```bash
411
+
cd ios/
412
+
pod install --repo-update
413
+
```
435
414
436
-
#### Deploying to Device
415
+
2. Configure the project in Xcode
437
416
438
-
In order to deploy the app to a iOS device, we recommend doing it via Xcode by using the `Runner.xcworkspace` project that was generated when the pods were installed. Since the camera permissions are taken care of, all you need to do is properly configure the *Signing & Capabilities* section of the project settings. Should the iOS device be connected to the computer, you can now run and deploy the app to the device.
417
+
Open Runner.xcworkspace in Xcode and:
439
418
440
-
If everything is set up correctly, you should see the app running on your device.
419
+
- Add **Privacy – Camera Usage Description** under **Project → Info**
420
+
- Configure **Signing & Capabilities**
421
+
- Connect your device and run the project
441
422
442
423
### Android
443
424
444
-
Go to the project folder, open a new terminal and run the following command:
425
+
Run the app:
426
+
427
+
```bash
428
+
flutter run
429
+
```
430
+
431
+
Run on a specific device:
445
432
446
433
```bash
447
434
flutter run -d <DEVICE_ID>
448
435
```
449
436
450
-
You can get the IDs of all connected (physical) devices by running the command `flutter devices`.
437
+
List devices:
438
+
439
+
```bash
440
+
flutter devices
441
+
```
451
442
452
443
## Full Sample Code
453
444
454
445
The full sample code is available [here](https://github.com/Dynamsoft/barcode-reader-flutter-samples/tree/main/ScanDriversLicense).
455
446
456
447
## License
457
448
458
-
You can request a 30-day trial license via the [Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=github&package=mobile) portal.
449
+
You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=guide&package=mobile){:target="_blank"} link.
0 commit comments