{"record":{"id":"d5ad934bbe3a4ada","repo":"babalae/better-genshin-impact","slug":"levelline","errorCode":null,"errorMessage":"未识别的等级：{levelLine}","messagePattern":"未识别的等级：(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoArtifactSalvage/AutoArtifactSalvageTask.cs","lineNumber":735,"sourceCode":"        #endregion\n\n        #region 等级\n        string levelLine = levelAndMinorAffixLines.Select(l =>\n        {\n            string pattern = @\"^\\+(\\d*)$\";\n            Match match = Regex.Match(l, pattern);\n            if (match.Success)\n            {\n                return match.Groups[1].Value;\n            }\n            else\n            {\n                return null;\n            }\n        }).Where(l => l != null).Cast<string>().SingleOrDefault() ?? throw new Exception($\"未找到等级对应的行：\\n{levelAndMinorAffixLines}\");\n        if (!int.TryParse(levelLine, out int level) || level < 0 || level > 20)\n        {\n            throw new Exception($\"未识别的等级：{levelLine}\");\n        }\n        #endregion\n\n        return new ArtifactStat(name, mainAffix, minorAffixes.ToArray(), level);\n    }\n\n    public static ArtifactStatus GetArtifactStatus(Mat src)\n    {\n        using Mat upperLine = new Mat(src, new Rect(0, 0, src.Width, (int)(src.Height * 0.19)));\n        //using Mat hsvMat = upperLine.CvtColor(ColorConversionCodes.BGR2HSV_FULL);\n        //var pixel_hsv_pink = hsvMat.At<Vec3b>(17, 12);    // 注意是（Y，X）\n        //var pixel_hsv_grren = hsvMat.At<Vec3b>(8, 105);   // 注意是（Y，X）\n\n        // 粉色锁\n        Scalar pinkhsv = OpenCvCommonHelper.CommonHSV2OpenCVHSVFull(new Scalar(9, 0.54, 1.00));\n        var lowPink = new Scalar(pinkhsv.Val0 - 3, pinkhsv.Val1 - 25, pinkhsv.Val2 - 25);\n        var highPink = new Scalar(pinkhsv.Val0 + 3, pinkhsv.Val1 + 25, pinkhsv.Val2);\n        using Mat pinkMask = OpenCvCommonHelper.InRangeHsvFull(upperLine, lowPink, highPink);","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoArtifactSalvage/AutoArtifactSalvageTask.cs#L717-L753","documentation":"Thrown when a level line was found (157 passed) but int.TryParse fails OR the parsed value is outside [0, 20]. Genshin artifact levels are bounded 0-20, so out-of-range indicates an OCR/capture error rather than a real level.","triggerScenarios":"OCR mis-read the level digits (e.g. '+2O' with a letter O); the matched line is not actually the level (false positive from 157's regex matching another '+N'); value exceeds 20 due to merged text.","commonSituations":"OCR confusion between digits and similar glyphs (0/O, 1/l); a non-level line matching '+\\d+' leaked through; UI overlay text captured alongside the level.","solutions":["Log levelLine to inspect the misread value.","Improve OCR preprocessing for the level region (threshold, scale).","Tighten 157's selection so only the true level line is matched.","Apply RecognitionFailurePolicy (Skip/Throw) consistently for out-of-range."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"static bool IsValidLevel(int level) => level >= 0 && level <= 20;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Improve OCR preprocessing for the level region to avoid digit/letter confusion.","Log the misread value for diagnosis.","Tighten 157's selection so only the real level line is matched.","Skip the card when the value is out of range."],"tags":["game-task","ocr","artifact","parsing","validation"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}