Giter Club home page Giter Club logo

receiptanalyzer's Introduction

Receipt Analyzer

This was a quick experiment I threw together to test the output of Azure Cognitive Services specifically with restaurant receipts.

Prerequisites

  • Python 3.6+ (using f strings, you can reformat and use with <3.6)
  • Requests library
  • Azure Subscription
    • Azure Form recognizer instance

Running the project

Environment set up

When you create your Azure Form Recognizer instance, you'll get an endpoint and a key, you'll need both to make requests.

These values will need to be passed to the receipt-analysis.py file.

It's configured to use environment variables:

     REQUEST_URL = os.environ['REQUEST_URL']
     KEY = os.environ['REQUEST_KEY'] 

You'll need to set those variables up in your environment, or edit the receipt-analysis.py file and hardcode your values. A quick word on security: you really should avoid hardcoding, especially if your code might end up on a public code sharing platform.

Making the request

receipt-analysis.py is what will make the request and takes the file path of your receipt picture as the first and only argument.

     python3 receipt-analysis.py [file-path]

If successful you'll see something like..

     Running OCR
     Loading Result...
     Waiting...
     Waiting...
     Results Loaded

It can take a few seconds to run as there are actually two requests, one of which can run multiple times before the results are available.

You should have a new file called 'azure-results.json' which will have the results from Azure.

Getting User Friendly Data from JSON

You can use process-azure-results.py to print out certain information from the output of receipt-analysis.py. It'll print out the address and the items that were ordered.

     python3 process-azure-results.py [file-path-to-your-json]

I only did this as a POC so there is very little (i.e. no) error checking so depending on what you get back from Azure, you're likely to run into an error.

receiptanalyzer's People

Contributors

dennysabu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.