tests started and tuning

This commit is contained in:
Boki 2026-02-11 15:17:44 -05:00
parent b8f5637c49
commit 641c87121a
17 changed files with 391 additions and 18 deletions

View file

@ -208,3 +208,101 @@ class DetectGridResponse
[JsonPropertyName("cellHeight")]
public double CellHeight { get; set; }
}
class DiffOcrParams
{
[JsonPropertyName("diffThresh")]
public int DiffThresh { get; set; } = 10;
[JsonPropertyName("rowThreshDiv")]
public int RowThreshDiv { get; set; } = 30;
[JsonPropertyName("colThreshDiv")]
public int ColThreshDiv { get; set; } = 8;
[JsonPropertyName("maxGap")]
public int MaxGap { get; set; } = 20;
[JsonPropertyName("trimCutoff")]
public double TrimCutoff { get; set; } = 0.4;
[JsonPropertyName("kernelSize")]
public int KernelSize { get; set; } = 41;
[JsonPropertyName("upscale")]
public int Upscale { get; set; } = 2;
public DiffOcrParams Clone() => (DiffOcrParams)MemberwiseClone();
public override string ToString() =>
$"diffThresh={DiffThresh} rowThreshDiv={RowThreshDiv} colThreshDiv={ColThreshDiv} maxGap={MaxGap} trimCutoff={TrimCutoff:F2} kernelSize={KernelSize} upscale={Upscale}";
}
class TestCase
{
[JsonPropertyName("id")]
public string Id { get; set; } = "";
[JsonPropertyName("image")]
public string Image { get; set; } = "";
[JsonPropertyName("fullImage")]
public string FullImage { get; set; } = "";
[JsonPropertyName("expected")]
public List<string> Expected { get; set; } = [];
}
class TestCaseResult
{
[JsonPropertyName("id")]
public string Id { get; set; } = "";
[JsonPropertyName("passed")]
public bool Passed { get; set; }
[JsonPropertyName("score")]
public double Score { get; set; }
[JsonPropertyName("matched")]
public List<string> Matched { get; set; } = [];
[JsonPropertyName("missed")]
public List<string> Missed { get; set; } = [];
[JsonPropertyName("extra")]
public List<string> Extra { get; set; } = [];
}
class TestResponse
{
[JsonPropertyName("ok")]
public bool Ok => true;
[JsonPropertyName("passed")]
public int Passed { get; set; }
[JsonPropertyName("failed")]
public int Failed { get; set; }
[JsonPropertyName("total")]
public int Total { get; set; }
[JsonPropertyName("results")]
public List<TestCaseResult> Results { get; set; } = [];
}
class TuneResponse
{
[JsonPropertyName("ok")]
public bool Ok => true;
[JsonPropertyName("bestScore")]
public double BestScore { get; set; }
[JsonPropertyName("bestParams")]
public DiffOcrParams BestParams { get; set; } = new();
[JsonPropertyName("iterations")]
public int Iterations { get; set; }
}