VIN

Overview

The parser supports all standards of the Vehicle Identification Number (VIN).

Standards differ a little bit from each other. North America standard (used in the USA) is more strict than ISO 3779 standard and the standard used in the European Union. European Union standard doesn’t have to contain information about model year, plant or check digit.

VIN numbers encoded in barcodes

VIN numbers encoded in barcodes (Code39) sometimes contain more than 17 characters. These codes can also be parsed and are handled the following way: For 18 characters the first character is stripped. For 19 characters the first and the last character are stripped. For 20 characters first two and the last character are stripped.

Sample usage for Vin parser and Text Capture

First, you need to create a DataCaptureContext, access a Camera and create VIN parser:

DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey(SCANDIT_LICENSE_KEY);
Camera camera = Camera.getDefaultCamera(TextCapture.createRecommendedCameraSettings());
dataCaptureContext.setFrameSource(camera);
camera.switchToDesiredState(FrameSourceState.ON);

TextCaptureSettings textCaptureSettings = TextCaptureSettings.fromJson(json);
TextCapture textCapture = TextCapture.forDataCaptureContext(dataCaptureContext, textCaptureSettings);

Parser parser = Parser.forFormat(dataCaptureContext, ParserDataFormat.VIN);

Then, you need to implement TextCaptureListener:

class MyTextCaptureListener implements TextCaptureListener {
@Override
public void onTextCaptured(
    @NonNull TextCapture textCapture,
    @NonNull TextCaptureSession session,
    @NonNull FrameData frameData
) {
    if (session.getNewlyCapturedTexts().isEmpty()) return;

    CapturedText text = session.getNewlyCapturedTexts().get(0);

    try {
        ParsedData parsedData = parser.parseString(text.getValue());
        /*
        * Extract the fields relevant to your use case. Below, for example, we extract a World Manufacturer Identifier,
        * which is represented as a map with keys "region", "fullCode" and "numberOfVehicles":
        */
        Map<String, Object> wmi = (Map<String, Object>) parsedData.getFieldsByName().get("WMI").getParsed();
        String region = wmi.get("region");
        String fullCode = wmi.get("fullCode");
        String numberOfVehicles = wmi.get("numberOfVehicles");

        // Do something with the extracted fields.
    } catch (RuntimeException e) {
        message = e.getMessage();
    }
    // Other callbacks omitted for brevity.
}

Finally, add the listener to the mode to receive scan results:

textCapture.addListener(new MyTextCaptureListener());

For details, go to the API docs.

Example

Parsing the following code (without quotes):

"5UXFG2C50DL782277"

will result in the following JSON output:

[
    {
        "name": "WMI",
        "parsed": {
            "region": "USA",
            "fullCode": "5UX"
            "numberOfVehicles": ">2000",
        },
        "rawString": "5UX"
    },
    {
        "name": "VDS",
        "parsed": "FG2C5",
        "rawString": "FG2C5"
    },
    {
        "name": "VIS",
        "parsed": {
            "modelYear" : [1983, 2013],
            "plant" : "L",
            "wmiSuffix" : null,
            "serialNumber" : "782277"
        },
        "rawString": "DL782277"
    },
    {
        "name" : "metadata",
        "parsed" : {
            "checksum" : "0",
            "passedChecksum": true,
            "standard": "northAmerica"
        },
        "rawString" : ""
    }
]

Fields

The following fields are exposed for VIN code:

Data Element ID

Meaning

Parsed Content

WMI

World Manufacturer Identifier

Dictionary with these key/value pairs:

  • ‘region’: String. English name of the region, e.g. Hungary, Japan, or USA.

  • ‘fullCode’: String. The full World Manufacturer Identifier (WMI), including the potential suffix from VIS (see wmiSuffix).

  • ‘numberOfVehicles’: String. Null or one of the following strings: ‘>2000’, ‘<2000’, ‘>500’, ‘<500’.

VDS

Vehicle Descriptor Section

String with vehicle data (contained information depends on manufacturer)

VIS

Vehicle Identification Section

Dictionary with these key/value pairs:

  • modelYear: Array of numbers. Building or model year of a vehicle. It is an array because that field is represented by only one digit in VIN code and is thus only unique within a period of 30 years.

  • plant: String. Manufacturer plant (assembly plant).

  • wmiSuffix: String. Null for >500/2000 vehicles/year for the model. The threshold of 2000 vs 500 cars depends on the standard used.

  • serialNumber: String. Serial number of the car. Six-digit for >2000 vehicles/year for the model. Three digit for <2000 vehicles/year for the model. The threshold of 2000 vs 500 cars depends on the standard used.

Metadata

The metadata field provides more information about the parsing of the input’s fields. The dictionary encoded in the JSON string of the ‘parsed’ field contains the following entries:

Key

Value Type

Description

checksum

string

check digit value

passedChecksum

boolean

true if checksum validation was successful

standard

string

One of the following strings:

  • ‘northAmerica’

  • ‘ISO’

  • ‘EU’

Parser Options

The parser can be configured by providing a JSON string containing key / value pairs. Currently there is only one option available:

Key

Value Type

Description

strictMode

boolean

Enabling this option allows the parser to fail for invalid checksums. Checksum verification results for the code are indicated using the ‘metadata’ field (with disabled strictMode).

falsePositiveCompensation

boolean

Enabling this option allow the parser to replace certain illegal characters with their non-illegal counterparts (I->1, Q->9, O->0).