Ejemplo n.º 1
0
        public bool AnyMatch(IMaskedGameImage gameImageSource, IReadOnlyList <GameImageMatchAction> actions)
        {
            var settings = settingsProvider.Get();

            foreach (var match in actions.SelectMany(x => x.ComparisonImages))
            {
                if (comparer.IsMatch(gameImageSource, match, settings.ImageMatchValuePercent))
                {
                    return(true);
                }
            }
            return(false);
        }
 private bool GetAndMatch(IMaskedGameImage gameImage, GameImageMatchActionType type, string splitName = null)
 {
     if (actionRepository.TryGet(type, out var split))
     {
         if (!string.IsNullOrEmpty(splitName))
         {
             split = split.Where(x => x.SplitName == splitName).ToList();
             if (split.Count == 0)
             {
                 return(false);
             }
         }
         if (actionMatcher.AnyMatch(gameImage, split))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public float GetMatchPercent(IMaskedGameImage gameImage, SplitComparisonImage splitImage)
        {
            try
            {
                if (gameImage.Image == null || splitImage.SourceImage == null)
                {
                    return(0);
                }
                //var difference = new Difference(splitImage.SourceImage);
                //var imageDiff = difference.Apply(gameImage.Frame);
                //var final = imageDiff;
                var image1 = gameImage.Image;
                var image2 = splitImage.SourceImage;

                ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);
                // compare two images
                TemplateMatch[] matchings = tm.ProcessImage(image1, image2);

                if (matchings.Length == 0)
                {
                    return(0);
                }

                //// check similarity level
                //if (matchings[0].Similarity > 0.97f)
                //{
                //    image1.Save("c:\\debug_image2.png", ImageFormat.Png);
                //    // do something with quite similar images
                //}

                return(matchings[0].Similarity);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
 public bool IsMatch(IMaskedGameImage gameImage, SplitComparisonImage splitImage, float minPercent)
 {
     return(GetMatchPercent(gameImage, splitImage) >= minPercent);
 }
 private bool GetAndMatchSplit(IMaskedGameImage gameImage, GameImageMatchActionType type)
 {
     return(GetAndMatch(gameImage, type, this.controller.CurrentSplitName));
 }