Giter Club home page Giter Club logo

app-ocr-functions's Introduction

OCRDemo = Nano-Services with Azure Functions

Simply open up the OCRItemsDataPage.xaml and enter your Azure Mobile App backend URL

OCR

Azure Functions Setup

Read the full blog at:

See the video:

<iframe width="640" height="480" src="https://www.youtube.com/embed/TImd9RGdreQ" frameborder="0" allowfullscreen></iframe>

Core for Azure Functions

#r "Microsoft.WindowsAzure.Storage"
#r "System.Runtime"
#r "System.Threading.Tasks"
#r "System.IO"

using System;
using System.Linq;
using System.Runtime;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.ProjectOxford.Vision;

public static void Run(ICloudBlob myBlob, TraceWriter log, out object outputRecord)
{
    var client = new VisionServiceClient("YOUR_API_KEY");
   
    log.Info($"C# Blob trigger function processed: {myBlob.Uri.ToString()}");
    
    var url = myBlob.Uri.ToString();
    var result = client.RecognizeTextAsync(url).Result;
    
     var words = from r in result.Regions
        from l in r.Lines
        from w in l.Words
        select w.Text;

    var output = string.Join(" ", words.ToArray());
    
    log.Info($"Complete output from OCR: {output}");
   
   
    var numbers = from word in words
                where word.Contains("$")
                select word.Replace("$", "");

    double temp = 0.0;
    var total = numbers.Count() == 0 ? 0.0 : numbers.Select(x => double.TryParse(x, out temp) ? temp : 0).Max();

    log.Info($"We found the total of: {total}");

    // 3. Add to data-bound collection.
    outputRecord = new 
    {
        Total = total,
        TimeStamp = DateTime.UtcNow,
        Url = url,
        Text = output
    };
   
}

app-ocr-functions's People

Contributors

jamesmontemagno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.