Struct tesseract_plumbing::TessBaseApi
source · pub struct TessBaseApi(_);
Expand description
Wrapper around tesseract::TessBaseAPI
Implementations§
source§impl TessBaseApi
impl TessBaseApi
pub fn create() -> Self
sourcepub fn init_2(
&mut self,
datapath: Option<&CStr>,
language: Option<&CStr>
) -> Result<(), TessBaseApiInitError>
pub fn init_2( &mut self, datapath: Option<&CStr>, language: Option<&CStr> ) -> Result<(), TessBaseApiInitError>
Wrapper for Init-2
Start tesseract
sourcepub fn init_4(
&mut self,
datapath: Option<&CStr>,
language: Option<&CStr>,
oem: TessOcrEngineMode
) -> Result<(), TessBaseApiInitError>
pub fn init_4( &mut self, datapath: Option<&CStr>, language: Option<&CStr>, oem: TessOcrEngineMode ) -> Result<(), TessBaseApiInitError>
Wrapper for Init-4
sourcepub fn set_image_2(&mut self, pix: &Pix)
pub fn set_image_2(&mut self, pix: &Pix)
Wrapper for SetImage-2
sourcepub 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>
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
sourcepub fn set_source_resolution(&mut self, ppi: c_int)
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().
sourcepub fn set_variable(
&mut self,
name: &CStr,
value: &CStr
) -> Result<(), TessBaseApiSetVariableError>
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.
sourcepub fn recognize(&mut self) -> Result<(), TessBaseApiRecogniseError>
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.
sourcepub fn get_utf8_text(&mut self) -> Result<Text, TessBaseApiGetUtf8TextError>
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.
sourcepub fn get_hocr_text(
&mut self,
page: c_int
) -> Result<Text, TessBaseApiGetHocrTextError>
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.
sourcepub fn get_input_image(&self) -> Option<BorrowedFrom<'_, Pix>>
pub fn get_input_image(&self) -> Option<BorrowedFrom<'_, Pix>>
Wrapper for TessBaseAPIGetInputImage
sourcepub fn get_source_y_resolution(&self) -> c_int
pub fn get_source_y_resolution(&self) -> c_int
Wrapper for TessBaseAPIGetSourceYResolution
sourcepub fn set_rectangle(
&mut self,
left: c_int,
top: c_int,
width: c_int,
height: c_int
)
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.
sourcepub fn get_alto_text(
&mut self,
page_number: c_int
) -> Result<Text, TessBaseApiGetAltoTextError>
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.
sourcepub fn get_tsv_text(
&mut self,
page_number: c_int
) -> Result<Text, TessBaseApiGetTsvTextError>
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.
sourcepub fn get_lstm_box_text(
&mut self,
page_number: c_int
) -> Result<Text, TessBaseApiGetLstmBoxTextError>
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.
sourcepub fn get_word_str_box_text(
&mut self,
page_number: c_int
) -> Result<Text, TessBaseApiGetWordStrBoxTextError>
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.
sourcepub fn mean_text_conf(&self) -> c_int
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.
sourcepub fn all_word_confidences(
&self
) -> Result<AllWordConfidences, TessBaseApiAllWordConfidencesError>
pub fn all_word_confidences( &self ) -> Result<AllWordConfidences, TessBaseApiAllWordConfidencesError>
Wrapper for TessBaseAPIAllWordConfidences
Returns a slice of confidences for each word in the result.
sourcepub fn get_component_images_1(
&self,
level: TessPageIteratorLevel,
text_only: c_int
) -> Result<RefCountedExclusive<Boxa>, TessBaseApiGetComponentImagesError>
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.