Code Monkey home page Code Monkey logo

evernote-ocr's Introduction

Evernote OCR

Latest Stable Version Build Status Coverage Status

This is an unofficial library for using the Evernote API as a means for image text recognition. Please be advised that using the Evernote API solely for the purpose of OCR for your application is a violation of the API License Agreement.

Installation

Install this package through Composer by editing your project's composer.json file to require estey/evernote-ocr.

{
    "require": {
        "estey/evernote-ocr": "0.2.*"
    }
}

Then, update Composer:

composer update

To get a new Evernote Dev Token, sign in to your account and use this link: https://www.evernote.com/api/DeveloperToken.action

Usage

use Estey\EvernoteOCR\Client;

$client = new Client('YOUR DEV TOKEN');
$response = $client->recognize('path/to/image.jpg');

print_r($response);

The recognize method will return an array of TextBlock objects, each with an array of text recognition options. Each Text object contains the recognized text and a confidence score of 0-100. Each TextBlock contains the X and Y coordinates where the text was found and the width and height of the text block in pixels.

Array
(
    [0] => Estey\EvernoteOCR\TextBlock Object
        (
            [x] => 51
            [y] => 82
            [width] => 307
            [height] => 35
            [options] => Array
                (
                    [0] => Estey\EvernoteOCR\Text Object
                        (
                            [text] => SEPTEMBER
                            [confidence] => 91
                        )

                )

        )

    [1] => Estey\EvernoteOCR\TextBlock Object
        (
            [x] => 370
            [y] => 87
            [width] => 128
            [height] => 30
            [options] => Array
                (
                    [0] => Estey\EvernoteOCR\Text Object
                        (
                            [text] => 2014
                            [confidence] => 77
                        )

                    [1] => Estey\EvernoteOCR\Text Object
                        (
                            [text] => 201 a
                            [confidence] => 35
                        )

                )

        )

)

Laravel Filesystem Adapter

If you're using Laravel, there is a service provider available. Open app/config/app.php, and add the service provider to the providers array. You'll also need to add your Evernote Dev Token to your .env file with the key set to EVERNOTE_DEV_TOKEN.

'Estey\EvernoteOCR\Providers\Illuminate\EvernoteOCRServiceProvider'

Use it like so:

$client = App::make('evernote_ocr', ['path/to/image.jpg']);
$response = $client->recognize();

print_r($response);

Flysystem Adapter

The Evernote OCR package comes with a built in adapter to support the Flysystem filesystem library.

use Estey\EvernoteOCR\Client;
use Estey\EvernoteOCR\FileAdapters\FlysystemFileAdapter;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as Adapter;

$filesystem = new Filesystem(
    new Adapter(__DIR__ . '/path/to/root/')
);

$client = new Client('YOUR DEV TOKEN');
$file = new FlysystemFileAdapter('path/to/image.jpg', $filesystem);
$response = $client->recognize($file);

print_r($response);

License

The MIT License (MIT). Please see License File for more information.

evernote-ocr's People

Contributors

bradestey avatar

Watchers

 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.