{"record":{"id":"1d3b03de0a2d8e8b","repo":"babalae/better-genshin-impact","slug":"error-1d3b03","errorCode":null,"errorMessage":"尝试获取生之花失败","messagePattern":"尝试获取生之花失败","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/GetGridIcons/GetGridIconsTask.cs","lineNumber":200,"sourceCode":"                var whiteOcrResult = OcrFactory.Paddle.OcrResult(roi);\n                flowerName = whiteOcrResult.Text;\n                // 所以只好识别两次，Trim后根据字数取原截图OCR的结果……\n                flowerName = flowerWithGlyph.Text.Trim().Substring(flowerWithGlyph.Text.Trim().Length - flowerName.Trim().Length);\n                return true;\n            }\n\n            if (!tryGetFlower(out string flowerName))\n            {\n                await TaskControl.Delay(100, this.ct);\n                for (int i = 0; i < 5; i++)\n                {\n                    this.input.Mouse.VerticalScroll(-2);\n                    await TaskControl.Delay(40, this.ct);\n                }\n                await TaskControl.Delay(300, this.ct);\n                if (!tryGetFlower(out flowerName))\n                {\n                    throw new Exception(\"尝试获取生之花失败\");\n                    //flowerName = $\"识别失败{nameRegion.GetHashCode()}\";\n                }\n            }\n\n            string fileName = flowerName;\n            if (fileNames.Add(fileName))\n            {\n                string filePath = Path.Combine(directory, $\"{fileName}.png\");\n                Thread saveThread = new Thread(() =>\n                {\n                    try\n                    {\n                        using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))\n                        {\n                            using Mat img125 = CropResizeArtifactSetFilterGridIcon(itemRegion);\n                            img125.ToBitmap().Save(fs, System.Drawing.Imaging.ImageFormat.Png);\n                        }\n                        logger.LogInformation(\"图片保存成功：{Text}\", fileName);","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/GetGridIcons/GetGridIconsTask.cs#L182-L218","documentation":"Thrown by GetGridIconsTask.GetArtifactSetFilterGridIcons after two failed attempts to OCR-recognize the flower (生之花) name from the artifact set filter screen. The local function tryGetFlower returns false when the OCR result does not contain a '套装包含' (set contains) region. After scrolling and retrying, a second failure aborts with a generic Exception.","triggerScenarios":"Calling GetArtifactSetFilterGridIcons when the game UI does not show the expected artifact set filter detail panel, OCR fails to detect the '套装包含' text, or the flower name region is obscured/blank. The error fires only after the retry with scrolling also fails.","commonSituations":"The game language is not Chinese so the OCR text pattern does not match; the game window is partially occluded or the detail panel did not open; the game UI changed in a version update shifting the OCR crop region; running on a resolution where the crop proportions are off.","solutions":["Ensure the game language is set to Chinese (simplified) so the '套装包含' OCR trigger text is present.","Manually open the artifact set filter detail panel before starting the task, as indicated by the log message for unsupported auto-open.","Verify the game window is fully visible and not occluded.","Check that the game resolution is 1920x1080 or the crop region proportions still match.","Consider catching this exception and skipping the item with a fallback name instead of aborting the entire task."],"exampleFix":"// before\nif (!tryGetFlower(out flowerName))\n{\n    throw new Exception(\"尝试获取生之花失败\");\n}\n\n// after — degrade gracefully instead of aborting\nif (!tryGetFlower(out flowerName))\n{\n    flowerName = $\"识别失败_{DateTime.Now:HHmmss}\";\n    logger.LogWarning(\"尝试获取生之花失败，使用回退名称：{Name}\", flowerName);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await GetArtifactSetFilterGridIcons(count, directory); }\ncatch (Exception ex) when (ex.Message.Contains(\"生之花\"))\n{ logger.LogWarning(ex, \"OCR 识别生之花失败，跳过该项\"); }","preventionTips":["Ensure the game language is Chinese (simplified) for OCR pattern matching.","Manually open the artifact set filter detail panel before starting.","Keep the game window fully visible and at 1920x1080 for best OCR accuracy."],"tags":["ocr","game-task","ui-recognition","runtime"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}