{"record":{"id":"53ed0a274fe56139","repo":"MaaAssistantArknights/MaaAssistantArknights","slug":"blackflow-map-perception-is-not-loaded","errorCode":null,"errorMessage":"BlackFlow map perception is not loaded","messagePattern":"BlackFlow map perception is not loaded","errorType":"exception","errorClass":"std::runtime_error","httpStatus":null,"severity":"error","filePath":"src/MaaCore/Vision/Roguelike/BlackFlow/BlackFlowMapAnalyzer.cpp","lineNumber":123,"sourceCode":"        error = \"BlackFlow map perception initialization failed: unknown exception\";\n        m_node_detector.reset();\n        m_loaded = false;\n        return false;\n    }\n}\n\nMapRecognitionResult BlackFlowMapAnalyzer::recognize(const cv::Mat& image, int floor, bool render_overlay) const\n{\n    MapRecognitionResult result;\n    result.floor = floor;\n    std::chrono::steady_clock::time_point normalization_start;\n    std::chrono::steady_clock::time_point recognition_start;\n    bool normalization_started = false;\n    bool normalization_finished = false;\n    bool recognition_started = false;\n    try {\n        if (!m_loaded || m_node_detector == nullptr) {\n            throw std::runtime_error(\"BlackFlow map perception is not loaded\");\n        }\n        if (image.empty() || image.type() != CV_8UC3) {\n            throw std::runtime_error(\"BlackFlow map perception requires a non-empty BGR8 image\");\n        }\n        const auto profile = floor_profile(floor);\n        if (!profile.has_value()) {\n            throw std::runtime_error(\"floor must be an integer from 1 to 5\");\n        }\n        result.rows = profile->rows;\n        result.columns = profile->columns;\n        result.captured_bgr = image.clone();\n\n        normalization_start = std::chrono::steady_clock::now();\n        normalization_started = true;\n        FrameNormalizationInfo normalization;\n        std::string normalization_error;\n        if (!m_normalizer.normalize(image, result.normalized_bgr, normalization, normalization_error)) {\n            throw std::runtime_error(\"Image normalization failed: \" + normalization_error);","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/68e5200d0a787d88807b1516dd118af6d6fa0487/src/MaaCore/Vision/Roguelike/BlackFlow/BlackFlowMapAnalyzer.cpp#L105-L141","documentation":"BlackFlowMapAnalyzer::recognize can only run after a successful load(); it checks m_loaded and m_node_detector and throws \"BlackFlow map perception is not loaded\" if the analyzer was never initialized or loading failed. This is a guard against using the analyzer in an uninitialized state.","triggerScenarios":"Calling recognize() before load(), after load() threw (e.g. Cannot open JSON), or when node detector construction failed during load.","commonSituations":"Skipping initialization in custom integrations, ignoring a failed load return path, reusing an analyzer after a resource error.","solutions":["Call load() with a valid map JSON and confirm it succeeds before recognize()","Check that the previous load error (if any) was resolved","Re-create the analyzer and load again after fixing resources","Assert m_loaded in your integration code before invoking recognize"],"exampleFix":"// before\nanalyzer.recognize(image, floor);\n// after\nif (analyzer.load(mapPath)) { analyzer.recognize(image, floor); }","handlingStrategy":"type-guard","validationCode":"// only call recognize after a successful load\nif (!loaded) { /* call load(mapPath) first */ }","typeGuard":"bool isAnalyzerReady(const BlackFlowMapAnalyzer& a) { return a.isLoaded(); } // check m_loaded equivalent accessor","tryCatchPattern":"try { auto r = analyzer.recognize(image, floor); }\ncatch (const std::runtime_error& e) {\n    if (std::string(e.what()) == \"BlackFlow map perception is not loaded\") {\n        // (re)load map data then retry once\n    } else throw;\n}","preventionTips":["Always pair construction with a checked load()","Handle load failures before the recognition loop","Re-create the analyzer after resource errors","Assert readiness in integration tests"],"tags":["blackflow","state","initialization","roguelike"],"backgroundTag":"analyzer-not-initialized","analyzedSha":"68e5200d0a787d88807b1516dd118af6d6fa0487","analyzedAt":"2026-09-01T04:33:15.058Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}