예제 #1
0
        public static OcrResult PopulateMatrixFromImage(Image image)
        {
            Pix           pix    = LoadBitmapToPix(image as Bitmap);
            List <string> Cells  = GetCellsFromPix(pix);
            var           root   = (int)Math.Floor(Math.Sqrt(Cells.Count));
            var           result = new OcrResult(root);

            for (int cell = 0, row = 0; cell < Cells.Count; cell++)
            {
                if (cell % root == 0 && cell != 0)
                {
                    row++;
                }

                if (row == root)
                {
                    break;
                }

                result.SetCell(row, (int)Math.Floor((decimal)cell % root), Cells[cell]);
            }
            image.Dispose();
            pix.Dispose();

            return(result);
        }