feat: 集成Tesseract源码到项目中
Description: 由于仓库中的Tesseract不是最新版本导致产生了一个bug,因此将Tesseract源码集成到项目中 Log: no Change-Id: I088de95d6c6ab670406daa8d47ed2ed46929c2c0
This commit is contained in:
@ -52,7 +52,7 @@ TessOcrUtils *TessOcrUtils::m_tessOcrUtils = nullptr;
|
||||
/**
|
||||
* @brief TessOcrUtils::t_Tesseract 三方库实例化
|
||||
*/
|
||||
tesseract::TessBaseAPI *TessOcrUtils::t_Tesseract = new tesseract::TessBaseAPI();
|
||||
//tesseract::TessBaseAPI *TessOcrUtils::t_Tesseract = new tesseract::TessBaseAPI();
|
||||
|
||||
|
||||
TessOcrUtils::TessOcrUtils()
|
||||
@ -78,7 +78,7 @@ TessOcrUtils *TessOcrUtils::instance()
|
||||
return m_tessOcrUtils;
|
||||
}
|
||||
//传入待识别图片的路径和想得到的返回结果类型,获取识别结果
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(const QString imagePath,const ResultType resultType)
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath,const ResultType &resultType)
|
||||
{
|
||||
QString errorMessage = "";
|
||||
ErrorCode errorCode = ErrorCode::UNKNOWN;
|
||||
@ -123,13 +123,13 @@ RecognitionResult TessOcrUtils::getRecogitionResult(const QString imagePath,cons
|
||||
}
|
||||
|
||||
//传入待识别图片的路径,获取纯字符串的识别结果
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(const QString imagePath)
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath)
|
||||
{
|
||||
return getRecogitionResult(imagePath,ResultType::RESULT_STRING);
|
||||
}
|
||||
|
||||
//传入待识别图片和想得到的返回结果类型,获取识别结果
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(QImage *image, const ResultType resultType)
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(QImage *image, const ResultType &resultType)
|
||||
{
|
||||
QString errorMessage = "";
|
||||
ErrorCode errorCode = ErrorCode::UNKNOWN;
|
||||
@ -232,6 +232,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
return t_result;
|
||||
}
|
||||
tesseract::TessBaseAPI *t_Tesseract = new tesseract::TessBaseAPI();
|
||||
try{
|
||||
//初始化语言包
|
||||
if (t_Tesseract->Init(m_sTessdataPath.toLatin1().data(), m_sLangs.toLatin1().data()))
|
||||
|
@ -142,14 +142,14 @@ public:
|
||||
* @param 返回的字符串结果类型
|
||||
* @return resultType类型的字符串结果
|
||||
*/
|
||||
RecognitionResult getRecogitionResult(const QString imagePath,const ResultType resultType);
|
||||
RecognitionResult getRecogitionResult(const QString &imagePath,const ResultType &resultType);
|
||||
|
||||
/**
|
||||
* @brief 传入待识别图片的路径,获取纯字符串的识别结果
|
||||
* @param 图片路径
|
||||
* @return 识别的字符串结果
|
||||
*/
|
||||
RecognitionResult getRecogitionResult(const QString imagePath);
|
||||
RecognitionResult getRecogitionResult(const QString &imagePath);
|
||||
|
||||
/**
|
||||
* @brief 传入待识别图片和想得到的返回结果类型,获取识别结果
|
||||
@ -157,7 +157,7 @@ public:
|
||||
* @param 返回的字符串结果类型
|
||||
* @return resultType类型的字符串结果
|
||||
*/
|
||||
RecognitionResult getRecogitionResult(QImage *image,const ResultType resultType);
|
||||
RecognitionResult getRecogitionResult(QImage *image,const ResultType &resultType);
|
||||
|
||||
/**
|
||||
* @brief 传入待识别图片,获取纯字符串的识别结果
|
||||
@ -244,7 +244,7 @@ private :
|
||||
|
||||
static TessOcrUtils *m_tessOcrUtils;
|
||||
|
||||
static tesseract::TessBaseAPI *t_Tesseract;
|
||||
// static tesseract::TessBaseAPI *t_Tesseract;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user