public static List <string> GetLineSegmentation(IReadOnlyList <EntityAnnotation> data) { var mergedArray = Initialization(data); CoordinatesHelper.GetBoundingPolygon(mergedArray); CoordinatesHelper.CombineBoundingPolygon(mergedArray); // This does the line segmentation based on the bounding boxes return(ConstructLineWithBoundingPolygon(mergedArray)); }
static List <ReceiptEntityAnnotation> Initialization(IReadOnlyList <EntityAnnotation> data) { // Computes the maximum y coordinate from the identified text blob int yMax = data[0].BoundingPoly.Vertices.Max(y => y.Y); CoordinatesHelper.InvertAxis(data, yMax); // The first index refers to the auto identified words which belongs to a sings line List <string> lines = data[0].Description.Split('\n').Reverse().ToList(); // gcp vision full text and remove the zeroth element which gives the total summary of the text // reverse to use lifo, because array.shift() will consume 0(n) var rawText = data.Skip(1).Reverse().ToList(); return(GetMergedLines(lines, rawText)); }