pub struct TessBaseApi(_);
Expand description

Wrapper around tesseract::TessBaseAPI

Implementations§

source§

impl TessBaseApi

source

pub fn create() -> Self

source

pub fn init_2( &mut self, datapath: Option<&CStr>, language: Option<&CStr> ) -> Result<(), TessBaseApiInitError>

Wrapper for Init-2

Start tesseract

source

pub fn init_4( &mut self, datapath: Option<&CStr>, language: Option<&CStr>, oem: TessOcrEngineMode ) -> Result<(), TessBaseApiInitError>

Wrapper for Init-4

source

pub fn set_image_2(&mut self, pix: &Pix)

Wrapper for SetImage-2

source

pub fn set_image( &mut self, image_data: &[u8], width: c_int, height: c_int, bytes_per_pixel: c_int, bytes_per_line: c_int ) -> Result<(), TessBaseApiSetImageSafetyError>

Wrapper for SetImage-1

source

pub fn set_source_resolution(&mut self, ppi: c_int)

Wrapper for SetSourceResolution

Set the resolution of the source image in pixels per inch so font size information can be calculated in results. Call this after SetImage().

source

pub fn set_variable( &mut self, name: &CStr, value: &CStr ) -> Result<(), TessBaseApiSetVariableError>

Wrapper for SetVariable

Warning! Everytime you use a name that isn’t recognized by Tesseract, a few bytes of memory are leaked.

source

pub fn recognize(&mut self) -> Result<(), TessBaseApiRecogniseError>

Wrapper for Recognize

Recognize the image. Returns Ok(()) on success and Err(()) otherwise. It is currently unclear to me what would make it error.

It could take a progress argument (monitor). If there is appetite for this, let me know and I could try and implement it.

source

pub fn get_utf8_text(&mut self) -> Result<Text, TessBaseApiGetUtf8TextError>

Wrapper for GetUTF8Text

Get the text out of an image.

Can return an error (null pointer), but it is not clear to me what would cause this.

This will implicitly call recognize if required.

source

pub fn get_hocr_text( &mut self, page: c_int ) -> Result<Text, TessBaseApiGetHocrTextError>

Wrapper for GetUTF8Text

Get the text out of an image.

Can return an error (null pointer), but it is not clear to me what would cause this.

This will implicitly call recognize if required.

source

pub fn get_input_image(&self) -> Option<BorrowedFrom<'_, Pix>>

source

pub fn get_source_y_resolution(&self) -> c_int

source

pub fn set_rectangle( &mut self, left: c_int, top: c_int, width: c_int, height: c_int )

Wrapper for TessBaseAPISetRectangle

Restrict recognition to a sub-rectangle of the image. Call after SetImage. Each SetRectangle clears the recogntion results so multiple rectangles can be recognized with the same image.

source

pub fn get_alto_text( &mut self, page_number: c_int ) -> Result<Text, TessBaseApiGetAltoTextError>

Wrapper for TessBaseAPIGetAltoText

Make an XML-formatted string with Alto markup from the internal data structures.

source

pub fn get_tsv_text( &mut self, page_number: c_int ) -> Result<Text, TessBaseApiGetTsvTextError>

Wrapper for TessBaseAPIGetTsvText

Make a TSV-formatted string from the internal data structures. page_number is 0-based but will appear in the output as 1-based.

source

pub fn get_lstm_box_text( &mut self, page_number: c_int ) -> Result<Text, TessBaseApiGetLstmBoxTextError>

Wrapper for TessBaseAPIGetLSTMBoxText

Make a box file for LSTM training from the internal data structures. Constructs coordinates in the original image - not just the rectangle. page_number is a 0-based page index that will appear in the box file.

source

pub fn get_word_str_box_text( &mut self, page_number: c_int ) -> Result<Text, TessBaseApiGetWordStrBoxTextError>

Wrapper for TessBaseAPIGetWordStrBoxText

The recognized text is returned as a char* which is coded in the same format as a WordStr box file used in training. page_number is a 0-based page index that will appear in the box file. Returned string must be freed with the delete [] operator.

Create a UTF8 box file with WordStr strings from the internal data structures. page_number is a 0-base page index that will appear in the box file.

source

pub fn mean_text_conf(&self) -> c_int

Wrapper for TessBaseAPIMeanTextConf

Returns the (average) confidence value between 0 and 100.

Returns the average word confidence for Tesseract page result.

source

pub fn all_word_confidences( &self ) -> Result<AllWordConfidences, TessBaseApiAllWordConfidencesError>

Wrapper for TessBaseAPIAllWordConfidences

Returns a slice of confidences for each word in the result.

source

pub fn get_component_images_1( &self, level: TessPageIteratorLevel, text_only: c_int ) -> Result<RefCountedExclusive<Boxa>, TessBaseApiGetComponentImagesError>

Wrapper for GetComponentImages 1/2

Get the given level kind of components (block, textline, word etc.) as a leptonica-style Boxa, Pixa pair, in reading order.

Trait Implementations§

source§

impl Debug for TessBaseApi

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TessBaseApi

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for TessBaseApi

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for TessBaseApi

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.