‚Äč

Cloud OCR SDK Documentation

processReceipt Method

Important: the technology fully supports US receipts, other countries are currently supported in beta mode.

Use recommendations at ABBYY Technology Portal to gain the best result. 

The method allows you to recognize the image of a receipt. The method loads the image, creates a processing task for the image with the specified parameters, and passes the task for processing.

[POST] http(s)://cloud.ocrsdk.com/processReceipt

The image file is transmitted in the request body. See the list of supported input formats.

See How to Recognize Receipts to know how to tune the parameters.

For details on task cost please see billing terms.

Parameters

ParameterIs requiredDefault valueDescription
country No "usa"

Specifies the country where the receipt was printed. This parameter can contain several names of countries separated with commas, for example "taiwan,china". The following values are supported:

  • uk
  • usa
  • australia
  • canada
  • japan
  • germany
  • italy
  • france
  • brazil
  • russia
  • china
  • korea
  • netherlands
  • spain
  • singapore
  • taiwan

Important! The technology fully supports US receipts, other countries are currently supported in beta mode.

imageSource No "auto"

Specifies the source of the image. It can be either a scanned image, or a photograph created with a digital camera. Special preprocessing operations can be performed with the image depending on the selected source. For example, the system can automatically correct distorted text lines, poor focus and lighting on photos.

The value of this parameter can be one of the following:

  • auto
    The image source is detected automatically.
  • photo
  • scanner
correctOrientation No "true" Specifies whether the orientation of the image should be automatically detected and corrected. It can have one of the following values:
  • true
    The page orientation is automatically detected, and if it differs from normal the image is rotated.
  • false
    The page orientation detection and correction is not performed.
correctSkew No "true" Specifies whether the skew of the image should be automatically detected and corrected. It can have either true or false value.
xml:writeExtendedCharacterInfo No "false" Specifies whether the additional information on the recognized characters (e.g. whether the character is recognized uncertainly) should be written to an output file in XML format. The parameter can have one of the following values:
  • true
  • false
description No "" Contains the description of the processing task. Must contain no more than 255 characters.
pdfPassword No "" Contains a password for accessing password-protected images in PDF format.

Status codes and response format

General status codes and response format of the method are described in HTTP Status Codes and Response Formats.

The following status codes can be returned when this method is called:

CodeDescription
200 Successful method call.
450 Incorrect parameters have been passed. One of the following errors occurred:
  • Image file has not been specified.
  • Incorrect recognition language has been specified.
  • Incorrect export format has been specified.
  • Task description length exceeds 255 characters.
  • Incorrect password for accessing password-protected image file has been specified.
  • Exceeded quota to add images. This error is returned if the number of images you have uploaded exceeds the number of images you can process with the credits available on your account plus some threshold. You can resolve this issue by topping up your account or by removing the tasks which have been submitted but have not been processed.
550 An internal program error occurred while processing the image.
551 An error occurred on the server side:
  • The format of the image file passed for processing is not supported.
  • The PDF file passed for processing has restrictions on creating raster images.

Output file format

The result of processing is returned in an XML file of the following format:

<?xml version="1.0" encoding="UTF-8"?>
<receipts count="1" xmlns="http://www.abbyy.com/ReceiptCaptureSDK_xml/ReceiptCapture-1.0.xsd">
 <receipt currency="USD">
<date>
   <normalizedValue>2011-04-30</normalizedValue>
   <recognizedValue>
    <text>04/30/2011</text>
   </recognizedValue>
  </date>
<total>
   <normalizedValue>54.26</normalizedValue>
   <recognizedValue>
    <text>$54.26</text>
   </recognizedValue>
  </total>
</receipt>
</receipts>

See the XSD schema of an XML file.

Receipt languages

You do not need to set the recognition languages for receipt recognition; they will be selected automatically on the basis of the countries you specify. See below the list of languages corresponding to countries.

CountryLanguages
United Kingdom English
USA English
Japan Japanese; English
Germany German
Italy Italian; English
France French
Brazil Portuguese (Brazil); English
Russia Russian
China Chinese Simplified
Korea Korean; English
Spain Spanish; English
Taiwan Chinese Traditional
Netherlands Dutch

Note that the receipt in one of these languages, but printed in some other country, is not guaranteed to be recognized correctly.

Description of receipt fields and attributes

The receipt tag can have several attributes which characterize the receipt as a whole.

AttributeDescription
paymentType

The payment type of the purchase. Can have one of the following values:

  • Card
  • Cash
  • Undefined
cardType The type of the card used for payment. It only makes sense if purchaseType is Card.
currency The three-character code of the currency of the receipt. If it is impossible to determine the code for dollar currency (e.g. if it is US dollar or Australian dollar), this property returns "$".
purchaseType The purchase type. It can be a receipt from supermarket, fuel station, parking, etc.

 The receipt tag also contains field tags, line item tags, and a tag with the full recognized text of the receipt. Each field represents some type of data found on the receipt. Each line item represents a line of the receipt and can contain several components.

The following table describes fields which can be found on the receipt.

Field typeDescription
Total

The total sum of the purchase.

SubTotal The subtotal of the receipt.
CardNumber The number of the card which was used during purchase. It only makes sense if purchaseType is Card.
TotalTax

The total sum of the tax.

Tax

One of the tax fields.

Date The date of the purchase.
Time The time when the receipt was printed out.
Vendor The title of the vendor organization.
Address The address field of the receipt.
Phone The phone number printed on the receipt.
Fax The fax number printed on the receipt.

 The following table describes the components a line item may have.

Line item componentDescription
ItemName

The name of the purchased item.

TotalValue

The total amount of money in the receipt line.

PricePerUnit

The price per one item.