Beispiel #1
0
 public bool TestForNewLine(RecognizedSegment seg, writerPosition position)
 {
     return Math.Abs(YValue - seg.Bounds.Y) > newLineYDiscrepancy && position != writerPosition.firstSeg;
 }
Beispiel #2
0
 public void RemoveOldRenderedString(RecognizedSegment seg)
 {
     for (int k = 0; k < renderingsAndEndIdx.Count; k++) {
         if (renderingsAndEndIdx[k].Item2 <= seg.Bounds.X)
             renderingsAndEndIdx.RemoveAt(k);
         else
             k = renderingsAndEndIdx.Count;
     }
 }
Beispiel #3
0
        //TODO: This won't be necessary when we enforce precise location
        private List<RecognizedSegment> orderAllResults(ReadOnlyCollection<RecognizedSegment> results)
        {
            var sortedOutput = results.OrderBy(k => k.Bounds.Y).ToList();
            int indiciesToAdjust = 0;

            for (int i = sortedOutput.Count - 1; i >= 0; i--) {
                if (i != 0 && (sortedOutput[i].Bounds.Y - sortedOutput[i - 1].Bounds.Y) < 4) {
                    indiciesToAdjust++;
                }
                else {
                    for (int j = 1; j <= indiciesToAdjust; j++) {
                        System.Drawing.Rectangle newBounds = new System.Drawing.Rectangle(sortedOutput[i + j].Bounds.X,
                                                                                            sortedOutput[i].Bounds.Y,
                                                                                            sortedOutput[i + j].Bounds.Width,
                                                                                            sortedOutput[i + j].Bounds.Height);
                        sortedOutput[i + j] = new RecognizedSegment(newBounds, sortedOutput[i + j].Text, sortedOutput[i + j].Certainty);
                    }
                    indiciesToAdjust = 0;
                }
            }

            sortedOutput = sortedOutput.OrderByDescending(k => k.Bounds.Width)
                                        .OrderBy(k => k.Bounds.X)
                                        .OrderBy(k => k.Bounds.Y).ToList();
            return sortedOutput;
        }
Beispiel #4
0
 public void AdjustLastSegValues(RecognizedSegment seg)
 {
     endingXValue = seg.Bounds.Right;
     startingXValue = seg.Bounds.X;
     YValue = seg.Bounds.Y;
 }
Beispiel #5
0
        static List<RecognizedSegment> CombineSegments(IEnumerable<RecognizedSegment> segments)
        {
            var sortedOutput = segments.OrderBy(k => k.Bounds.Y).ToList();
            int indiciesToAdjust = 0;

            for (int i = sortedOutput.Count - 1; i >= 0; i--) {
                if (i != 0 && (sortedOutput[i].Bounds.Y - sortedOutput[i - 1].Bounds.Y) < 4) {
                    indiciesToAdjust++;
                } else {
                    for (int j = 1; j <= indiciesToAdjust; j++) {
                        System.Drawing.Rectangle newBounds = new System.Drawing.Rectangle(sortedOutput[i + j].Bounds.X,
                                                                                          sortedOutput[i].Bounds.Y,
                                                                                          sortedOutput[i + j].Bounds.Width,
                                                                                          sortedOutput[i + j].Bounds.Height);
                        sortedOutput[i + j] = new RecognizedSegment(newBounds, sortedOutput[i + j].Text, sortedOutput[i + j].Certainty);
                    }
                    indiciesToAdjust = 0;
                }
            }

            return sortedOutput.OrderByDescending(k => k.Bounds.Width)
                               .ThenBy(k => k.Bounds.X)
                               .ThenBy(k => k.Bounds.Y)
                               .ToList();
        }