chore(CI): amd内存泄露修改
Description: 单元测试内存泄露问题修改 Log: 内存释放错误 Change-Id: Ib5a86ea12a21b044e4d4ee9f8d81ac403a32d156
This commit is contained in:
parent
ff14725526
commit
3ed93d0480
|
@ -273,17 +273,20 @@ RecognitionResult TessOcrUtils::getRecognizeResult(Pix * image,ResultType result
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//识别图片
|
//识别图片
|
||||||
|
char* resultString = nullptr;
|
||||||
switch (resultType) {
|
switch (resultType) {
|
||||||
case ResultType::RESULT_HTML:
|
case ResultType::RESULT_HTML:
|
||||||
result = QString(t_Tesseract->GetHOCRText(0));
|
resultString = t_Tesseract->GetHOCRText(0);
|
||||||
break;
|
break;
|
||||||
case ResultType::RESULT_STRING:
|
case ResultType::RESULT_STRING:
|
||||||
result = QString(t_Tesseract->GetUTF8Text());
|
resultString = t_Tesseract->GetUTF8Text();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = QString(t_Tesseract->GetUTF8Text());
|
resultString = t_Tesseract->GetUTF8Text();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
result = QString(resultString);
|
||||||
|
delete [] resultString;
|
||||||
} catch (const std::logic_error &e) {
|
} catch (const std::logic_error &e) {
|
||||||
//errorMesage = "识别图片失败!" + QString(qExc.what());
|
//errorMesage = "识别图片失败!" + QString(qExc.what());
|
||||||
errorMessage = "Image recognition failed! " + QString(e.what());
|
errorMessage = "Image recognition failed! " + QString(e.what());
|
||||||
|
@ -293,12 +296,12 @@ RecognitionResult TessOcrUtils::getRecognizeResult(Pix * image,ResultType result
|
||||||
return t_result;
|
return t_result;
|
||||||
}
|
}
|
||||||
t_Tesseract->End();
|
t_Tesseract->End();
|
||||||
pixDestroy(&image);
|
//pixDestroy(&image);
|
||||||
t_result.flag = true;
|
t_result.flag = true;
|
||||||
t_result.message = errorMessage;
|
t_result.message = errorMessage;
|
||||||
t_result.errorCode = ErrorCode::OK;
|
t_result.errorCode = ErrorCode::OK;
|
||||||
t_result.resultType = resultType;
|
t_result.resultType = resultType;
|
||||||
t_result.result = result;
|
t_result.result = result.remove(QRegExp(" ")); // 去除识别结果中的空格字符串
|
||||||
m_isRunning = false;
|
m_isRunning = false;
|
||||||
return t_result;
|
return t_result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,7 @@ TEST_F(TessOcrUtilsTest, getRecogitionResultImageAndResultType)
|
||||||
EXPECT_EQ("", recognitionResult.message);
|
EXPECT_EQ("", recognitionResult.message);
|
||||||
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
|
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
|
||||||
EXPECT_EQ(resultType, recognitionResult.resultType);
|
EXPECT_EQ(resultType, recognitionResult.resultType);
|
||||||
|
delete t_image;
|
||||||
//EXPECT_NE("", recognitionResult.result);
|
//EXPECT_NE("", recognitionResult.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ TEST_F(TessOcrUtilsTest, getRecogitionResultImage)
|
||||||
EXPECT_EQ("", recognitionResult.message);
|
EXPECT_EQ("", recognitionResult.message);
|
||||||
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
|
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
|
||||||
EXPECT_EQ(ResultType::RESULT_STRING, recognitionResult.resultType);
|
EXPECT_EQ(ResultType::RESULT_STRING, recognitionResult.resultType);
|
||||||
|
delete t_image;
|
||||||
//EXPECT_NE("", recognitionResult.result);
|
//EXPECT_NE("", recognitionResult.result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -162,6 +164,7 @@ TEST_F(TessOcrUtilsTest, getRecognizeResult)
|
||||||
EXPECT_EQ("", recognitionResult.message);
|
EXPECT_EQ("", recognitionResult.message);
|
||||||
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
|
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
|
||||||
EXPECT_EQ(ResultType::RESULT_STRING, recognitionResult.resultType);
|
EXPECT_EQ(ResultType::RESULT_STRING, recognitionResult.resultType);
|
||||||
|
delete image;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TessOcrUtilsTest, setLanguagesPath)
|
TEST_F(TessOcrUtilsTest, setLanguagesPath)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user