chore(CI): amd内存泄露修改

Description: 单元测试内存泄露问题修改

Log: 内存释放错误
Change-Id: Ib5a86ea12a21b044e4d4ee9f8d81ac403a32d156
This commit is contained in:
ut000593 2021-12-21 14:47:30 +08:00
parent ff14725526
commit 3ed93d0480
2 changed files with 11 additions and 5 deletions

View File

@ -273,17 +273,20 @@ RecognitionResult TessOcrUtils::getRecognizeResult(Pix * image,ResultType result
try {
//识别图片
char* resultString = nullptr;
switch (resultType) {
case ResultType::RESULT_HTML:
result = QString(t_Tesseract->GetHOCRText(0));
resultString = t_Tesseract->GetHOCRText(0);
break;
case ResultType::RESULT_STRING:
result = QString(t_Tesseract->GetUTF8Text());
resultString = t_Tesseract->GetUTF8Text();
break;
default:
result = QString(t_Tesseract->GetUTF8Text());
resultString = t_Tesseract->GetUTF8Text();
break;
}
result = QString(resultString);
delete [] resultString;
} catch (const std::logic_error &e) {
//errorMesage = "识别图片失败!" + QString(qExc.what());
errorMessage = "Image recognition failed! " + QString(e.what());
@ -293,12 +296,12 @@ RecognitionResult TessOcrUtils::getRecognizeResult(Pix * image,ResultType result
return t_result;
}
t_Tesseract->End();
pixDestroy(&image);
//pixDestroy(&image);
t_result.flag = true;
t_result.message = errorMessage;
t_result.errorCode = ErrorCode::OK;
t_result.resultType = resultType;
t_result.result = result;
t_result.result = result.remove(QRegExp(" ")); // 去除识别结果中的空格字符串
m_isRunning = false;
return t_result;
}

View File

@ -112,6 +112,7 @@ TEST_F(TessOcrUtilsTest, getRecogitionResultImageAndResultType)
EXPECT_EQ("", recognitionResult.message);
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
EXPECT_EQ(resultType, recognitionResult.resultType);
delete t_image;
//EXPECT_NE("", recognitionResult.result);
}
@ -124,6 +125,7 @@ TEST_F(TessOcrUtilsTest, getRecogitionResultImage)
EXPECT_EQ("", recognitionResult.message);
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
EXPECT_EQ(ResultType::RESULT_STRING, recognitionResult.resultType);
delete t_image;
//EXPECT_NE("", recognitionResult.result);
}
@ -162,6 +164,7 @@ TEST_F(TessOcrUtilsTest, getRecognizeResult)
EXPECT_EQ("", recognitionResult.message);
EXPECT_EQ(ErrorCode::OK, recognitionResult.errorCode);
EXPECT_EQ(ResultType::RESULT_STRING, recognitionResult.resultType);
delete image;
}
TEST_F(TessOcrUtilsTest, setLanguagesPath)