MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / prepare_batch_ocr

Method prepare_batch_ocr

source/MaaFramework/Task/PipelineTask.cpp:333–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333std::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
370void PipelineTask::try_add_ocr_node(OCRCollectContext& ctx, const std::string& name, const MAA_VISION_NS::OCRerParam& param)
371{

Callers

nothing calls this directly

Calls 3

get_pipeline_dataMethod · 0.80
check_hit_countMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected