docs/passport_v1
title: Passport OCR Ruby
category: 622b805aaec68102ea7fcbc2
slug: ruby-passport-ocr
parentDoc: 6294d97ee723f1008d2ab28e
The Ruby OCR SDK supports the Passport API.
Using the sample below, we are going to illustrate how to extract the data that we want using the OCR SDK.
Quick-Start
require 'mindee' # Init a new client mindee_client = Mindee::Client.new(api_key: 'my-api-key') # Load a file from disk input_source = mindee_client.source_from_path('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( input_source, Mindee::Product::Passport::PassportV1 ) # Print a full summary of the parsed data in RST format puts result.document # Print the document-level parsed data # puts result.document.inference.prediction
Output (RST):
######## Document ######## :Mindee ID: 18e41f6c-16cd-4f8e-8cd2-00ca02a35764 :Filename: default_sample.jpg Inference ######### :Product: mindee/passport v1.0 :Rotation applied: Yes Prediction ========== :Country Code: GBR :ID Number: 707797979 :Given Name(s): HENERT :Surname: PUDARSAN :Date of Birth: 1995-05-20 :Place of Birth: CAMTETH :Gender: M :Date of Issue: 2012-04-22 :Expiry Date: 2017-04-22 :MRZ Line 1: P): The given name(s) of the passport holder. ```rb for given_names_elem in result.document.inference.prediction.given_names do puts given_names_elem.value end
ID Number
id_number (StringField): The passport’s identification number.
puts result.document.inference.prediction.id_number.value
Date of Issue
issuance_date (DateField): The date the passport was issued.
puts result.document.inference.prediction.issuance_date.value
MRZ Line 1
mrz1 (StringField): Machine Readable Zone, first line
puts result.document.inference.prediction.mrz1.value
MRZ Line 2
mrz2 (StringField): Machine Readable Zone, second line
puts result.document.inference.prediction.mrz2.value
Surname
surname (StringField): The surname of the passport holder.
puts result.document.inference.prediction.surname.value