Exemple #1
0
        private static List <RowAsText> Ocr(Image image, IEnumerable <Row> rowHolder)
        {
            var source            = new Bitmap(image);
            var currentTextValues = new List <RowAsText>();
            var rowbmpholder      = rowHolder.Select(rownum => new RowBmpHolder
            {
                GoodsName =
                    source.Clone(rownum.RowTop, 0, 303 * source.Width / 1000, rownum.RowBottom - rownum.RowTop).ResizeBmp(),
                SellPrice =
                    source.Clone(rownum.RowTop, 308 * source.Width / 1000, 80 * source.Width / 1000,
                                 rownum.RowBottom - rownum.RowTop)
                    .ResizeBmp(),
                BuyPrice =
                    source.Clone(rownum.RowTop, 381 * source.Width / 1000, 71 * source.Width / 1000,
                                 rownum.RowBottom - rownum.RowTop)
                    .ResizeBmp(),

                NumSupply =
                    source.Clone(rownum.RowTop, 684 * source.Width / 1000, 90 * source.Width / 1000,
                                 rownum.RowBottom - rownum.RowTop)
                    .ResizeBmp(),

                GalacticAverage =
                    source.Clone(rownum.RowTop, 851 * source.Width / 1000, 152 * source.Width / 1000,
                                 rownum.RowBottom - rownum.RowTop)
                    .ResizeBmp()
            }).ToList();

            foreach (var temp in rowbmpholder)
            {
                var tesseract = new RowAsText();

                temp.GoodsName.Save(@"c:\ocrtest\GoodsName.Tiff", ImageFormat.Tiff);
                tesseract.GoodsName = InterfaceOcr.GetText(@"c:\ocrtest\GoodsName.Tiff");
                @"c:\ocrtest\GoodsName.Tiff".TryToDelete();

                temp.SellPrice.Save(@"c:\ocrtest\SellPrice.Tiff", ImageFormat.Tiff);
                tesseract.SellPrice = InterfaceOcr.GetText(@"c:\ocrtest\SellPrice.Tiff");
                @"c:\ocrtest\SellPrice.Tiff".TryToDelete();

                temp.BuyPrice.Save(@"c:\ocrtest\BuyPrice.Tiff", ImageFormat.Tiff);
                tesseract.BuyPrice = InterfaceOcr.GetText(@"c:\ocrtest\BuyPrice.Tiff");
                @"c:\ocrtest\BuyPrice.Tiff".TryToDelete();

                temp.NumSupply.Save(@"c:\ocrtest\NumSupply.Tiff", ImageFormat.Tiff);
                tesseract.NumSupply = InterfaceOcr.GetText(@"c:\ocrtest\NumSupply.Tiff");
                @"c:\ocrtest\NumSupply.Tiff".TryToDelete();

                temp.GalacticAverage.Save(@"c:\ocrtest\x.Tiff", ImageFormat.Tiff);
                tesseract.GalacticAverage = InterfaceOcr.GetText(@"c:\ocrtest\x.Tiff");
                @"c:\ocrtest\x.Tiff".TryToDelete();

                currentTextValues.Add(tesseract);
            }


            return(currentTextValues);
        }
Exemple #2
0
        private DataGridViewRow MakeNewDataGridViewRow(RowAsText x)
        {
            var row = new DataGridViewRow();

            row.CreateCells(dg_OCRRows, Systemname, Stationname, x.GoodsName, x.SellPrice, x.BuyPrice, x.NumSupply,
                            x.GalacticAverage);
            row.DefaultCellStyle.BackColor          = Color.Black;
            row.DefaultCellStyle.ForeColor          = Color.FromArgb(255, 255, 128, 0);
            row.DefaultCellStyle.Font               = new Font("Eurostile", 10, FontStyle.Regular);
            row.DefaultCellStyle.SelectionBackColor = Color.Red;
            return(row);
        }
Exemple #3
0
        private static void GridviewDisplayedDataCleanUp(RowAsText x, ConsumerItemsList productlist)
        {
            x.GoodsName = productlist.ReturnMostSimilarWord(x.GoodsName);

            if (x.SellPrice == "")
            {
                x.SellPrice = "0";
            }
            if (x.BuyPrice == "")
            {
                x.BuyPrice = "0";
            }

            if (x.NumSupply == "")
            {
                x.NumSupply = "0";
            }
            if (x.GalacticAverage == "")
            {
                x.GalacticAverage = "0";
            }
        }