-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f6e601
commit c30361f
Showing
1 changed file
with
8 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,11 @@ import { createPendingPromise, getNeedShowFields } from "./util.js"; | |
let pDataLoad = createPendingPromise(); | ||
|
||
/** LICENSE ALERT - README | ||
* To use the library, you need to first specify a license key using the API "license" as shown below. | ||
* To use the library, you need to first specify a license key using the API "initLicense" as shown below. | ||
*/ | ||
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"); | ||
// Dynamsoft.License.LicenseManager.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiODAwMC04MDAwIiwibWFpblNlcnZlclVSTCI6Imh0dHBzOi8vMTkyLjE2OC44LjEyMi9kbHMvIiwib3JnYW5pemF0aW9uSUQiOiI4MDAwIiwiY2hlY2tDb2RlIjotMTA1NjUzOTM3M30=", true); | ||
/** | ||
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dlr&package=js to get your own trial license good for 30 days. | ||
* You can visit https://www.dynamsoft.com/customer/license/trialLicense/?product=cvs&utm_source=docs&package=javascript to get your own trial license good for 30 days. | ||
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license. | ||
* For more information, see https://www.dynamsoft.com/label-recognition/programming/javascript/user-guide.html?ver=latest#specify-the-license or contact [email protected]. | ||
* LICENSE ALERT - THE END | ||
|
@@ -23,20 +22,20 @@ Dynamsoft.DLR.LabelRecognizerModule.onDataLoadProgressChanged = (modelPath, tag, | |
} | ||
|
||
/** | ||
* Preloads the `LabelRecognizer` module | ||
* Preloads the resources | ||
*/ | ||
Dynamsoft.Core.CoreModule.loadWasm(["DLR", "DCP"]); | ||
Dynamsoft.DCP.CodeParserModule.loadSpec("MRTD_TD3_PASSPORT"); | ||
Dynamsoft.DLR.LabelRecognizerModule.loadRecognitionData("MRZ"); | ||
|
||
/** | ||
* Creates a CameraEnhancer instance for later use. | ||
* Creates a CameraEnhancer instance as the image source | ||
*/ | ||
async function initDCE() { | ||
cameraView = await Dynamsoft.DCE.CameraView.createInstance(cameraViewContainer); | ||
cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView); | ||
|
||
// Get the device's camera information and render the camera list | ||
// Get the camera information of the device and render the camera list | ||
cameraList = await cameraEnhancer.getAllCameras(); | ||
for (let camera of cameraList) { | ||
const cameraItem = document.createElement("div"); | ||
|
@@ -59,16 +58,15 @@ async function initDCE() { | |
} | ||
|
||
/** | ||
* Creates a CaptureVisionRouter instance and configure the task to recognize text. | ||
* Also, make sure the original image is returned after it has been processed. | ||
* Creates a CaptureVisionRouter instance and configure the task setting. | ||
*/ | ||
let cvrReady = (async function initCVR() { | ||
await initDCE(); | ||
cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance(); | ||
await cvRouter.initSettings("./template.json"); | ||
cvRouter.setInput(cameraEnhancer); | ||
|
||
/* Defines the result receiver for the task.*/ | ||
/* Defines the result receiver for the solution.*/ | ||
const resultReceiver = new Dynamsoft.CVR.CapturedResultReceiver(); | ||
resultReceiver.onCapturedResultReceived = (result) => { | ||
const recognizedResults = result.textLineResultItems; | ||
|
@@ -78,7 +76,7 @@ let cvrReady = (async function initCVR() { | |
parsedResultName.innerText = ""; | ||
parsedResultSexAndAge.innerText = ""; | ||
parsedResultMain.innerText = ""; | ||
// If get parsing result, use the parsing result to render the result page | ||
// If a parsed result is obtained, use it to render the result page | ||
if (parsedResults) { | ||
const parseResultInfo = getNeedShowFields(parsedResults[0]); | ||
parsedResultName.innerText = parseResultInfo["Name"] || "Name not detected"; | ||
|