feat: PipelineAnalyzer 支持使用灰度图匹配文字

This commit is contained in:
uye
2025-08-01 21:02:19 +08:00
parent e4453e5a33
commit 92bd4690cd
6 changed files with 16 additions and 7 deletions

View File

@@ -100,6 +100,7 @@ void OCRerConfig::_set_task_info(OcrTaskInfo task_info)
m_params.without_det = task_info.without_det;
m_params.bin_threshold_lower = task_info.bin_threshold_lower;
m_params.bin_threshold_upper = task_info.bin_threshold_upper;
m_params.use_raw = task_info.use_raw;
_set_roi(task_info.roi);
}

View File

@@ -18,6 +18,7 @@ public:
bool replace_full = false;
bool without_det = false;
bool use_char_model = false;
bool use_raw = false;
int bin_threshold_lower = 140;
int bin_threshold_upper = 255;

View File

@@ -40,8 +40,10 @@ RegionOCRer::ResultOpt RegionOCRer::analyze() const
#endif // ASST_DEBUG
new_roi = correct_rect(new_roi, m_roi);
auto config = m_params;
auto use_raw = config.use_raw;
OCRer ocr_analyzer;
if (m_use_raw) {
if (use_raw) {
ocr_analyzer = OCRer(m_image, new_roi);
}
else {
@@ -51,7 +53,6 @@ RegionOCRer::ResultOpt RegionOCRer::analyze() const
ocr_analyzer = OCRer(bin3, bounding_rect);
}
auto config = m_params;
config.without_det = true;
ocr_analyzer.set_params(std::move(config));
@@ -60,7 +61,7 @@ RegionOCRer::ResultOpt RegionOCRer::analyze() const
return std::nullopt;
}
m_result = result->front();
if (!m_use_raw) {
if (!use_raw) {
m_result.rect.x += m_roi.x;
m_result.rect.y += m_roi.y;
}

View File

@@ -15,7 +15,7 @@ public:
ResultOpt analyze() const;
void set_use_raw(bool use_raw) { m_use_raw = use_raw; }
void set_use_raw(bool use_raw) { m_params.use_raw = use_raw; }
// FIXME: 老接口太难重构了,先弄个这玩意兼容下,后续慢慢全删掉
const auto& get_result() const noexcept { return m_result; }
@@ -31,6 +31,5 @@ protected:
private:
// FIXME: 老接口太难重构了,先弄个这玩意兼容下,后续慢慢全删掉
mutable Result m_result;
bool m_use_raw = true;
};
}