fix.修复一些浮点数溢出导致的异常

This commit is contained in:
MistEO
2022-03-15 00:13:43 +08:00
parent 953ae8363b
commit 29832045d3
3 changed files with 5 additions and 2 deletions

View File

@@ -108,7 +108,7 @@ bool asst::MatchImageAnalyzer::match_templ(const cv::Mat templ)
Log.trace("match_templ |", m_templ_name, "score:", max_val, "rect:", rect.to_string(), "roi:", m_roi.to_string());
}
if (max_val >= m_templ_thres) {
if (m_templ_thres <= max_val && max_val < 2.0) {
m_result = { max_val, rect };
return true;
}

View File

@@ -105,7 +105,7 @@ bool asst::MultiMatchImageAnalyzer::multi_match_templ(const cv::Mat templ)
for (int i = 0; i != matched.rows; ++i) {
for (int j = 0; j != matched.cols; ++j) {
auto value = matched.at<float>(i, j);
if (value >= m_templ_thres) {
if (m_templ_thres <= value && value < 2.0) {
Rect rect(j + m_roi.x, i + m_roi.y, templ.cols, templ.rows);
bool need_push = true;
// 如果有两个点离得太近,只取里面得分高的那个

View File

@@ -97,6 +97,9 @@ std::vector<asst::TextRect> asst::OcrPack::recognize(const cv::Mat image, const
}
std::string text(*(m_strs_buffer + i));
float score = *(m_scores_buffer + i);
if (score > 2.0) {
score = 0;
}
TextRect tr{ score, rect, text };
#ifdef ASST_DEBUG