Skip to content

Instantly share code, notes, and snippets.

View antlypls's full-sized avatar

Anatoliy Plastinin antlypls

View GitHub Profile
antlypls /
Created May 2, 2016 21:38 — forked from dannguyen/
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

if [ -z "$1" ] ; then
echo 'Project name is empty'
exit 1
antlypls /
Last active August 29, 2015 14:21 — forked from chrismdp/
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (
# Based on a modified script from here:
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
antlypls /
Last active August 29, 2015 14:15 — forked from senko/
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
# Written by: Senko Rasic <>
# Requires Linux, bash and inotifywait (from inotify-tools package).
# To avoid executing the command multiple times when a sequence of
require 'spec/support/grep_matcher'
describe do
disallow_presence_of pattern: "send(.*#",
location: "app/",
description: "Do not use dynamic method invocations",
failure: "Please change dynamic method call to something more sane."
@mixin mobile_bg($file){
background-image: image-url('mobile/standard/#{$file}');
@media screen and (-webkit-min-device-pixel-ratio: 2) {
background-image: image-url('mobile/retina/#{$file}');
background-size: image-width('mobile/standard/#{$file}') image-height('mobile/standard/#{$file}');
// Usage
guard 'process', :name => 'shrink-images', :command => 'ruby resize-mobile-images.rb mobileretina' do
watch /^images\/mobileretina\/.+/
# config/locales/en.yml
title: "Not Found"
description: "The page you were looking for does not exists."
title: "Internal Server Error"
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
# create the template
template =
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = template.render_to_string(:template=>"quotes/review.html.haml")