Code Monkey home page Code Monkey logo

handwriting's Introduction

handwriting

A SQL implementation of an ancient handwriting recognition algorithm.

Yes, this is weird! But it nicely showcases that SQL is a programming language, which is the title of the seminar during which this work was done.

Overview: The directory code/ contains the implementation. In paper/, you'll find the LaTeX source of a short 4-page term paper on the topic. Finally, a Deckset-powered set of slides lives in presentation/.

Setup

Install PostgreSQL, version 10 or newer should work just fine. Then run:

psql -c "CREATE DATABASE handwriting;"
psql -d handwriting -f code/handwriting_setup.sql

Usage

Open code/index.html in your browser and draw a character as instructed. Ignore the "Working..." bit – setting up the server component, which runs the query on a background Postgres instance, can be a bit of a pain. Instead, copy the JSON value shown at the bottom of the page.

Change line 17 of code/handwriting.sql from

--\set pen '[ { "x": 37, "y": 31 }, { "x": 37, "y": 31 }, { "x": 37, "y": 34 }, { "x": 37, "y": 39 }, { "x": 38, "y": 43 }, { "x": 41, "y": 57 }, { "x": 44, "y": 66 }, { "x": 48, "y": 76 }, { "x": 52, "y": 86 }, { "x": 54, "y": 92 }, { "x": 56, "y": 96 }, { "x": 58, "y": 99 }, { "x": 59, "y": 101 }, { "x": 59, "y": 102 }, { "x": 60, "y": 102 }, { "x": 60, "y": 102 }, { "x": 60, "y": 101 }, { "x": 60, "y": 98 }, { "x": 61, "y": 90 }, { "x": 64, "y": 80 }, { "x": 65, "y": 73 }, { "x": 67, "y": 66 }, { "x": 69, "y": 60 }, { "x": 71, "y": 52 }, { "x": 72, "y": 49 }, { "x": 72, "y": 46 }, { "x": 73, "y": 44 }, { "x": 74, "y": 42 }, { "x": 74, "y": 41 }, { "x": 74, "y": 40 }, { "x": 74, "y": 40 }, { "x": 74, "y": 39 }, { "x": 74, "y": 39 }, { "x": 74, "y": 39 }, { "x": 74, "y": 39 }, { "x": 74, "y": 39 }, { "x": 74, "y": 39 }, { "x": 72, "y": 40 }, { "x": 67, "y": 43 }, { "x": 63, "y": 45 }, { "x": 60, "y": 47 }, { "x": 58, "y": 49 }, { "x": 56, "y": 50 }, { "x": 54, "y": 52 }, { "x": 52, "y": 52 }, { "x": 51, "y": 53 }, { "x": 50, "y": 54 }, { "x": 50, "y": 54 }, { "x": 50, "y": 54 }, { "x": 49, "y": 54 }, { "x": 49, "y": 54 }, { "x": 49, "y": 54 }, { "x": 49, "y": 54 }, { "x": 49, "y": 55 }, { "x": 49, "y": 55 }, { "x": 49, "y": 55 }, { "x": 48, "y": 55 }, { "x": 48, "y": 55 }, { "x": 48, "y": 55 }, { "x": 47, "y": 56 }, { "x": 46, "y": 56 }, { "x": 46, "y": 56 }, { "x": 46, "y": 56 }, { "x": 46, "y": 56 } ]'

to

\set pen ''

(where should be replaced with the JSON value copied just earlier) and run it:

psql -d handwriting -f code/handwriting.sql

If everything went well, you have just found out which character you've drawn! (Ideally, it matches your intent...)

License

See LICENSE, with the following caveats:

  • Mike Bostock' D3.js, located at code/assets/d3.v4.min.js, is licensed under the BSD 3-Clause License.
  • The Iosevka font, to be found at code/assets/iosevka-regular.*, is licensed under the SIL Open Font License Version 1.1.
  • Most of the visualizations in paper/, presentation/, as well as code/assets/guide.png are based on Jack Schaedler's excellent interactive essay "Back to the Future of Handwriting Recognition", which is licensed under the MIT License.
  • The videos presentation/alankay*.mp4 of Alan Kay demoing GRAIL are taken from a talk entitled "Doing with Images Makes Symbols". As the're still under copyright protection, I'm technically engaging in freebooting by including them in this repository. However, since the talk has been available on archive.org since 2002, I'm hopeful that nobody will mind too much.
  • Similar caveats hold for paper/grailconsole.png, presentation/approach.png, presentation/decisiontree.png, the mockup used for presentation/nexus5.jpg, presentation/pglogo.png, and presentation/tablet.jpg.

handwriting's People

Contributors

doersino avatar

Watchers

James Cloos 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.