Train Ticket OCR

This article shows you how to build an OCR API that extracts data from train tickets (or eTickets) using our deep learning engine. It will work for any train ticket format or template, paper or digital. Improve your workflow by extracting data directly from your train ticket documents.

Prerequisites

  1. You’ll need a free account. Sign up and confirm your email to login.
  2. You’ll need at least 20 train ticket images or PDFs to train your OCR.

Define your Train Ticket use case

First, we’re going to define the fields we'd like to extract from our train tickets.

Train ticket key data extractionTrain ticket key data extraction

Train ticket key data extraction

  • Passenger name: The full name of the passenger traveling (Jane Martin)
  • Reservation number: The reservation number of your train ticket (925D90)
  • Departure Date: The date of departure
  • Departure station code: The 3 letters identification code for your departure station (WAS)
  • Arrival station code: The 3 letters identification code for your arrival station (NYP)
  • Departure Time: The train departure time from the departure station (01:50 PM)

That’s it for our use case. Feel free to add any other relevant data to fit your requirements.

Deploy your API

Once you have defined all of the fields you want to extract, head over to the platform and press the ‘create a new API’ button.

You land now on the setup page. Here is the image you can use to set up the API. For instance, my setup is as follows:
Set up your modelSet up your model

Set up your model

Once you’re ready, click on the “next” button. We are going to specify the data types for each of the fields we want our API to extract.

To move forward, you have two possibilities:

Upload a json config
Copy the following JSON into a file and upload it on the interface

{
  "problem_type": {
    "classificator": { "features": [], "features_name": [] },
    "selector": {
      "features": [
        {
          "cfg": { "filter": { "alpha": -1, "numeric": 0 } },
          "handwritten": false,
          "name": "passenger_name",
          "public_name": "Passenger name",
          "semantics": "word"
        },
        {
          "cfg": { "filter": { "alpha": -1, "numeric": -1 } },
          "handwritten": false,
          "name": "reservation_number",
          "public_name": "Reservation number",
          "semantics": "word"
        },
        {
          "cfg": { "filter": { "convention": "US" } },
          "handwritten": false,
          "name": "departure_date",
          "public_name": "Departure Date",
          "semantics": "date"
        },
        {
          "cfg": { "filter": { "alpha": -1, "numeric": 0 } },
          "handwritten": false,
          "name": "departure_station_code",
          "public_name": "Departure Station Code",
          "semantics": "word"
        },
        {
          "cfg": { "filter": { "alpha": -1, "numeric": 0 } },
          "handwritten": false,
          "name": "arrival_station_code",
          "public_name": "Arrival Station Code",
          "semantics": "word"
        },
        {
          "cfg": { "filter": { "alpha": -1, "numeric": -1 } },
          "handwritten": false,
          "name": "departure_time",
          "public_name": "Departure Time",
          "semantics": "word"
        }
      ],
      "features_name": [
        "passenger_name",
        "reservation_number",
        "departure_date",
        "departure_station_code",
        "arrival_station_code",
        "departure_time"
      ]
    }
  }
}

Or build your data model manually
Using the interface, add up to your data model each field.

Define your modelDefine your model

Define your model

  • Passenger name: String type that never contains numeric characters.
  • Reservation number: String type without specifications.
  • Departure Date: Date type with US format.
  • Departure Station Code: String type that never contains numeric characters.
  • Arrival Station Code: type String that never contains numeric characters.
  • Departure Time: type String without specifications.

Once you’re done setting up your data model, press the Start training your model button at the bottom of the screen.

Data model ready to trainData model ready to train

Data model ready to train

Train your Boarding Pass OCR

Train your train ticket OCRTrain your train ticket OCR

Train your train ticket OCR

You’re all set!

Now is the time to train your train ticket deep learning model in the Training section of your API.

In a few hours (minutes if you're swift), you’ll get your first model trained and will be able to use your custom OCR API for parsing train tickets in your application.

To get more information about the training phase, please refer to the Getting Started tutorial.

If you have any questions regarding your use case, feel free to reach out on the chat!

Updated 4 months ago


Train Ticket OCR


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.