Beispiel #1
0
        public static void Main()
        {
            // Get the path and filename to process from the user.
            Console.WriteLine("Optical Character Recognition:");
            //Console.Write("Enter the path to an image with text you wish to read: ");
            string imageFilePath = INPUT_FILE;

            if (File.Exists(imageFilePath))
            {
                // Call the REST API method.
                Console.WriteLine("\nWait a moment for the results to appear.\n");
                var result = OcrProcessor.ProcessImage(imageFilePath).Result;

                foreach (var entry in result)
                {
                    Console.WriteLine($"{entry.Text,2} => TopLeft[{entry.BoundingBox.TopLeft.X},{entry.BoundingBox.TopLeft.Y}] TopRight[{entry.BoundingBox.TopRight.X},{entry.BoundingBox.TopRight.Y}] BottumRight[{entry.BoundingBox.BottumLeft.X},{entry.BoundingBox.BottomRight.Y}] BottomLeft[{entry.BoundingBox.BottumLeft.X},{entry.BoundingBox.BottumLeft.Y}]");
                }
            }
            else
            {
                Console.WriteLine("\nInvalid file path");
            }
            Console.WriteLine("\nPress Enter to exit...");
            Console.ReadLine();
        }
        private async void Window_Initialized(object sender, EventArgs e)
        {
            //Application.Current.MainWindow.WindowState = WindowState.Maximized;

            var result = await OcrProcessor.ProcessImage(@"c:\temp\sudoku.jpeg");

            foreach (var entry in result)
            {
                // Initialize a new Rectangle
                Rectangle r = new Rectangle();


                // Set up rectangle's size
                r.Width  = Math.Abs(entry.BoundingBox.TopRight.X - entry.BoundingBox.TopLeft.X);
                r.Height = Math.Abs(entry.BoundingBox.BottumLeft.Y - entry.BoundingBox.TopLeft.Y);

                // Set up the Background color
                //r.Fill = Brushes.Red;
                r.Stroke = new SolidColorBrush(Colors.Red);

                // Set up the position in the window, at mouse coordonate
                Canvas.SetTop(r, entry.BoundingBox.TopLeft.Y);
                Canvas.SetLeft(r, entry.BoundingBox.TopLeft.X);



                // Add rectangle to the Canvas
                cvDrawingArea.Children.Add(r);


                TextBlock textBlock = new TextBlock();
                textBlock.Foreground = new SolidColorBrush(Colors.Red);
                textBlock.Text       = entry.Text;
                textBlock.Width      = r.Width;
                textBlock.Height     = r.Height;
                textBlock.FontSize   = 32;

                Canvas.SetTop(textBlock, entry.BoundingBox.TopLeft.Y);
                Canvas.SetLeft(textBlock, entry.BoundingBox.TopLeft.X);

                cvDrawingArea.Children.Add(textBlock);
            }
        }
Beispiel #3
0
        public Bot()
        {
            _config = Config.Load(Strings.ConfigFileName);
            if (_config == null)
            {
                _logger.Error($"Failed to load config file.");
                return;
            }

            _client = new DiscordClient(new DiscordConfiguration
            {
                AutomaticGuildSync = true,
                AutoReconnect      = true,
                EnableCompression  = true,
                Token                 = _config.Token,
                TokenType             = TokenType.Bot,
                UseInternalLogHandler = true
            });
            _client.Ready          += Client_Ready;
            _client.MessageCreated += Client_MessageCreated;

            _ocrProcessor = new OcrProcessor(_client, _config);
        }