Skip to content

Instantly share code, notes, and snippets.

@nigelkerr
Created November 6, 2016 19:44
Show Gist options
  • Save nigelkerr/18e56fbb66656968dea35607d06662a6 to your computer and use it in GitHub Desktop.
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
$( 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