OCRTesseract 类提供了一个与 C++ 中的 tesseract-ocr API (v3.02.02) 的接口。 更多...
#include <opencv2/text/ocr.hpp>
|
| String | run (InputArray image, InputArray mask, int min_confidence, int component_level=0) |
| |
| String | run (InputArray image, int min_confidence, int component_level=0) |
| |
| virtual void | run (Mat &image, Mat &mask, std::string &output_text, std::vector< Rect > *component_rects=NULL, std::vector< std::string > *component_texts=NULL, std::vector< float > *component_confidences=NULL, int component_level=0) CV_OVERRIDE |
| |
| virtual void | run (Mat &image, std::string &output_text, std::vector< Rect > *component_rects=NULL, std::vector< std::string > *component_texts=NULL, std::vector< float > *component_confidences=NULL, int component_level=0) CV_OVERRIDE |
| | 使用 tesseract-ocr API 识别文本。
|
| |
| virtual void | setWhiteList (const String &char_whitelist)=0 |
| |
| virtual | ~BaseOCR () |
| |
OCRTesseract 类提供了一个与 C++ 中的 tesseract-ocr API (v3.02.02) 的接口。
请注意,只有在正确安装 tesseract-ocr 时才会编译它。
- 注意
-
◆ create()
| static Ptr< OCRTesseract > cv::text::OCRTesseract::create |
( |
const char * | datapath = NULL, |
|
|
const char * | language = NULL, |
|
|
const char * | char_whitelist = NULL, |
|
|
int | oem = OEM_DEFAULT, |
|
|
int | psmode = PSM_AUTO ) |
|
static |
| Python |
|---|
| cv.text.OCRTesseract.create( | [, datapath[, language[, char_whitelist[, oem[, psmode]]]]] | ) -> | retval |
| cv.text.OCRTesseract_create( | [, datapath[, language[, char_whitelist[, oem[, psmode]]]]] | ) -> | retval |
创建 OCRTesseract 类的实例。 初始化 Tesseract。
- 参数
-
| datapath | tessdata 父目录的名称,以 "/" 结尾,或 NULL 以使用系统的默认目录。 |
| language | ISO 639-3 代码,或 NULL 将默认为“eng”。 |
| char_whitelist | 指定用于识别的字符列表。 NULL 默认为 ""(所有字符都将用于识别)。 |
| oem | tesseract-ocr 提供不同的 OCR 引擎模式 (OEM),默认情况下使用 tesseract::OEM_DEFAULT。 有关其他可能的值,请参阅 tesseract-ocr API 文档。 |
| psmode | tesseract-ocr 提供不同的页面分割模式 (PSM),使用 tesseract::PSM_AUTO(完全自动布局分析)。 有关其他可能的值,请参阅 tesseract-ocr API 文档。 |
- 注意
- 在 OpenCV 4.7.0/3.19.0 之后,char_whitelist 默认值从 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 更改为 ""。
◆ run() [1/4]
| Python |
|---|
| cv.text.OCRTesseract.run( | image, min_confidence[, component_level] | ) -> | retval |
| cv.text.OCRTesseract.run( | image, mask, min_confidence[, component_level] | ) -> | retval |
◆ run() [2/4]
| String cv::text::OCRTesseract::run |
( |
InputArray | image, |
|
|
int | min_confidence, |
|
|
int | component_level = 0 ) |
| Python |
|---|
| cv.text.OCRTesseract.run( | image, min_confidence[, component_level] | ) -> | retval |
| cv.text.OCRTesseract.run( | image, mask, min_confidence[, component_level] | ) -> | retval |
◆ run() [3/4]
| virtual void cv::text::OCRTesseract::run |
( |
Mat & | image, |
|
|
Mat & | mask, |
|
|
std::string & | output_text, |
|
|
std::vector< Rect > * | component_rects = NULL, |
|
|
std::vector< std::string > * | component_texts = NULL, |
|
|
std::vector< float > * | component_confidences = NULL, |
|
|
int | component_level = 0 ) |
|
virtual |
| Python |
|---|
| cv.text.OCRTesseract.run( | image, min_confidence[, component_level] | ) -> | retval |
| cv.text.OCRTesseract.run( | image, mask, min_confidence[, component_level] | ) -> | retval |
◆ run() [4/4]
| virtual void cv::text::OCRTesseract::run |
( |
Mat & | image, |
|
|
std::string & | output_text, |
|
|
std::vector< Rect > * | component_rects = NULL, |
|
|
std::vector< std::string > * | component_texts = NULL, |
|
|
std::vector< float > * | component_confidences = NULL, |
|
|
int | component_level = 0 ) |
|
virtual |
| Python |
|---|
| cv.text.OCRTesseract.run( | image, min_confidence[, component_level] | ) -> | retval |
| cv.text.OCRTesseract.run( | image, mask, min_confidence[, component_level] | ) -> | retval |
使用 tesseract-ocr API 识别文本。
在输入时获取图像,并在 output_text 参数中返回识别的文本。 可选地还提供找到的各个文本元素的矩形(例如单词),以及这些文本元素及其置信度值的列表。
- 参数
-
| image | 输入图像 CV_8UC1 或 CV_8UC3 |
| output_text | tesseract-ocr 的输出文本。 |
| component_rects | 如果提供,该方法将输出找到的各个文本元素(例如单词或文本行)的矩形列表。 |
| component_texts | 如果提供,该方法将输出各个文本元素识别的文本字符串列表(例如单词或文本行)。 |
| component_confidences | 如果提供,该方法将输出找到的各个文本元素的置信度值列表(例如单词或文本行)。 |
| component_level | OCR_LEVEL_WORD(默认),或 OCR_LEVEL_TEXTLINE。 |
实现 cv::text::BaseOCR。
◆ setWhiteList()
| virtual void cv::text::OCRTesseract::setWhiteList |
( |
const String & | char_whitelist | ) |
|
|
纯虚函数 |
| Python |
|---|
| cv.text.OCRTesseract.setWhiteList( | char_whitelist | ) -> | 无 |
此类文档是从以下文件生成的