Skip to content

Commit 4ffa11a

Browse files
committed
fix: camera selection
1 parent 198fce6 commit 4ffa11a

32 files changed

+7
-9194
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.npmrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

LICENSE

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -4,146 +4,6 @@ This user guide will walk you through the [Hello World](https://github.com/Dynam
44

55
To learn about what an MRZ is, along with the makeup and system requirements of this solution, please visit the [MRZ Introduction](https://www.dynamsoft.com/mrz-scanner/docs/web/introduction/index.html) page on the Dynamsoft website.
66

7-
## License
7+
## Demo Branch
88

9-
### Trial License
10-
11-
When you are getting started with the MRZ Scanner solution, we recommend getting your own 30-day trial license through the [customer portal](https://www.dynamsoft.com/customer/license/trialLicense/?product=mrz&utm_source=guide&package=js). The trial license can be renewed via the same customer portal twice, each time for another 15 days, giving you a total of 60 days to develop your own application using the solution. If more time is needed for a full evaluation, please contact the [Dynamsoft Support Team](https://www.dynamsoft.com/company/contact/).
12-
13-
> Note:
14-
>
15-
> Please note that the **MRZ Scanner** license contains a license for the **Dynamsoft Label Recognizer**, **Dynamsoft Code Parser**, and the **Dynamsoft Camera Enhancer** as those are the three functional products that are central to the operation of the MRZ Scanner.
16-
17-
### Full License
18-
19-
If you are fully satisfied with the solution and would like to move forward with a full license, please contact the [Dynamsoft Sales Team](https://www.dynamsoft.com/company/contact/).
20-
21-
## Quick Start - Including the SDK and creating Hello World
22-
23-
As mentioned previously, the purpose of this guide is to help you implement a Hello World application using the MRZ Scanner solution. To showcase this, we will be using vanilla JS. You can find the full code in the [Github repository](https://github.com/Dynamsoft/mrz-scanner-javascript/blob/main/README.md).
24-
25-
The first step before you venture into writing the code is to include the SDK in your application. The simplest way to include the SDK would be to use the precompiled script - but you can also build it from source yourself.
26-
27-
### Building the Library from Source
28-
29-
In this guide, we will show the developer how to build the scanner themselves from the source files. The advantage of doing this is that it allows the developer to do some deep customization of the scanner if they are familiar with using the foundational products **Dynamsoft Label Recognizer**, **Dynamsoft Code Parser**, and the **Dynamsoft Camera Enhancer**.
30-
31-
Please note that we also offer a pre-compiled script reference to make the inclusion of the library even easier. To learn how to use that, please visit the full User Guide for the MRZ Scanner.
32-
33-
This method requires retrieving the **MRZ Scanner for Web** source files from its [Github repository](https://github.com/Dynamsoft/mrz-scanner-javascript), compiles them into a distributable package, and then runs a *ready-made* Hello World sample page that is already included in the repo.
34-
35-
Please follow these steps in order to build from the source:
36-
37-
1. Download the **MRZ Scanner for Web** source files from [Github](https://github.com/Dynamsoft/mrz-scanner-javascript) as a compressed folder ("Download ZIP" option).
38-
39-
2. Extract the contents of the compressed folder.
40-
41-
3. Open the *Hello World* sample included with the source files located at `samples/hello-world.html`
42-
43-
4. Search for 'YOUR_LICENSE_KEY_HERE' and replace that with your own license key, whether it is trial or full.
44-
45-
5. Install project dependencies - in the terminal, navigate to the project root directory and run the following:
46-
```bash
47-
npm install
48-
```
49-
50-
6. Build the project - once the dependencies are installed, build the project by running:
51-
```bash
52-
npm run build
53-
```
54-
55-
7. Serve the project via localhost:
56-
```bash
57-
npm run serve
58-
```
59-
Once the server is running, open the application in a browser using the address provided in the terminal output after running `npm run serve`.
60-
61-
## Breaking down Hello World
62-
63-
Let's now go through the code of the Hello World sample and understand the purpose of each section and how they all work together to bring the app to life.
64-
65-
### Step 1: Setting up the HTML and Including the MRZ Scanner
66-
67-
```html
68-
<!DOCTYPE html>
69-
<html lang="en">
70-
<head>
71-
<meta charset="utf-8" />
72-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
73-
<title>Dynamsoft MRZ Scanner - Hello World</title>
74-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mrz-scanner.bundle.js"></script>
75-
</head>
76-
77-
<body>
78-
<h1 style="font-size: large">Dynamsoft MRZ Scanner</h1>
79-
</body>
80-
81-
</html>
82-
```
83-
84-
The first step in setting up the HTML in a Hello World implementation is to include the SDK. The ways to include the SDK has already been addressed in the [Quick Start](#quick-start---including-the-sdk-and-creating-hello-world) section, so please refer to that if you have not already. In this example, we are including the MRZ Scanner via the precompiled script as that is the easiest way to get started.
85-
86-
Since this is a Hello World implementation, the HTML body will be kept quite simple. Since the MRZ Scanner comes with a **Ready-to-Use UI**, it is not necessary to place any `<div>` placeholder elements or anything like. Once the scanner is launched, the **Ready-to-Use UI** will come up and occupy the page.
87-
88-
<!-- The main DOM element that is required in the `<body>` is a `<div>` element where the MRZ result (or lack thereof) and the original image of the MRZ document will be displayed once the user clicks *Done* in the result view. Feel free to customize the styling of the `<div>` element to your liking. -->
89-
90-
Now let's move to the main script that will define the operation of the
91-
92-
### Step 2: Initialize the MRZ Scanner
93-
94-
```js
95-
// Initialize the Dynamsoft MRZ Scanner
96-
const mrzscanner = new Dynamsoft.MRZScanner({
97-
license: "YOUR_LICENSE_KEY_HERE",
98-
});
99-
```
100-
101-
Above you will see the **simplest** way that you can initialize the MRZ Scanner. The one that is **absolutely required** in this setup is the **license**. Without a valid license, the MRZ Scanner view will not launch and you will be met with an error message explaining that the license key is invalid or has expired. To learn how to get your own license, please refer to the [License](#license) section of the guide.
102-
103-
### Step 3: Launching the MRZ Scanner
104-
105-
```js
106-
(async () => {
107-
// Launch the scanner and wait for the result
108-
const result = await mrzscanner.launch({});
109-
console.log(result);
110-
})();
111-
```
112-
113-
Now that the MRZ Scanner has been initialized and configured, it is ready to be launched! Once the MRZ Scanner is launched, the user will see the main **MRZScannerView**. Once a MRZ is scanned (via video or static image), the MRZ Scanner then switches to the **MRZResultView** to display a cropped image of the MRZ document as well as the parsed fields of the MRZ text. Let's break down these two views:
114-
115-
#### MRZScannerView
116-
117-
Here is a quick breakdown of the UI elements that make up the main view of the MRZ Scanner
118-
119-
1. **Camera View**: The majority of the space of the MRZScannerView is occupied by the camera view to give the user a complete picture of what is being seen by the camera.
120-
121-
2. **Scan Guide Frame**: By default, at the centre of the camera view you will find a frame that helps guide the user on where to place the MRZ document to get a fast and accurate result. Please note that if scan guide frame is shown, then anything outside of the frame will not be captured. This frame can be hidden via the **MRZScannerViewConfig** interface.
122-
123-
3. **Format Selector**: Below the scan guide frame, you will also notice a selector box that allows the user to choose which formats the MRZ Scanner should recognize. The formats that show up in the format selector are configurable via the **MRZScannerConfig** interface, while the visibility of the format selector itself is configurable via the **MRZScannerViewConfig** interface. To learn about MRZ formats, please refer to the [Introduction](https://www.dynamsoft.com/mrz-scanner/docs/web/introduction/index.html#supported-mrz-formats) page.
124-
125-
4. **Resolution/Camera Select Dropdown**: This dropdown allows the user to switch cameras (should they have more than one available on the device), or select a different resolution for the camera that is currently selected.
126-
127-
5. **Load Image Button**: When this button is clicked, the user can select a MRZ document image from the device's local storage to be recognized.
128-
129-
6. **Sound Button**: By toggling this on, the MRZ Scanner will play a *beep* sound to signal that the MRZ has been successfully recognized.
130-
131-
7. **Flash Button**: This button is responsible for toggling the flash of the camera should it have one. If the device doesn't have the flash feature or if the browser being used doesn't support flash, this flash icon will not show up.
132-
133-
8. **Close Scanner Button**: Clicking this button will close the MRZ Scanner and take the user back to the landing page.
134-
135-
#### MRZResultView
136-
137-
Here is a quick breakdown of the UI elements that make up the result view
138-
139-
1. **Original Image**: A cropped image of the MRZ document that was just scanned will be displayed at the top by default.
140-
141-
2. **Parsed Results**: The parsed results, along with their corresponding field names, are displayed in a form view underneath the original image. In addition to displaying these parsed results, the MRZ Scanner allows the user to edit any of the fields if they find that any of the parsed info is incorrect after cross referencing it with the info on the MRZ document.
142-
143-
3. **Re-take Button**: Clicking this button allows the user to go back to the **MRZScannerView** to scan another MRZ document.
144-
145-
4. **Done Button**: Clicking this button basically closes the scanner and destroys the **MRZScanner** instance. At that point, the application will go back to the landing page, but the developer can dictate the action to take once this button is clicked. These actions can include allowing the user to perform some extra actions with the MRZ result, or navigating to another page, or really anything that the developer would like to do once the scanning operation is done.
146-
147-
>Note:
148-
>
149-
> In the Hello World sample, no action is taken once the Done button is clicked. The scanner closes and the user is met with an empty page. In order to open the scanner again, the user must refresh the page. However, this action can be changed according to the developer's wishes as indicated above.
9+
This branch is only for our Dynamsoft demo. Please refer to the main branch for all uses.

dev-server/index.js

Lines changed: 0 additions & 138 deletions
This file was deleted.

dev-server/pem/cert.pem

Lines changed: 0 additions & 13 deletions
This file was deleted.

dev-server/pem/csr.pem

Lines changed: 0 additions & 11 deletions
This file was deleted.

dev-server/pem/key.pem

Lines changed: 0 additions & 15 deletions
This file was deleted.

dist/mrz-scanner.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mrz-scanner.bundle.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/mrz-scanner.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mrz-scanner.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/mrz-scanner.no-content-bundle.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)