Created
November 6, 2016 19:44
-
-
Save nigelkerr/18e56fbb66656968dea35607d06662a6 to your computer and use it in GitHub Desktop.
js to include in a hocr file to make it easier to see the document regions recognized
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
$( document ).ready(function() { | |
var bbox_re = /bbox (\d+) (\d+) (\d+) (\d+)/i; | |
var posr = function(i) { | |
var t = $(this).attr('title'); | |
var result = t.match(bbox_re); | |
if ( result ) { | |
var top = result[2] / 3; | |
var left = result[1] / 3; | |
var bottom = result[4] / 3; | |
var right = result[3] / 3; | |
$(this).offset({top: top, left: left}); | |
$(this).outerWidth( right - left ); | |
$(this).outerHeight( bottom - top ); | |
} | |
}; | |
$('.ocr_page').each(posr); | |
$('.ocr_carea').each(posr); | |
$('.ocr_par').each(posr); | |
$('.ocr_line').each(posr); | |
$('.ocrx_word').each(posr); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment