翻譯|使用教程|編輯:楊鵬連|2020-07-03 13:47:52.533|閱讀 406 次
概述:在本文中,讓我們看一下一個(gè)JavaScript示例,該示例通過(guò)調(diào)用Dynamsoft JavaScript條碼SDK來(lái)用幾行代碼實(shí)現(xiàn)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷售中 >>
Dynamic Web TWAIN是一個(gè)專為Web應(yīng)用程序設(shè)計(jì)的TWAIN掃描識(shí)別控件。你只需在TWAIN接口寫(xiě)幾行代碼,就可以用兼容TWAIN的掃描儀掃描文檔或從數(shù)碼相機(jī)/采集卡中獲取圖像。然后用戶可以編輯圖像并將圖像保存為多種格式,用戶可保存圖像到遠(yuǎn)程數(shù)據(jù)庫(kù)或者SharePoint。這個(gè)TWAIN控件還支持上傳和處理本地圖像。
點(diǎn)擊下載Dynamic Web TWAIN試用版
知道如何從Android上的PDF417中讀取駕駛執(zhí)照信息。與構(gòu)建Android本機(jī)攝像頭應(yīng)用程序相比,構(gòu)建網(wǎng)絡(luò)攝像頭應(yīng)用程序要容易得多。在本文中,讓我們看一下一個(gè)JavaScript示例,該示例通過(guò)調(diào)用Dynamsoft JavaScript條碼SDK來(lái)用幾行代碼實(shí)現(xiàn)。
JS Barcode SDK安裝
在JavaScript的條碼庫(kù)可供下載的npmjs.org。
您可以通過(guò)以下方式下載軟件包
npm install dynamsoft-javascript-barcode --save
或直接包含在線JS文件:
<script src="http://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@7.4.0-v1/dist/dbr.js" data-productKeys="PRODUCT-KEYS"></script>
在不到30秒的時(shí)間內(nèi)構(gòu)建Web條形碼閱讀器
Dynamsoft JavaScript條碼SDK基于WebAssembly,為Web開(kāi)發(fā)人員帶來(lái)了高性能的條碼掃描功能。此外,它提供了內(nèi)置的相機(jī)模塊API。使用深層封裝JavaScript SDK,您將發(fā)現(xiàn)使用相機(jī)制作HTML5條碼讀取器從未如此便捷。
要快速構(gòu)建網(wǎng)絡(luò)條形碼閱讀器,您只需要將以下代碼復(fù)制到HTML文件中:
<!DOCTYPE html>
<html>
<body>
<script src="http://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@7.4.0-v1/dist/dbr.js" data-productKeys="PRODUCT-KEYS"></script>
<script>
let scanner = null;
(async()=>{
scanner = await Dynamsoft.BarcodeScanner.createInstance();
scanner.onFrameRead = results => {console.log(results);};
scanner.onUnduplicatedRead = (txt, result) => {alert(txt);};
await scanner.show();
})();
</script>
</body>
</html>
注意:您必須獲得免費(fèi)的試用許可證才能替換PRODUCT-KEYS。
如果您已將Microsoft Edge,Chrome或Firefox更新到最新版本,則只需雙擊即可打開(kāi)HTML文件,而不需要進(jìn)行任何Web服務(wù)器部署。
基于AAMVA標(biāo)準(zhǔn)解析駕駛執(zhí)照信息
為了更好地平衡PDF417符號(hào)解碼的準(zhǔn)確性和性能,您最好根據(jù)在線文檔進(jìn)行一些參數(shù)配置:
let runtimeSettings = await scanner.getRuntimeSettings(); runtimeSettings.barcodeFormatIds = Dynamsoft.EnumBarcodeFormat.BF_PDF417; runtimeSettings.LocalizationModes = [2,8,0,0,0,0,0,0]; runtimeSettings.deblurLevel = 2;
最后一件事是創(chuàng)建一個(gè)JavaScript解析器,用于基于AAMVA標(biāo)準(zhǔn)提取駕駛執(zhí)照信息:
const DLAbbrDesMap = { 'DCA': 'Jurisdiction-specific vehicle class', 'DBA': 'Expiry Date', 'DCS': 'Last Name', 'DAC': 'First Name', 'DBD': 'Issue Date', 'DBB': 'Birth Date', 'DBC': 'Gender', 'DAY': 'Eye Color', 'DAU': 'Height', 'DAG': 'Street', 'DAI': 'City', 'DAJ': 'State', 'DAK': 'Zip', 'DAQ': 'License Number', 'DCF': 'Document Discriminator', 'DCG': 'Issue Country', 'DAH': 'Street 2', 'DAZ': 'Hair Color', 'DCI': 'Place of birth', 'DCJ': 'Audit information', 'DCK': 'Inventory Control Number', 'DBN': 'Alias / AKA Family Name', 'DBG': 'Alias / AKA Given Name', 'DBS': 'Alias / AKA Suffix Name', 'DCU': 'Name Suffix', 'DCE': 'Physical Description Weight Range', 'DCL': 'Race / Ethnicity', 'DCM': 'Standard vehicle classification', 'DCN': 'Standard endorsement code', 'DCO': 'Standard restriction code', 'DCP': 'Jurisdiction-specific vehicle classification description', 'DCQ': 'Jurisdiction-specific endorsement code description', 'DCR': 'Jurisdiction-specific restriction code description', 'DDA': 'Compliance Type', 'DDB': 'Card Revision Date', 'DDC': 'HazMat Endorsement Expiration Date', 'DDD': 'Limited Duration Document Indicator', 'DAW': 'Weight(pounds)', 'DAX': 'Weight(kilograms)', 'DDH': 'Under 18 Until', 'DDI': 'Under 19 Until', 'DDJ': 'Under 21 Until', 'DDK': 'Organ Donor Indicator', 'DDL': 'Veteran Indicator', // old standard 'DAA': 'Customer Full Name', 'DAB': 'Customer Last Name', 'DAE': 'Name Suffix', 'DAF': 'Name Prefix', 'DAL': 'Residence Street Address1', 'DAM': 'Residence Street Address2', 'DAN': 'Residence City', 'DAO': 'Residence Jurisdiction Code', 'DAR': 'License Classification Code', 'DAS': 'License Restriction Code', 'DAT': 'License Endorsements Code', 'DAV': 'Height in CM', 'DBE': 'Issue Timestamp', 'DBF': 'Number of Duplicates', 'DBH': 'Organ Donor', 'DBI': 'Non-Resident Indicator', 'DBJ': 'Unique Customer Identifier', 'DBK': 'Social Security Number', 'DBM': 'Social Security Number', 'DCH': 'Federal Commercial Vehicle Codes', 'DBR': 'Name Suffix', 'PAA': 'Permit Classification Code', 'PAB': 'Permit Expiration Date', 'PAC': 'Permit Identifier', 'PAD': 'Permit IssueDate', 'PAE': 'Permit Restriction Code', 'PAF': 'Permit Endorsement Code', 'ZVA': 'Court Restriction Code', 'DAD': 'Middle Name' }; var parseDriverLicense = txt => { console.log(txt); let lines = txt.split('\n'); let abbrs = Object.keys(DLAbbrDesMap); let map = {}; lines.forEach((line, i) => { let abbr; let content; if(i === 1){ abbr = 'DAQ'; content = line.substring(line.indexOf(abbr) + 3); }else{ abbr = line.substring(0, 3); content = line.substring(3).trim(); } if(abbrs.includes(abbr)){ map[abbr] = { description: DLAbbrDesMap[abbr], content: content }; } }); return map; };
為了節(jié)省時(shí)間,您可以使用alert()顯示駕駛執(zhí)照信息:
scanner.onUnduplicatedRead = txt => { // Get infos let licenseInfo = parseDriverLicense(txt); alert(JSON.stringify(licenseInfo)); };
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: