OpenCV 4.12.0
开源计算机视觉
加载中...
搜索中...
无匹配项
cv::text::OCRTesseract 类参考abstract

OCRTesseract 类提供了一个与 C++ 中的 tesseract-ocr API (v3.02.02) 的接口。 更多...

#include <opencv2/text/ocr.hpp>

cv::text::OCRTesseract 的协作图

公共成员函数

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
 
- 从 cv::text::BaseOCR 继承的公共成员函数
virtual ~BaseOCR ()
 

静态公共成员函数

static Ptr< OCRTesseractcreate (const char *datapath=NULL, const char *language=NULL, const char *char_whitelist=NULL, int oem=OEM_DEFAULT, int psmode=PSM_AUTO)
 创建 OCRTesseract 类的实例。 初始化 Tesseract。
 

详细描述

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。

参数
datapathtessdata 父目录的名称,以 "/" 结尾,或 NULL 以使用系统的默认目录。
languageISO 639-3 代码,或 NULL 将默认为“eng”。
char_whitelist指定用于识别的字符列表。 NULL 默认为 ""(所有字符都将用于识别)。
oemtesseract-ocr 提供不同的 OCR 引擎模式 (OEM),默认情况下使用 tesseract::OEM_DEFAULT。 有关其他可能的值,请参阅 tesseract-ocr API 文档。
psmodetesseract-ocr 提供不同的页面分割模式 (PSM),使用 tesseract::PSM_AUTO(完全自动布局分析)。 有关其他可能的值,请参阅 tesseract-ocr API 文档。
注意
在 OpenCV 4.7.0/3.19.0 之后,char_whitelist 默认值从 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 更改为 ""。

◆ run() [1/4]

String cv::text::OCRTesseract::run ( InputArray image,
InputArray mask,
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() [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

实现 cv::text::BaseOCR

◆ 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_texttesseract-ocr 的输出文本。
component_rects如果提供,该方法将输出找到的各个文本元素(例如单词或文本行)的矩形列表。
component_texts如果提供,该方法将输出各个文本元素识别的文本字符串列表(例如单词或文本行)。
component_confidences如果提供,该方法将输出找到的各个文本元素的置信度值列表(例如单词或文本行)。
component_levelOCR_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) ->

此类文档是从以下文件生成的