示例#1
0
        public void OccurencesLookup()
        {
            var screenshot = _calculatorSession.GetScreenshot();
            var options    = new OccurenceMatchingOptions {
                Visualize = true
            };

            var occurencesResult = _calculatorSession.FindImageOccurence(screenshot.AsBase64EncodedString, screenshot.AsBase64EncodedString, options);

            Assert.IsNotNull(occurencesResult.Rect);
            Assert.IsNotNull(occurencesResult.Visualization);
        }
示例#2
0
        /// <summary>
        /// Performs images matching by template to find possible occurrence of
        /// the partial image in the full image with default options. Read
        /// https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html
        /// for more details on this topic.
        /// </summary>
        /// <param name="fullImage">base64-encoded representation of the full image</param>
        /// <param name="partialImage">base64-encoded representation of the partial image</param>
        /// <param name="options">comparison options</param>
        /// <returns>The matching result. The configuration of fields in the result depends on comparison options.</returns>
        public OccurenceMatchingResult FindImageOccurence(string fullImage, string partialImage,
                                                          OccurenceMatchingOptions options = null)
        {
            var parameters = new Dictionary <string, object>
            {
                { "mode", ComparisonMode.MatchTemplate },
                { "firstImage", fullImage },
                { "secondImage", partialImage }
            };

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

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

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