Giter Site home page Giter Site logo

google_drive_ocr's Introduction

Google OCR (Drive API v3)

https://img.shields.io/pypi/v/google_drive_ocr?color=success Documentation Status Python Version Support GitHub Issues GitHub Followers Twitter Followers

Perform OCR using Google's Drive API v3

Features

  • Perform OCR using Google's Drive API v3
  • Class GoogleOCRApplication() for use in projects
  • Highly configurable CLI
  • Run OCR on a single image file
  • Run OCR on multiple image files
  • Run OCR on all images in directory
  • Use multiple workers (multiprocessing)
  • Work on a PDF document directly

Usage

Using in a Project

Create a GoogleOCRApplication application instance:

from google_drive_ocr import GoogleOCRApplication

app = GoogleOCRApplication('client_secret.json')

Perform OCR on a single image:

app.perform_ocr('image.png')

Perform OCR on mupltiple images:

app.perform_ocr_batch(['image_1.png', 'image_2.png', 'image_3.png'])

Perform OCR on multiple images using multiple workers (multiprocessing):

app.perform_ocr_batch(['image_1.png', 'image_3.png', 'image_2.png'], workers=2)

Using Command Line Interface

Typical usage with several options:

google-ocr --client-secret client_secret.json \
--upload-folder-id <google-drive-folder-id>  \
--image-dir images/ --extension .jpg \
--workers 4 --no-keep

Show help message with the full set of options:

google-ocr --help

Configuration

The default location for configuration is ~/.gdo.cfg. If configuration is written to this location with a set of options, we don't have to specify those options again on the subsequent runs.

Save configuration and exit:

google-ocr --client-secret client_secret.json --write-config ~/.gdo.cfg

Read configuration from a custom location (if it was written to a custom location):

google-ocr --config ~/.my_config_file ..

Performing OCR

Note: It is assumed that the client-secret option is saved in configuration file.

Single image file:

google-ocr -i image.png

Multiple image files:

google-ocr -b image_1.png image_2.png image_3.png

All image files from a directory with a specific extension:

google-ocr --image-dir images/ --extension .png

Multiple workers (multiprocessing):

google-ocr -b image_1.png image_2.png image_3.png --workers 2

PDF files:

google-ocr --pdf document.pdf --pages 1-3 5 7-10 13

Note: You must setup a Google application and download client_secrets.json file before using google_drive_ocr.

Setup Instructions

Create a project on Google Cloud Platform

Wizard: https://console.developers.google.com/start/api?id=drive

Instructions:

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.