Пример #1
0
        private void AddMissingEntries(AnalysisOutput output)
        {
            var foundKeys = output.Issues.Select(i => i.RuleId).ToList();

            var notFoundKeys = AnalyzerTypes
                               .Select(t =>
                                       new
            {
                Type          = t,
                RuleAttribute = t.GetCustomAttribute <RuleAttribute>()
            })
                               .Select(rule =>
                                       RuleFinder.IsRuleTemplate(rule.Type)
                        ? string.Format(TemplateRuleIdPattern, rule.RuleAttribute.Key)
                        : rule.RuleAttribute.Key)
                               .Where(s => !foundKeys.Contains(s));

            foreach (var notFoundKey in notFoundKeys)
            {
                output.Issues.Add(new Issue
                {
                    RuleId = notFoundKey
                });
            }
        }
        public void CompareWorksWithIdenticalImages(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                AnalyzerType    = aType,
                BoundingBoxMode = bMode,
                Labeler         = lType
            });
            var result = target.Compare(FirstImage, FirstImage);

            result.Save(string.Format(OutputFormat, $"CompareWorksWithIdenticalImages_{aType}_{bMode}_{lType}"), SecondImage.RawFormat);
        }
        /// <summary>
        /// Creates the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="justNoticeableDifference">The just noticeable difference.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Unrecognized Difference Detection Mode: {type}</exception>
        public static IBitmapAnalyzer Create(AnalyzerTypes type, double justNoticeableDifference)
        {
            switch (type)
            {
            case AnalyzerTypes.ExactMatch:
                return(new ExactMatchAnalyzer());

            case AnalyzerTypes.CIE76:
                return(new CIE76Analyzer(justNoticeableDifference));

            default:
                throw new ArgumentException($"Unrecognized Difference Detection Mode: {type}");
            }
        }
Пример #4
0
        public void EqualsReturnsFalseWithNullSecondImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor   = Color.Red,
                BoundingBoxMode    = bMode,
                AnalyzerType       = aType,
                DetectionPadding   = 2,
                BoundingBoxPadding = 2,
                Labeler            = lType
            });
            var result = target.Equals(FirstImage, null);

            Assert.IsFalse(result);
        }
Пример #5
0
        public void CompareWorksWithDifferentImages(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor   = Color.Red,
                BoundingBoxMode    = bMode,
                AnalyzerType       = aType,
                DetectionPadding   = 2,
                BoundingBoxPadding = 2,
                Labeler            = lType
            });
            var result = target.Compare(FirstImage, SecondImage);

            result.Save(string.Format(OutputFormat, string.Format("CompareWorksWithDifferentImages_{0}_{1}_{2}", aType, bMode, lType)), SecondImage.RawFormat);
        }
        public void EqualsReturnsTrueWithNullImages(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor   = Color.Red,
                BoundingBoxMode    = bMode,
                AnalyzerType       = aType,
                DetectionPadding   = 2,
                BoundingBoxPadding = 2,
                Labeler            = lType
            });
            var result = target.Equals(null, null);

            result.ShouldBeTrue();
        }
        public void EqualsReturnsFalseWithDifferentImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor   = Color.Red,
                BoundingBoxMode    = bMode,
                AnalyzerType       = aType,
                DetectionPadding   = 2,
                BoundingBoxPadding = 2,
                Labeler            = lType
            });
            var result = target.Equals(FirstImage, SecondImage);

            result.ShouldBeFalse();
        }
Пример #8
0
        public void EqualsReturnsTrueWithSameImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor   = Color.Red,
                BoundingBoxMode    = bMode,
                AnalyzerType       = aType,
                DetectionPadding   = 2,
                BoundingBoxPadding = 2,
                Labeler            = lType
            });
            var newInstanceOfFirstImage = new Bitmap(TestImage1);
            var result = target.Equals(FirstImage, newInstanceOfFirstImage);

            Assert.IsTrue(result);
        }
Пример #9
0
 public Analyzer()
 {
     version      = 1.0;
     analyzerType = AnalyzerTypes.Standard;
 }