Ejemplo n.º 1
0
        public void SimilarityCalculation()
        {
            var screenshot = _calculatorSession.GetScreenshot();
            var options    = new SimilarityMatchingOptions {
                Visualize = true
            };

            var similarityResult = _calculatorSession.GetImagesSimilarity(screenshot.AsBase64EncodedString, screenshot.AsBase64EncodedString, options);

            Assert.Greater(similarityResult.Score, 0);
            Assert.IsNotNull(similarityResult.Visualization);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs images matching to calculate the similarity score between them.
        /// The flow there is similar to the one used in
        /// <see cref="FindImageOccurence(string, string, OccurenceMatchingOptions)"/>
        /// but it is mandatory that both images are of equal size.
        /// </summary>
        /// <param name="base64Image1">base64-encoded representation of the first image</param>
        /// <param name="base64Image2">base64-encoded representation of the second image</param>
        /// <param name="options">comparison options</param>
        /// <returns>Matching result. The configuration of fields in the result depends on comparison options.</returns>
        public SimilarityMatchingResult GetImagesSimilarity(string base64Image1, string base64Image2,
                                                            SimilarityMatchingOptions options = null)
        {
            var parameters = new Dictionary <string, object>()
            {
                { "mode", ComparisonMode.GetSimilarity },
                { "firstImage", base64Image1 },
                { "secondImage", base64Image2 },
            };

            if (options != null)
            {
                parameters.Add("options", options.GetParameters());
            }

            var result = Execute(AppiumDriverCommand.CompareImages, parameters);

            return(new SimilarityMatchingResult(result.Value as Dictionary <string, object>));
        }