[−][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()); }
Implementations
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: impl AsRef<Path>) -> Result<(), PixError>
[src]
Set image to use for OCR.
pub fn set_image_from_mem(&mut self, img: &[u8]) -> Result<(), PixError>
[src]
pub fn get_source_y_resolution(&mut self) -> i32
[src]
pub fn get_image_dimensions(&self) -> Option<(u32, u32)>
[src]
pub fn set_source_resolution(&mut self, res: i32)
[src]
Override image resolution. Can be used to suppress "Warning: Invalid resolution 0 dpi." output.
pub fn set_fallback_source_resolution(&mut self, res: i32)
[src]
Override image resolution if not detected
pub fn recognize(&self) -> i32
[src]
pub fn set_rectangle(&mut self, 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 RefUnwindSafe for LepTess
impl !Send for LepTess
impl !Sync for LepTess
impl Unpin for LepTess
impl UnwindSafe for LepTess
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
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>,