Beispiel #1
0
        private async Task <OcrResult <TimeSpan> > GetTimerValue(Image <Rgba32> imageFragment, RaidImageConfiguration imageConfiguration, RaidImageFragmentType imageFragmentType)
        {
            imageFragment = imageConfiguration.PreProcessTimerFragment(imageFragment, imageFragmentType);
            var result = await GetOcrResultAsync(imageFragment);

            if (result.Value > 0 && TimeSpan.TryParse(result.Key, out TimeSpan timeSpan))
            {
                return(new OcrResult <TimeSpan>(true, result.Key,
                                                new[] { new KeyValuePair <TimeSpan, double>(timeSpan, result.Value) }));
            }
            return(new OcrResult <TimeSpan>(false, result.Key));
        }
Beispiel #2
0
        private async Task <OcrResult <TimeSpan> > GetTimerValue(Image <Rgba32> imageFragment, RaidImageConfiguration imageConfiguration, RaidImageFragmentType imageFragmentType)
        {
            imageFragment = imageConfiguration.PreProcessTimerFragment(imageFragment, imageFragmentType);
            var result = await GetOcrResultAsync(imageFragment);

            // Remove all characters which can not be part of a timespan
            var arr = result.Key.ToCharArray();

            arr = Array.FindAll(arr, (c => (char.IsDigit(c) || c == ':')));
            var stringCleaned = new string(arr);

            if (result.Value > 0 && TimeSpan.TryParse(stringCleaned, out TimeSpan timeSpan))
            {
                return(new OcrResult <TimeSpan>(true, stringCleaned,
                                                new[] { new KeyValuePair <TimeSpan, double>(timeSpan, result.Value) }));
            }
            return(new OcrResult <TimeSpan>(false, result.Key));
        }