Ruby OCR SDK
Last updated
Was this helpful?
Was this helpful?
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')
result = mindee_client.parse(
input_source,
Mindee::Product::Invoice::InvoiceV4
)
# Print a full summary of the parsed data in RST format
puts result.documentinput_source = mindee_client.source_from_url("https://my-url")input_source = mindee_client.source_from_bytes('/path/to/the/file.ext', "name-of-my-file.ext")input_source = mindee_client.source_from_b64string('/path/to/the/file.ext', "name-of-my-file.ext")input_source = mindee_client.source_from_file(input_file, "name-of-my-file.ext")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')
result = mindee_client.parse(
input_source,
Mindee::Product::EU::LicensePlate::LicensePlateV1
)
# Print a full summary of the parsed data in RST format
puts result.documentrequire 'mindee'
# Init a new client and configure your custom document
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
endpoint = mindee_client.create_endpoint(
endpoint_name: 'my-endpoint',
account_name: 'my-account'
)
# Load a file from disk
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
result = mindee_client.parse(
input_source,
Mindee::Product::Universal::Universal,
endpoint: endpoint
)
# Print a full summary of the parsed data in RST format
puts result.document
# Looping over all prediction values
result.document.inference.prediction.fields.each do |field_name, field_data|
puts field_name
puts field_data.values
puts field_data.to_s
endrequire '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')
# Send the file to the server
enqueue_response = mindee_client.enqueue(
input_source,
Mindee::Product::InternationalId::InternationalIdV2
)
job_id = enqueue_response.job.id
# Load the JSON string sent by the Mindee webhook POST callback.
# Reading the callback data will vary greatly depending on your HTTP server.
# This is therefore beyond the scope of this example.
local_response = Mindee::Input::LocalResponse.new(request.body.string)
# You can also use a File object as the input.
# FILE_PATH = File.join('path', 'to', 'file.json').freeze
# local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
# Optional: verify the HMAC signature.
unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
raise "Invalid HMAC signature!"
end
# Deserialize the response:
result = mindee_client.load_prediction(
Mindee::Product::InternationalId::InternationalIdV2,
local_response
)
# Print a full summary of the parsed data in RST format
puts result.documentruby ./bin/mindee.rb <product_name> path/to/your/file.extbundle exec ruby ./bin/mindee.rb <product_name> path/to/your/file.ext