| 331 | } |
| 332 | |
| 333 | std::optional<PipelineTask::BatchOCRPlan> PipelineTask::prepare_batch_ocr(const std::vector<MAA_RES_NS::NodeAttr>& list) |
| 334 | { |
| 335 | using namespace MAA_RES_NS::Recognition; |
| 336 | |
| 337 | if (!context_) { |
| 338 | return std::nullopt; |
| 339 | } |
| 340 | |
| 341 | OCRCollectContext ctx; |
| 342 | |
| 343 | for (const auto& node : list) { |
| 344 | auto data_opt = context_->get_pipeline_data(node); |
| 345 | if (!data_opt) { |
| 346 | continue; |
| 347 | } |
| 348 | const auto& data = *data_opt; |
| 349 | |
| 350 | if (!data.enabled) { |
| 351 | continue; |
| 352 | } |
| 353 | |
| 354 | if (!context_->check_hit_count(data)) { |
| 355 | continue; |
| 356 | } |
| 357 | |
| 358 | collect_ocr_from_reco(ctx, data.name, data.reco_type, data.reco_param); |
| 359 | } |
| 360 | |
| 361 | if (ctx.plan.entries.size() < 2) { |
| 362 | LogDebug << "batch OCR not needed, eligible OCR nodes < 2" << VAR(ctx.plan.entries.size()); |
| 363 | return std::nullopt; |
| 364 | } |
| 365 | |
| 366 | LogInfo << "prepared batch OCR plan" << VAR(ctx.plan.node_names) << VAR(ctx.plan.model); |
| 367 | return ctx.plan; |
| 368 | } |
| 369 | |
| 370 | void PipelineTask::try_add_ocr_node(OCRCollectContext& ctx, const std::string& name, const MAA_VISION_NS::OCRerParam& param) |
| 371 | { |
nothing calls this directly
no test coverage detected