﻿namespace ImageRecognition
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;

    public class ImageAnalyzer
    {
        public List<WordInfo> HorizontalWord(Bitmap bitmap)
        {
            ConnectedCoordinate coordinate = new ConnectedCoordinate();
            ImageLabeling labeling = new ImageLabeling();
            MatchCharacter character = new MatchCharacter();
            Word word = new Word();
            DateTime now = DateTime.Now;
            Dictionary<short, List<PixelPoint>> imageLabel = labeling.GetImageLabel(bitmap);
            DateTime time2 = DateTime.Now;
            TimeSpan span = (TimeSpan) (time2 - now);
            Console.WriteLine("execution time image labeling {0} ms", span.TotalMilliseconds);
            List<ConnectedPixel> connectedPixel = coordinate.GetConnectedPixel(bitmap, imageLabel);
            List<CharacterInfo> matchCharacter = character.GetMatchCharacter(connectedPixel);
            List<CharacterInfo> collection = character.MatchJoinedCharacter(connectedPixel);
            matchCharacter.AddRange(collection);
            return word.GetHorizontalWord(matchCharacter);
        }
    }
}

