Last active
August 25, 2017 18:40
Tesseract License Plate OCR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height: 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script async src=http://CDN.JSDelivr.net/npm/p5></script> | |
<script defer src=http://CDN.JSDelivr.net/gh/naptha/tesseract.js/dist/tesseract.min.js></script> | |
<script defer src=sketch.js></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tesseract License Plate OCR (v1.0.2) | |
* MarcoHeleno & GoToLoop (2017-Feb-23) | |
* | |
* Forum.Processing.org/two/discussion/23878/ | |
* need-help-with-sending-p5-image-to-tesseract-js#Item_2 | |
* | |
* Bl.ocks.org/GoSubRoutine/241b4070e20a13f1c3dd8f852390baa0 | |
*/ | |
"use strict"; | |
const HTTP = 'http:' + '//', | |
PROX = 'CORS-Anywhere.HerokuApp.com/', | |
SITE = 'CheesieMack.com/', | |
FOLD = 'wp/wp-content/uploads/2012/06/', | |
FILE = 'CT-872NED.jpg', | |
PATH = HTTP + PROX + SITE + FOLD + FILE, | |
LOCAL = false; | |
let img; | |
function preload() { | |
img = loadImage(LOCAL && FILE || PATH, console.info); | |
} | |
function setup() { | |
createCanvas(img.width, img.height).mousePressed(() => ocr(img.canvas)); | |
background(img); | |
} | |
function ocr(imageLike) { | |
Tesseract.recognize(imageLike).progress(print).then(logFoundWords); | |
} | |
function logFoundWords(json) { | |
console.table(json.lines); | |
print(json); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment