parent
26b865537d
commit
0d2b8b41c6
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,99 @@
|
||||
DejaVu Fonts License
|
||||
|
||||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
|
||||
|
||||
Bitstream Vera Fonts Copyright
|
||||
———————————————
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
|
||||
a trademark of Bitstream, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of the fonts accompanying this license (“Fonts”) and associated
|
||||
documentation files (the “Font Software”), to reproduce and distribute the
|
||||
Font Software, including without limitation the rights to use, copy, merge,
|
||||
publish, distribute, and/or sell copies of the Font Software, and to permit
|
||||
persons to whom the Font Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice shall
|
||||
be included in all copies of one or more of the Font Software typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in particular
|
||||
the designs of glyphs or characters in the Fonts may be modified and
|
||||
additional glyphs or characters may be added to the Fonts, only if the fonts
|
||||
are renamed to names not containing either the words “Bitstream” or the word
|
||||
“Vera”.
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts or Font
|
||||
Software that has been modified and is distributed under the “Bitstream
|
||||
Vera” names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but no
|
||||
copy of one or more of the Font Software typefaces may be sold by itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
|
||||
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
|
||||
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
|
||||
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
|
||||
FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the names of Gnome, the Gnome
|
||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
||||
otherwise to promote the sale, use or other dealings in this Font Software
|
||||
without prior written authorization from the Gnome Foundation or Bitstream
|
||||
Inc., respectively. For further information, contact: fonts at gnome dot
|
||||
org.
|
||||
|
||||
Arev Fonts Copyright
|
||||
———————————————
|
||||
|
||||
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the fonts accompanying this license (“Fonts”) and
|
||||
associated documentation files (the “Font Software”), to reproduce
|
||||
and distribute the modifications to the Bitstream Vera Font Software,
|
||||
including without limitation the rights to use, copy, merge, publish,
|
||||
distribute, and/or sell copies of the Font Software, and to permit
|
||||
persons to whom the Font Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice
|
||||
shall be included in all copies of one or more of the Font Software
|
||||
typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in
|
||||
particular the designs of glyphs or characters in the Fonts may be
|
||||
modified and additional glyphs or characters may be added to the
|
||||
Fonts, only if the fonts are renamed to names not containing either
|
||||
the words “Tavmjong Bah” or the word “Arev”.
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts
|
||||
or Font Software that has been modified and is distributed under the
|
||||
“Tavmjong Bah Arev” names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but
|
||||
no copy of one or more of the Font Software typefaces may be sold by
|
||||
itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
||||
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Tavmjong Bah shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other
|
||||
dealings in this Font Software without prior written authorization
|
||||
from Tavmjong Bah. For further information, contact: tavmjong @ free
|
||||
. fr.
|
After Width: | Height: | Size: 27 KiB |
@ -0,0 +1 @@
|
||||
[{"id":0,"hint":"H At\n","confidence":67,"width":53,"height":23,"x":189,"y":38},{"id":1,"hint":"Adcdaer\n","confidence":25,"width":92,"height":22,"x":251,"y":39},{"id":2,"hint":"A\nR\n","confidence":96,"width":21,"height":52,"x":28,"y":107},{"id":3,"hint":"S\n","confidence":95,"width":16,"height":22,"x":437,"y":124},{"id":4,"hint":"(sum)\n","confidence":87,"width":73,"height":22,"x":486,"y":127},{"id":5,"hint":"—p\n","confidence":29,"width":73,"height":22,"x":381,"y":232},{"id":6,"hint":"(carry\n","confidence":87,"width":99,"height":24,"x":486,"y":235},{"id":7,"hint":"out)\n","confidence":89,"width":61,"height":22,"x":605,"y":235}]
|
@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"id": 0,
|
||||
"hint": "Half Adder",
|
||||
"confidence": 100,
|
||||
"width": 170,
|
||||
"height": 23,
|
||||
"x": 189,
|
||||
"y": 38
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"hint": "A",
|
||||
"confidence": 96,
|
||||
"width": 21,
|
||||
"height": 25,
|
||||
"x": 28,
|
||||
"y": 107
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"hint": "B",
|
||||
"confidence": 96,
|
||||
"width": 21,
|
||||
"height": 25,
|
||||
"x": 28,
|
||||
"y": 137
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"hint": "S (sum)",
|
||||
"confidence": 95,
|
||||
"width": 150,
|
||||
"height": 26,
|
||||
"x": 437,
|
||||
"y": 124
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"hint": "C (carry out)",
|
||||
"confidence": 29,
|
||||
"width": 240,
|
||||
"height": 30,
|
||||
"x": 431,
|
||||
"y": 230
|
||||
}
|
||||
]
|
@ -0,0 +1,45 @@
|
||||
use std::fs;
|
||||
use ocr_json_common::TextBox;
|
||||
use image::{Rgba};
|
||||
use imageproc::drawing::{
|
||||
draw_hollow_rect_mut,
|
||||
draw_text_mut,
|
||||
};
|
||||
use imageproc::rect::Rect;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use rusttype::{Font, Scale};
|
||||
|
||||
fn main() {
|
||||
let img_file_name = if env::args().count() >= 2 {
|
||||
env::args().nth(1).unwrap()
|
||||
} else {
|
||||
panic!("Please enter a target file path for image")
|
||||
};
|
||||
let json_file_name = if env::args().count() >= 3 {
|
||||
env::args().nth(2).unwrap()
|
||||
} else{
|
||||
panic!("Please enter a target file path for json")
|
||||
};
|
||||
let json = fs::read_to_string(json_file_name).expect("There was an error reading the file.");
|
||||
let ocr_rects: Vec<TextBox> = serde_json::from_str(&json).unwrap();
|
||||
let image_path = Path::new(&img_file_name);
|
||||
let red = Rgba([255u8, 0u8, 0u8, 255u8]);
|
||||
|
||||
let font_data: &[u8] = include_bytes!("../fonts/UBraille.ttf");
|
||||
let font: Font<'static> = Font::try_from_bytes(font_data).expect("Error loading font.");
|
||||
|
||||
let mut img = image::open(image_path).unwrap();
|
||||
|
||||
// run OCR on each word bounding box
|
||||
for rect in &ocr_rects {
|
||||
draw_hollow_rect_mut(&mut img, Rect::at(rect.x, rect.y).of_size(rect.width, rect.height), red);
|
||||
let y: u32 = (rect.y-25) as u32;
|
||||
let x: u32 = (rect.x-25) as u32;
|
||||
//let text = format!("{}", rect.id).as_str();
|
||||
let text = "⠨⠙⠕⠃⠗⠕⠙⠕⠱⠇⠊";
|
||||
draw_text_mut(&mut img, red, x, y, Scale::uniform(20.0), &font, text);
|
||||
}
|
||||
|
||||
img.save("out.png").unwrap();
|
||||
}
|
Loading…
Reference in new issue