Struct opencv::text::OCRTesseract
source · pub struct OCRTesseract { /* private fields */ }
Expand description
OCRTesseract class provides an interface with the tesseract-ocr API (v3.02.02) in C++.
Notice that it is compiled only when tesseract-ocr is correctly installed.
Note:
- (C++) An example of OCRTesseract recognition combined with scene text detection can be found at the end_to_end_recognition demo: https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/end_to_end_recognition.cpp
- (C++) Another example of OCRTesseract recognition combined with scene text detection can be found at the webcam_demo: https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/webcam_demo.cpp
Implementations§
source§impl OCRTesseract
impl OCRTesseract
sourcepub fn create(
datapath: &str,
language: &str,
char_whitelist: &str,
oem: i32,
psmode: i32
) -> Result<Ptr<OCRTesseract>>
pub fn create( datapath: &str, language: &str, char_whitelist: &str, oem: i32, psmode: i32 ) -> Result<Ptr<OCRTesseract>>
Creates an instance of the OCRTesseract class. Initializes Tesseract.
Parameters
- datapath: the name of the parent directory of tessdata ended with “/”, or NULL to use the system’s default directory.
- language: an ISO 639-3 code or NULL will default to “eng”.
- char_whitelist: specifies the list of characters used for recognition. NULL defaults to “” (All characters will be used for recognition).
- oem: tesseract-ocr offers different OCR Engine Modes (OEM), by default tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible values.
- psmode: tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO (fully automatic layout analysis) is used. See the tesseract-ocr API documentation for other possible values.
Note: The char_whitelist default is changed after OpenCV 4.7.0/3.19.0 from “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ” to “”.
C++ default parameters
- datapath: NULL
- language: NULL
- char_whitelist: NULL
- oem: OEM_DEFAULT
- psmode: PSM_AUTO
sourcepub fn create_def() -> Result<Ptr<OCRTesseract>>
pub fn create_def() -> Result<Ptr<OCRTesseract>>
Creates an instance of the OCRTesseract class. Initializes Tesseract.
Parameters
- datapath: the name of the parent directory of tessdata ended with “/”, or NULL to use the system’s default directory.
- language: an ISO 639-3 code or NULL will default to “eng”.
- char_whitelist: specifies the list of characters used for recognition. NULL defaults to “” (All characters will be used for recognition).
- oem: tesseract-ocr offers different OCR Engine Modes (OEM), by default tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible values.
- psmode: tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO (fully automatic layout analysis) is used. See the tesseract-ocr API documentation for other possible values.
Note: The char_whitelist default is changed after OpenCV 4.7.0/3.19.0 from “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ” to “”.
Note
This alternative version of OCRTesseract::create function uses the following default values for its arguments:
- datapath: NULL
- language: NULL
- char_whitelist: NULL
- oem: OEM_DEFAULT
- psmode: PSM_AUTO
Trait Implementations§
source§impl BaseOCRTrait for OCRTesseract
impl BaseOCRTrait for OCRTesseract
fn as_raw_mut_BaseOCR(&mut self) -> *mut c_void
source§fn run(
&mut self,
image: &mut Mat,
output_text: &mut String,
component_rects: &mut Vector<Rect>,
component_texts: &mut Vector<String>,
component_confidences: &mut Vector<f32>,
component_level: i32
) -> Result<()>
fn run( &mut self, image: &mut Mat, output_text: &mut String, component_rects: &mut Vector<Rect>, component_texts: &mut Vector<String>, component_confidences: &mut Vector<f32>, component_level: i32 ) -> Result<()>
C++ default parameters Read more
source§impl BaseOCRTraitConst for OCRTesseract
impl BaseOCRTraitConst for OCRTesseract
fn as_raw_BaseOCR(&self) -> *const c_void
source§impl Boxed for OCRTesseract
impl Boxed for OCRTesseract
source§impl Debug for OCRTesseract
impl Debug for OCRTesseract
source§impl Drop for OCRTesseract
impl Drop for OCRTesseract
source§impl From<OCRTesseract> for BaseOCR
impl From<OCRTesseract> for BaseOCR
source§fn from(s: OCRTesseract) -> Self
fn from(s: OCRTesseract) -> Self
Converts to this type from the input type.
source§impl OCRTesseractTrait for OCRTesseract
impl OCRTesseractTrait for OCRTesseract
fn as_raw_mut_OCRTesseract(&mut self) -> *mut c_void
source§fn run_multiple(
&mut self,
image: &mut Mat,
output_text: &mut String,
component_rects: &mut Vector<Rect>,
component_texts: &mut Vector<String>,
component_confidences: &mut Vector<f32>,
component_level: i32
) -> Result<()>
fn run_multiple( &mut self, image: &mut Mat, output_text: &mut String, component_rects: &mut Vector<Rect>, component_texts: &mut Vector<String>, component_confidences: &mut Vector<f32>, component_level: i32 ) -> Result<()>
Recognize text using the tesseract-ocr API. Read more
source§fn run_multiple_def(
&mut self,
image: &mut Mat,
output_text: &mut String
) -> Result<()>
fn run_multiple_def( &mut self, image: &mut Mat, output_text: &mut String ) -> Result<()>
Recognize text using the tesseract-ocr API. Read more
source§fn run_multiple_mask(
&mut self,
image: &mut Mat,
mask: &mut Mat,
output_text: &mut String,
component_rects: &mut Vector<Rect>,
component_texts: &mut Vector<String>,
component_confidences: &mut Vector<f32>,
component_level: i32
) -> Result<()>
fn run_multiple_mask( &mut self, image: &mut Mat, mask: &mut Mat, output_text: &mut String, component_rects: &mut Vector<Rect>, component_texts: &mut Vector<String>, component_confidences: &mut Vector<f32>, component_level: i32 ) -> Result<()>
C++ default parameters Read more
source§fn run_multiple_mask_def(
&mut self,
image: &mut Mat,
mask: &mut Mat,
output_text: &mut String
) -> Result<()>
fn run_multiple_mask_def( &mut self, image: &mut Mat, mask: &mut Mat, output_text: &mut String ) -> Result<()>
Note Read more
source§fn run(
&mut self,
image: &impl ToInputArray,
min_confidence: i32,
component_level: i32
) -> Result<String>
fn run( &mut self, image: &impl ToInputArray, min_confidence: i32, component_level: i32 ) -> Result<String>
C++ default parameters Read more
source§fn run_def(
&mut self,
image: &impl ToInputArray,
min_confidence: i32
) -> Result<String>
fn run_def( &mut self, image: &impl ToInputArray, min_confidence: i32 ) -> Result<String>
Note Read more
source§fn run_mask(
&mut self,
image: &impl ToInputArray,
mask: &impl ToInputArray,
min_confidence: i32,
component_level: i32
) -> Result<String>
fn run_mask( &mut self, image: &impl ToInputArray, mask: &impl ToInputArray, min_confidence: i32, component_level: i32 ) -> Result<String>
C++ default parameters Read more
source§fn run_mask_def(
&mut self,
image: &impl ToInputArray,
mask: &impl ToInputArray,
min_confidence: i32
) -> Result<String>
fn run_mask_def( &mut self, image: &impl ToInputArray, mask: &impl ToInputArray, min_confidence: i32 ) -> Result<String>
Note Read more
fn set_white_list(&mut self, char_whitelist: &str) -> Result<()>
source§impl OCRTesseractTraitConst for OCRTesseract
impl OCRTesseractTraitConst for OCRTesseract
fn as_raw_OCRTesseract(&self) -> *const c_void
source§impl TryFrom<BaseOCR> for OCRTesseract
impl TryFrom<BaseOCR> for OCRTesseract
impl Send for OCRTesseract
Auto Trait Implementations§
impl RefUnwindSafe for OCRTesseract
impl !Sync for OCRTesseract
impl Unpin for OCRTesseract
impl UnwindSafe for OCRTesseract
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more