feat: 修改Tesseract三方库定义方式
Description: 优化三方库不能在application后实例化 Log: 修改识别接口 Change-Id: Ia36d0b9c9e43fab1d1a637728f0dbabccff3679e
This commit is contained in:
parent
e73c254cb8
commit
a7326a4165
|
@ -49,6 +49,12 @@ const QString TESSDATA_PATH = "/usr/share/deepin-ocr/tesslangs";
|
||||||
*/
|
*/
|
||||||
TessOcrUtils *TessOcrUtils::m_tessOcrUtils = nullptr;
|
TessOcrUtils *TessOcrUtils::m_tessOcrUtils = nullptr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TessOcrUtils::t_Tesseract 三方库实例化
|
||||||
|
*/
|
||||||
|
tesseract::TessBaseAPI *TessOcrUtils::t_Tesseract = new tesseract::TessBaseAPI();
|
||||||
|
|
||||||
|
|
||||||
TessOcrUtils::TessOcrUtils()
|
TessOcrUtils::TessOcrUtils()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -226,10 +232,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
||||||
setResult(errorCode,errorMessage,resultType,t_result);
|
setResult(errorCode,errorMessage,resultType,t_result);
|
||||||
return t_result;
|
return t_result;
|
||||||
}
|
}
|
||||||
tesseract::TessBaseAPI *t_Tesseract = new tesseract::TessBaseAPI();
|
|
||||||
try{
|
try{
|
||||||
//实例化tesseract
|
|
||||||
t_Tesseract = new tesseract::TessBaseAPI();
|
|
||||||
//初始化语言包
|
//初始化语言包
|
||||||
if (t_Tesseract->Init(m_sTessdataPath.toLatin1().data(), m_sLangs.toLatin1().data()))
|
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;
|
return t_result;
|
||||||
}
|
}
|
||||||
t_Tesseract->End();
|
t_Tesseract->End();
|
||||||
delete t_Tesseract;
|
|
||||||
pixDestroy(&image);
|
pixDestroy(&image);
|
||||||
t_result.flag = true;
|
t_result.flag = true;
|
||||||
t_result.message = errorMessage;
|
t_result.message = errorMessage;
|
||||||
|
|
|
@ -244,6 +244,8 @@ private :
|
||||||
|
|
||||||
static TessOcrUtils *m_tessOcrUtils;
|
static TessOcrUtils *m_tessOcrUtils;
|
||||||
|
|
||||||
|
static tesseract::TessBaseAPI *t_Tesseract;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TESSOCRUTILS_H
|
#endif // TESSOCRUTILS_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user