{"record":{"id":"cdcc7c69a5b1b6df","repo":"babalae/better-genshin-impact","slug":"error-cdcc7c","errorCode":null,"errorMessage":"模板素材未找到","messagePattern":"模板素材未找到","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropTask.cs","lineNumber":280,"sourceCode":"        {\n            ro.RegionOfInterest = roi.Value;\n        }\n\n        return ro;\n    }\n\n    private Mat LoadTemplate(string relativePath)\n    {\n        if (_templateCache.TryGetValue(relativePath, out var cached))\n        {\n            return cached;\n        }\n\n        var workDir = Global.Absolute(@\"GameTask\\AutoLeyLineOutcrop\");\n        var fullPath = Path.Combine(workDir, relativePath.Replace(\"/\", Path.DirectorySeparatorChar.ToString()));\n        if (!File.Exists(fullPath))\n        {\n            throw new FileNotFoundException(\"模板素材未找到\", fullPath);\n        }\n\n        var mat = Mat.FromStream(File.OpenRead(fullPath), ImreadModes.Color);\n        // Resize once and reuse to avoid repeated scaling during recognition.\n        var scaled = ResizeHelper.Resize(mat, _systemInfo.AssetScale);\n        _templateCache[relativePath] = scaled;\n        return scaled;\n    }\n\n    private async Task<int> HandleResinExhaustionMode()\n    {\n        if (!_taskParam.IsResinExhaustionMode)\n        {\n            return _taskParam.Count;\n        }\n\n        var result = await CalCountByResin();\n        if (result.Count <= 0)","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropTask.cs#L262-L298","documentation":"Thrown as a FileNotFoundException by LoadTemplate when a template image file (e.g. Assets/icon/open.png, Assets/icon/close.png) referenced by a RecognitionObject does not exist on disk. LoadTemplate resolves the path under GameTask/AutoLeyLineOutcrop and is called during LoadRecognitionObjects to build template-matching ROIs for icons like the ley line open/close buttons, box icon, map settings button, and handbook track-action button.","triggerScenarios":"LoadTemplate is called for each template path during Initialize. Fires when any one of the expected image files (open.png, close.png, paimon_menu.png, box.png, map_setting_button.bmp, handbook_track_action_left.png) is missing from the Assets/icon directory.","commonSituations":"Incomplete installation missing icon assets; antivirus quarantine; the image file was renamed or moved during a refactor; a build did not copy image resources to the output; a version update added a new template but the old installation was not fully replaced.","solutions":["Reinstall the application to restore all bundled icon assets.","Verify the Assets/icon directory under GameTask/AutoLeyLineOutcrop contains all expected .png and .bmp files.","If building from source, ensure image files have Build Action set to Content and CopyToOutputDirectory.","Check the error message's fileName field to identify which specific template is missing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before building recognition objects, verify all template files exist\nvar workDir = Global.Absolute(@\"GameTask\\AutoLeyLineOutcrop\");\nvar requiredTemplates = new[] { \"Assets/icon/open.png\", \"Assets/icon/close.png\", \"Assets/icon/box.png\" };\nforeach (var rel in requiredTemplates)\n{\n    var fullPath = Path.Combine(workDir, rel);\n    if (!File.Exists(fullPath))\n    {\n        Logger.LogError(\"模板素材缺失: {Path}\", fullPath);\n    }\n}","typeGuard":null,"tryCatchPattern":"catch (FileNotFoundException ex) when (ex.Message.Contains(\"模板素材未找到\"))\n{\n    logger.LogError(\"模板图片缺失: {Path}\", ex.FileName);\n    ThemedMessageBox.Error($\"模板图片缺失，请重新安装程序: {ex.FileName}\", \"文件未找到\");\n}","preventionTips":["Use a complete application installation with all icon assets.","If building from source, verify image files have Build Action = Content and CopyToOutputDirectory.","Do not delete or move files under the Assets/icon directory."],"tags":["ley-line","file-not-found","assets","template","opencv"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}