feat: 修改Tesseract三方库定义方式

Description:   优化三方库不能在application后实例化

Log: 修改识别接口
Change-Id: Ia36d0b9c9e43fab1d1a637728f0dbabccff3679e
This commit is contained in:
wangcong 2021-06-15 15:21:36 +08:00
parent e73c254cb8
commit a7326a4165
2 changed files with 8 additions and 4 deletions

View File

@ -49,6 +49,12 @@ const QString TESSDATA_PATH = "/usr/share/deepin-ocr/tesslangs";
*/
TessOcrUtils *TessOcrUtils::m_tessOcrUtils = nullptr;
/**
* @brief TessOcrUtils::t_Tesseract
*/
tesseract::TessBaseAPI *TessOcrUtils::t_Tesseract = new tesseract::TessBaseAPI();
TessOcrUtils::TessOcrUtils()
{
@ -226,10 +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{
//实例化tesseract
t_Tesseract = new tesseract::TessBaseAPI();
//初始化语言包
if (t_Tesseract->Init(m_sTessdataPath.toLatin1().data(), m_sLangs.toLatin1().data()))
{
@ -267,7 +270,6 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
return t_result;
}
t_Tesseract->End();
delete t_Tesseract;
pixDestroy(&image);
t_result.flag = true;
t_result.message = errorMessage;

View File

@ -244,6 +244,8 @@ private :
static TessOcrUtils *m_tessOcrUtils;
static tesseract::TessBaseAPI *t_Tesseract;
};
#endif // TESSOCRUTILS_H