コード例 #1
0
        /// <summary>
        /// Performs images matching by features. Read
        /// https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html
        /// for more details on this topic.
        /// </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>The matching result. The configuration of fields in the result depends on comparison options</returns>
        public FeaturesMatchingResult MatchImageFeatures(string base64Image1, string base64Image2,
                                                         FeaturesMatchingOptions options = null)
        {
            var parameters = new Dictionary <string, object>
            {
                { "mode", ComparisonMode.MatchFeatures },
                { "firstImage", base64Image1 },
                { "secondImage", base64Image2 }
            };

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

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

            return(new FeaturesMatchingResult(result.Value as Dictionary <string, object>));
        }
コード例 #2
0
        public void FeaturesMatching()
        {
            var screenshot = _calculatorSession.GetScreenshot();
            var options    = new FeaturesMatchingOptions {
                Visualize         = true,
                DetectorName      = "ORB",
                MatchFunc         = "BruteForce",
                GoodMatchesFactor = 40
            };

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

            Assert.IsNotNull(occurencesResult.Visualization);
            Assert.Greater(occurencesResult.TotalCount, 0);
            Assert.Greater(occurencesResult.Points1.Count, 0);
            Assert.Greater(occurencesResult.Points2.Count, 0);
            Assert.IsNotNull(occurencesResult.Rect1);
            Assert.IsNotNull(occurencesResult.Rect2);
        }