Skip to main content

Barcode Detection

Automatically detects and decodes barcodes in document images. Supports QR codes, DataMatrix, PDF417, and 1D barcode formats. Cross-validates barcode data against MRZ and visual inspection zone (VIZ) data to detect tampering.

How It Works

  1. Document image is analyzed for barcodes during document upload
  2. All barcodes in the image are detected and decoded
  3. PDF417 barcodes (US/Canadian driver's licenses) are parsed using AAMVA format
  4. Barcode data is cross-validated against MRZ data for consistency
  5. Discrepancies are flagged as potential document tampering

Barcode detection runs automatically as part of the document verification pipeline. No additional API call is needed.

Supported Formats

FormatUsageCross-Validation
QR CodeEU digital IDs, some visasJSON payload compared to MRZ
DataMatrixVisas, residence permitsCompared to MRZ
PDF417US/Canadian driver's licensesAAMVA fields compared to MRZ
EAN-13Product barcodesDetected but not cross-validated
EAN-8Product barcodesDetected but not cross-validated
Code 128Shipping labels, visasDetected but not cross-validated
Code 39Military IDs, some licensesDetected but not cross-validated
ITFLogistics barcodesDetected but not cross-validated

AAMVA PDF417 Parsing

US and Canadian driver's licenses use PDF417 barcodes with AAMVA-compliant data elements. Valydar automatically extracts:

FieldAAMVA CodeDescription
Last nameDCSFamily name
First nameDACGiven name
Middle nameDADMiddle name
Date of birthDBBMMDDYYYY format
SexDBCGender code
Eye colorDAYEye color code
Document numberDAQLicense/ID number
Expiry dateDBAMMDDYYYY format
AddressDAL-DAMStreet, city, state, postal code
HeightDAX/DCEHeight in ft/cm
WeightDAW/DCHWeight in lbs/kg

Cross-Validation

When both barcode and MRZ data are available, Valydar compares:

  • Document number — barcode value must match MRZ document number
  • Name — barcode last name must match MRZ primary identifier
  • Date of birth — AAMVA MMDDYYYY converted to ISO format and compared to MRZ DOB

Example: Matching Data

{
"mrz_matches_barcode": true,
"barcode_matches_viz": true,
"discrepancies": []
}

Example: Mismatch Detected

{
"mrz_matches_barcode": false,
"barcode_matches_viz": true,
"discrepancies": [
"document number mismatch: barcode='D1234567', mrz='S9876543'"
]
}

Result Structure

The barcode check result is included in the verification's checks_results:

{
"type": "document",
"result": "passed",
"details": {
"barcodes": [
{
"format": "pdf417",
"raw_text": "DCSDOE<<JOHN<<<<<<<<<<<<<<<<<<<<<<<...",
"position": { "x": 50, "y": 200, "width": 400, "height": 80 }
}
],
"barcodes_detected": 1,
"barcode_formats": ["pdf417"],
"barcode_cross_validation": {
"mrz_matches_barcode": true,
"barcode_matches_viz": true,
"discrepancies": []
}
}
}

Tips

  • Ensure the barcode area is clearly visible and not obscured
  • Higher resolution images improve barcode detection accuracy
  • For driver's licenses, the back of the card typically contains the PDF417 barcode
  • Cross-validation failures may indicate document tampering — review manually