コード例 #1
0
        public void ToDebugConsole()
        {
            var xSize   = MaxX - MinX + 1;
            var ySize   = MaxY - MinY + 1;
            var boolArr = new bool[xSize, ySize];

            foreach (var c in Coords)
            {
                var x = c.X - MinX;
                var y = c.Y - MinY;
                boolArr[x, y] = true;
            }

            Boolean2DimArrayConverter.ToDebugLog(boolArr);
        }
コード例 #2
0
        private static IEnumerable <RecognizedCharData> SplitBySymbol(bool[,] image, bool onlyNumbers)
        {
            var ret = new List <RecognizedCharData>();

            var w = image.GetLength(0);
            var h = image.GetLength(1);

            var visited = new bool[w, h];

            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    var canBeVisited = !visited[i, j];
                    visited[i, j] = true;
                    if (!canBeVisited || !image[i, j])
                    {
                        continue;
                    }

                    var coordsData = VisitChar(i, j, visited, image);
                    VisitVertical(coordsData, visited, image);

                    // TODO debug
                    //coordsData.ToDebugConsole();

                    var charData = coordsData.ToRecognizedCharData();
                    var p        = charData.Pattern;
                    var xSize    = p.GetLength(0);
                    var ySize    = p.GetLength(1);
                    if (onlyNumbers && xSize > 7 && xSize > ySize + 1)
                    {
                        Debug.WriteLine($"Splitting too wide character (width: {xSize}, height: {ySize}):");
                        Boolean2DimArrayConverter.ToDebugLog(charData.Pattern);
                        SplitIn2Chars(ret, charData);
                    }
                    else
                    {
                        ret.Add(charData);
                    }

                    i += xSize - 1;
                    break;
                }
            }

            return(ret);
        }
コード例 #3
0
        private static IEnumerable <RecognizedCharData> SplitBySymbol(DirectBitmap db, bool onlyNumbers)
        {
            var ret = new List <RecognizedCharData>();

            var visited = new bool[db.Width, db.Height];

            for (int i = 0; i < db.Width; i++)
            {
                for (int j = 0; j < db.Height; j++)
                {
                    var canBeVisited = !visited[i, j];
                    visited[i, j] = true;
                    if (canBeVisited && IsNotBlank(db, i, j))
                    {
                        var coordsData = VisitChar(i, j, visited, db);
                        VisitVertical(coordsData, visited, db);
                        var charData = coordsData.ToRecognizedCharData();
                        var p        = charData.Pattern;
                        var xSize    = p.GetLength(0);
                        var ySize    = p.GetLength(1);
                        if (onlyNumbers && xSize > 7 && xSize > ySize + 1)
                        {
                            Debug.WriteLine($"Splitting too wide character (width: {xSize}, height: {ySize}):");
                            Boolean2DimArrayConverter.ToDebugLog(charData.Pattern);
                            SplitIn2Chars(ret, charData);
                        }
                        else
                        {
                            ret.Add(charData);
                        }
                    }
                }
            }

            return(ret);
        }