Can You Read a Book Digitally Using Its Barcode
If yous've renewed your commuter'south license whatsoever time in the concluding few years, y'all have probable noticed an increase in its visual complexity. Many governing bodies take made significant strides towards making forgery more difficult. The unfortunate side-effect from that positive change is that traditional recognition algorithms are more difficult with the many colors, backgrounds, holograms, and layouts.
Thankfully, new driver's licenses as well accept PDF417 barcodes on them, and in North America, follow specifications laid out by the American Association of Motor Vehicle Administrators (AAMVA). These barcodes are pocket-size, error resistant, and can encode a lot of information.
This tutorial will introduce you to the classes and methods for both reading and writing AAMVA-compliant barcodes from Driver's Licenses.
Reading AAMVA Barcodes
Since Driver'south Licenses are and so broadly accepted as forms of identification, at that place are a wealth of opportunities for reading the information from them. We covered those concepts in an before white paper on Capturing Client Information from Driver's Licenses, so we won't repeat them here. That paper also discussed using the PDF417 barcodes before they were regulated by AAMVA. Since then, LEADTOOLS has added a new AAMVAID
class which does all the field parsing for you.
What's the large deal? Take a wait at the raw data for an AAMVA barcode:
@∖n∖u001e∖rANSI 636004080002DL00410266ZN03070017DLDAQ123456789123∖nDCSDOE∖nDDEN∖nDACJANE∖nDDFN∖nDAD∖nDDGN∖nDCAC∖nDCBNONE∖nDCDNONE∖nDBD08152015∖nDBB08151987∖nDBA08152020∖nDBC2∖nDAU070 in∖nDAYBRO∖nDAG1100 NEW BERN AVENUE∖nDAIRALEIGH∖nDAJNC∖nDAK276970001∖nDCF0123456789∖nDCGUSA∖nDAZBRO∖nDCLU ∖nDCK000012345678NCSVTL01∖nDDB10242014∖nDDK1∖nDDL1∖nZNZNADUP∖nZNB∖nZNC0∖n
Where's the proper name? Or the birthdate? Do you need to calculate if this person is over 21 and legally immune to make a purchase? With LEADTOOLS, yous can get that kind of information in beautiful, strongly typed properties:
using (AAMVAID id = BarcodeData.ParseAAMVAData(information.GetData(), faux)) { Console.WriteLine("Issuer Identification Number: " + id.IssuerIdentificationNumber); Console.WriteLine("First Name: " + id.FirstName.Value); Console.WriteLine("Last Name: " + id.LastName.Value); Console.WriteLine("Over 21?: " + id.Over21); // etc. }
Writing AAMVA Barcodes
There may be fewer reasons for generating AAMVA barcodes, but every motor vehicle agency in every state or province in the Usa, Canada, and Mexico needs the ability to impress them on the licenses they issue. Naturally, you can't just print whatever old barcode onto licenses and IDs. As with well-nigh specifications, they are hard to follow and tin crusade a significant evolution roadblock due to the R&D requirements. LEADTOOLS simplifies this in two means: generating the AAMVA string and creating the PDF417 barcode.
Beginning, you need to convert your customer data into a valid AAMVA cord value. To aid in this process, LEADTOOLS provides the AAMVAIDBuilder
class. The builder will aid organize the data and output it conforming to the 2016 AAMVA CDS. Here nosotros initialize the AAMVAIDBuilder
, add together some information and then employ the Build part to generate the AAMVAID
object:
AAMVAIDBuilder builder = new AAMVAIDBuilder(); builder.SetJurisdiction(AAMVAJurisdiction.NorthCarolina, AAMVAID.LookupIssuerIdentificationNumber(AAMVAJurisdiction.NorthCarolina)); // Set principal data builder.SetVersion(AAMVAVersion.Version2016); builder.SetJurisdictionVersion("00"); builder.SetNumberOfEntries(1); // Build the subfile entry as a driver's license (vs. an ID) builder.SetSubfileType(0, AAMVASubfileType.DL, "DL"); builder.AddDataElementToSubfile(0, "DAC", "John"); builder.AddDataElementToSubfile(0, "DCS", "Doe"); // etc. // Get the AAMVA string data byte[] data; using (AAMVAID id = builder.Build()) { data = id.GetBytes(); }
At present that our customer'southward information is correctly encoded for AAMVA, nosotros volition create the PDF417 barcode. Thank you to LEAD'due south nearly three decades of experience in with raster and document imaging technologies, this process is even simpler than writing the AAMVA string despite the barcode's greater complexity. Here nosotros generate the BarcodeEngine
, gear up a few options to assistance the proportions make AAMVA happy, and LEADTOOLS takes intendance of the rest. In this elementary instance, we simply created a bare prototype using the calculated bounds of the barcode:
BarcodeEngine engine = new BarcodeEngine(); PDF417BarcodeWriteOptions writeOptions = (PDF417BarcodeWriteOptions)engine.Writer.GetDefaultOptions(BarcodeSymbology.PDF417); //Refer to AAMVA CDS 2016 Section D.3 thru D.eleven.ii //Must range from 0.0066 to 0.015 inches writeOptions.XModule = 15; //0.015 //Must >= 3 writeOptions.XModuleAspectRatio = 3; //Error level must be at to the lowest degree three, v is recommended writeOptions.ECCLevel = PDF417BarcodeECCLevel.Level5; //Default WidthAspectRatio is ii:1. 4:1 looks like to ID barcodes in the wild writeOptions.SymbolWidthAspectRatio = 4; //Default quiet zone for PDF417 is 2 * XModule PDF417BarcodeData barcodeData = (PDF417BarcodeData)BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.PDF417); barcodeData.SetData(data); const int resolution = 96; // screen resolution engine.Writer.CalculateBarcodeDataBounds(LeadRect.Empty, resolution, resolution, barcodeData, writeOptions); using (RasterImage prototype = RasterImage.Create(barcodeData.Bounds.Width, barcodeData.Bounds.Peak, 24, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))) { engine.Writer.WriteBarcode(image, barcodeData, writeOptions); using (RasterCodecs codecs = new RasterCodecs()) { codecs.Save(image, imageFilePath, RasterImageFormat.Png, image.BitsPerPixel); } }
Equally a check, we'll load the image back into the Principal Barcode demo like before and read the data.
Alter the Globe! (or at least your DMV...)
Reading is really the easy part. Most of you on this blog are pretty nifty and might've picked upwards on how the raw data in that string worked and thought, "I could parse that!" Equally mentioned previously, the biggest catch out in that location is adoption. It'due south one thing to figure out how to parse some values from a long text string, but writing them out correctly and following the AAMVA spec is what's really belongings states and countries back. LEADTOOLS makes information technology incredibly easy to make certain your data follows the specifications, AND can write the barcode. Then get out there and code something that'south so like shooting fish in a barrel, even a sloth can do it!
Conclusion
LEADTOOLS has a history of staying on the forefront of document imaging and recognition technologies like OCR, Forms, Barcode, and PDF. Driver's licenses and IDs have become far more than complex, yet improve regulated with the adoption of AAMVA barcodes. LEADTOOLS will stay a feasible pick for developers wanting to speedily and easily create software to read and write identification data stored in AAMVA barcodes.
Download the Full AAMVA Barcode Example
You lot tin download the fully functional demo which includes the features discussed above. To run this example you will demand the following:
- LEADTOOLS gratuitous evaluation
- Visual Studio 2010 or subsequently
- Browse to the LEADTOOLS Examples folder (east.yard. C:∖LEADTOOLS 20∖Examples∖) where you tin can observe case projects for this and many more technologies in LEADTOOLS.
Need help getting this sample up and going? Contact our support team for complimentary technical back up! For pricing or licensing questions, yous can contact our sales squad (sales@leadtools.com) or call us at 704-332-5532.
Source: https://www.leadtools.com/blog/document-imaging/barcode/reading-writing-aamva-barcodes-drivers-licenses/
0 Response to "Can You Read a Book Digitally Using Its Barcode"
Publicar un comentario