[−][src]Struct leptess::LepTess
High level wrapper for Tesseract and Leptonica
Examples
Full page OCR
let mut lt = leptess::LepTess::new(Some("./tests/tessdata"), "eng").unwrap(); lt.set_image("./tests/di.png"); println!("{}", lt.get_utf8_text().unwrap());
OCR on a specific region of the image
lt.set_rectangle(&leptess::leptonica::Box::new( 10, 10, 200, 60, ).unwrap()); println!("{}", lt.get_utf8_text().unwrap());
Iterate bounding boxes for each recognized word
let boxes = lt.get_component_boxes( leptess::capi::TessPageIteratorLevel_RIL_WORD, true, ).unwrap(); for b in &boxes { println!("{:?}", b.get_val()); }
Methods
impl LepTess
[src]
pub fn new(
data_path: Option<&str>,
lang: &str
) -> Result<LepTess, TessInitError>
[src]
data_path: Option<&str>,
lang: &str
) -> Result<LepTess, TessInitError>
pub fn set_image(&mut self, img_uri: &str) -> bool
[src]
Set image to use for OCR.
pub fn recognize(&self) -> i32
[src]
pub fn set_rectangle<'a, 'b>(&'a mut self, b: &'b Box)
[src]
Restrict OCR to a specific region of the image.
pub fn get_utf8_text(&self) -> Result<String, Utf8Error>
[src]
Extract text from current selected region of the image. By default, it is the full page. But it can be changed through set_rectangle api.
Example
let mut lt = leptess::LepTess::new(None, "eng").unwrap(); lt.set_image("./tests/di.png"); println!("{}", lt.get_utf8_text().unwrap());
pub fn mean_text_conf(&self) -> i32
[src]
pub fn get_regions(&self) -> Option<Boxa>
[src]
pub fn get_component_boxes(
&self,
level: TessPageIteratorLevel,
text_only: bool
) -> Option<Boxa>
[src]
&self,
level: TessPageIteratorLevel,
text_only: bool
) -> Option<Boxa>
Get the given level kind of components (block, textline, word etc.) as a leptonica-style Boxa, in reading order.If text_only is true, then only text components are returned.
Example
Get word bounding boxes
let mut lt = leptess::LepTess::new(None, "eng").unwrap(); lt.set_image("./tests/di.png"); let boxes = lt.get_component_boxes( leptess::capi::TessPageIteratorLevel_RIL_WORD, true, ).unwrap(); for b in &boxes { println!("{:?}", b.get_val()); }
Auto Trait Implementations
impl !Send for LepTess
impl Unpin for LepTess
impl !Sync for LepTess
impl UnwindSafe for LepTess
impl RefUnwindSafe for LepTess
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,