MaaAssistantArknights/MaaAssistantArknights · error · std::runtime_error
BlackFlow map perception is not loaded
Error message
BlackFlow map perception is not loaded
What it means
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.
Source
Thrown at src/MaaCore/Vision/Roguelike/BlackFlow/BlackFlowMapAnalyzer.cpp:123
error = "BlackFlow map perception initialization failed: unknown exception";
m_node_detector.reset();
m_loaded = false;
return false;
}
}
MapRecognitionResult BlackFlowMapAnalyzer::recognize(const cv::Mat& image, int floor, bool render_overlay) const
{
MapRecognitionResult result;
result.floor = floor;
std::chrono::steady_clock::time_point normalization_start;
std::chrono::steady_clock::time_point recognition_start;
bool normalization_started = false;
bool normalization_finished = false;
bool recognition_started = false;
try {
if (!m_loaded || m_node_detector == nullptr) {
throw std::runtime_error("BlackFlow map perception is not loaded");
}
if (image.empty() || image.type() != CV_8UC3) {
throw std::runtime_error("BlackFlow map perception requires a non-empty BGR8 image");
}
const auto profile = floor_profile(floor);
if (!profile.has_value()) {
throw std::runtime_error("floor must be an integer from 1 to 5");
}
result.rows = profile->rows;
result.columns = profile->columns;
result.captured_bgr = image.clone();
normalization_start = std::chrono::steady_clock::now();
normalization_started = true;
FrameNormalizationInfo normalization;
std::string normalization_error;
if (!m_normalizer.normalize(image, result.normalized_bgr, normalization, normalization_error)) {
throw std::runtime_error("Image normalization failed: " + normalization_error);View on GitHub (pinned to 68e5200d0a)
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
Example fix
// before
analyzer.recognize(image, floor);
// after
if (analyzer.load(mapPath)) { analyzer.recognize(image, floor); } Defensive patterns
Strategy: type-guard
Validate before calling
// only call recognize after a successful load
if (!loaded) { /* call load(mapPath) first */ } Type guard
bool isAnalyzerReady(const BlackFlowMapAnalyzer& a) { return a.isLoaded(); } // check m_loaded equivalent accessor Try / catch
try { auto r = analyzer.recognize(image, floor); }
catch (const std::runtime_error& e) {
if (std::string(e.what()) == "BlackFlow map perception is not loaded") {
// (re)load map data then retry once
} else throw;
} Prevention
- 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
When it happens
Trigger: Calling recognize() before load(), after load() threw (e.g. Cannot open JSON), or when node detector construction failed during load.
Common situations: Skipping initialization in custom integrations, ignoring a failed load return path, reusing an analyzer after a resource error.
Related errors
- BlackFlow strategy config:
- floor must be an integer from 1 to 5
- platform not supported
- Unsupported resolution
- Cannot open JSON:
AI-assisted analysis of MaaAssistantArknights/MaaAssistantArknights@68e5200d0a (2026-09-01).
Data as JSON: /api/errors/53ed0a274fe56139.
Report an issue: GitHub.