예제 #1
0
        public IEnumerable<RecognizedSegment> Recognize(Stream document, IProgressReporter progress)
        {
            var imageData = new ImageData(document);
            var boards = imageData.DefineIteratedBoards();

            var heuristics = boards.Segment().ToList();

            progress.Maximum = heuristics.Count * 1000;

            foreach (var segment in heuristics) {
                var whitespaceResults = trainingData.PerformWhitespaceLookup(segment, progress.ScaledChildOperation(500)).LastOrDefault(r => r.Certainty > 10);

                if (whitespaceResults != null && whitespaceResults.Text == "AllLabels") {
                    var match = trainingData.PerformLookup(segment, progress.ScaledChildOperation(500)).LastOrDefault(r => r.Certainty > 10);
                    if (match != null)
                        yield return match;
                } else
                    progress.Progress += 500;	//Add the progress that would have been used by the character recognition
            }
        }