예제 #1
0
        public Image DrawRegion(OcrRegion region, OcrLocation ocrLocation)
        {
            var bmp      = new Bitmap(Source);
            var bluePen  = new Pen(Color.Blue, 3);
            var greenPen = new Pen(Color.Green, 4);

            using (var graphic = Graphics.FromImage(bmp))
            {
                graphic.DrawRectangle(bluePen, region.Location.X, region.Location.Y, region.Location.Width, region.Location.Height);
                graphic.DrawRectangle(greenPen, ocrLocation.X, ocrLocation.Y, ocrLocation.Width, ocrLocation.Height);
            }
            return(bmp);
        }
예제 #2
0
        public static List <OcrLine> GetLines2(List <OcrWord> words, OcrRegion region, ImageInfo info)
        {
            var lineId   = 1;
            var lines    = new List <OcrLine>();
            var horLines = new List <OcrLine>();

            //var horLines = Navigator.GetWordsHorizontallyAligned2(words, HorizontalLineMargin);
            foreach (var line in horLines)
            {
                line.ParentRegion = region;
                //line.Location.X = line.Words.Min(i => i.Location.X);
                //line.Location.Y = line.Words.Max(i => i.Location.Y);
                //line.Location.Height = line.Words.Max(i => i.Location.YBound) - line.Location.Y;
                //line.Location.Width = line.Words.Max(i => i.Location.XBound) - line.Location.X;
                line.Location = GetLocationFromElements(line.Words);
                line.Code     = OcrLoaderHelper.GetLineCode(lineId, region);
                lines.Add(line);
                lineId++;
            }
            return(lines);
        }
예제 #3
0
 public OcrLine()
 {
     Words        = new List <OcrWord>();
     ParentRegion = new OcrRegion();
 }