namespace OcrDaemon; using System.Text.Json.Serialization; class Request { [JsonPropertyName("cmd")] public string? Cmd { get; set; } [JsonPropertyName("region")] public RegionRect? Region { get; set; } [JsonPropertyName("path")] public string? Path { get; set; } [JsonPropertyName("cols")] public int Cols { get; set; } [JsonPropertyName("rows")] public int Rows { get; set; } [JsonPropertyName("threshold")] public int Threshold { get; set; } [JsonPropertyName("minCellSize")] public int MinCellSize { get; set; } [JsonPropertyName("maxCellSize")] public int MaxCellSize { get; set; } [JsonPropertyName("file")] public string? File { get; set; } [JsonPropertyName("debug")] public bool Debug { get; set; } [JsonPropertyName("ocr")] public OcrOptions? Ocr { get; set; } [JsonPropertyName("targetRow")] public int TargetRow { get; set; } = -1; [JsonPropertyName("targetCol")] public int TargetCol { get; set; } = -1; } class OcrOptions { [JsonPropertyName("preprocess")] public bool Preprocess { get; set; } = true; [JsonPropertyName("kernelSize")] public int KernelSize { get; set; } = 25; [JsonPropertyName("scale")] public int Scale { get; set; } = 2; [JsonPropertyName("minConfidence")] public int MinConfidence { get; set; } = 50; } class RegionRect { [JsonPropertyName("x")] public int X { get; set; } [JsonPropertyName("y")] public int Y { get; set; } [JsonPropertyName("width")] public int Width { get; set; } [JsonPropertyName("height")] public int Height { get; set; } } class ReadyResponse { [JsonPropertyName("ok")] public bool Ok => true; [JsonPropertyName("ready")] public bool Ready => true; } class OkResponse { [JsonPropertyName("ok")] public bool Ok => true; } class ErrorResponse(string message) { [JsonPropertyName("ok")] public bool Ok => false; [JsonPropertyName("error")] public string Error => message; } class OcrResponse { [JsonPropertyName("ok")] public bool Ok => true; [JsonPropertyName("text")] public string Text { get; set; } = ""; [JsonPropertyName("lines")] public List Lines { get; set; } = []; } class DiffOcrResponse { [JsonPropertyName("ok")] public bool Ok => true; [JsonPropertyName("text")] public string Text { get; set; } = ""; [JsonPropertyName("lines")] public List Lines { get; set; } = []; [JsonPropertyName("region")] public RegionRect? Region { get; set; } } class OcrLineResult { [JsonPropertyName("text")] public string Text { get; set; } = ""; [JsonPropertyName("words")] public List Words { get; set; } = []; } class OcrWordResult { [JsonPropertyName("text")] public string Text { get; set; } = ""; [JsonPropertyName("x")] public int X { get; set; } [JsonPropertyName("y")] public int Y { get; set; } [JsonPropertyName("width")] public int Width { get; set; } [JsonPropertyName("height")] public int Height { get; set; } } class CaptureResponse { [JsonPropertyName("ok")] public bool Ok => true; [JsonPropertyName("image")] public string Image { get; set; } = ""; } class GridResponse { [JsonPropertyName("ok")] public bool Ok => true; [JsonPropertyName("cells")] public List> Cells { get; set; } = []; [JsonPropertyName("items")] public List? Items { get; set; } [JsonPropertyName("matches")] public List? Matches { get; set; } } class GridItem { [JsonPropertyName("row")] public int Row { get; set; } [JsonPropertyName("col")] public int Col { get; set; } [JsonPropertyName("w")] public int W { get; set; } [JsonPropertyName("h")] public int H { get; set; } } class GridMatch { [JsonPropertyName("row")] public int Row { get; set; } [JsonPropertyName("col")] public int Col { get; set; } [JsonPropertyName("similarity")] public double Similarity { get; set; } } class DetectGridResponse { [JsonPropertyName("ok")] public bool Ok => true; [JsonPropertyName("detected")] public bool Detected { get; set; } [JsonPropertyName("region")] public RegionRect? Region { get; set; } [JsonPropertyName("cols")] public int Cols { get; set; } [JsonPropertyName("rows")] public int Rows { get; set; } [JsonPropertyName("cellWidth")] public double CellWidth { get; set; } [JsonPropertyName("cellHeight")] public double CellHeight { get; set; } }