Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13
AKAZE descriptors can only be used with KAZE or AKAZE keypoints. Try to avoid using *extract* and *detect* instead of *operator()* due to performance reasons. .. [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
Inheritance: Feature2D
コード例 #1
0
        public static string Execute(string imagePath)
        {
            var           img    = Cv2.ImRead(imagePath);
            List <string> result = new List <string>();
            List <KeyValuePair <string, double> > featureScores = new List <KeyValuePair <string, double> >();
            var features = IndexImages.GetFeatures();

            OpenCvSharp.AKAZE kaze = OpenCvSharp.AKAZE.Create();
            KeyPoint[]        keyPoints;
            Mat desc = new Mat();

            kaze.DetectAndCompute(img, null, out keyPoints, desc);

            foreach (var feature in features)
            {
                var train   = new Mat(feature.Rows, feature.Cols, feature.ImgType, feature.ImgData);
                var matches = GetMatches(desc, train);
                var score   = GetScore(matches);
                if (score == double.MaxValue)
                {
                    continue;
                }

                featureScores.Add(new KeyValuePair <string, double>(feature.Category, score));
            }

            return(featureScores.Count > 0 ? featureScores.OrderBy(x => (x.Value)).ToList()[0].Key : "Unknown");
        }
コード例 #2
0
        private static ExtractedFeature ExtractFeatures(string image)
        {
            Mat    img      = Cv2.ImRead(image);
            string category = Path.GetFileNameWithoutExtension(image).Split('.')[0];

            OpenCvSharp.AKAZE kaze = OpenCvSharp.AKAZE.Create();
            KeyPoint[]        keyPoints;
            Mat desc = new Mat();

            kaze.DetectAndCompute(img, null, out keyPoints, desc);
            ExtractedFeature result = new ExtractedFeature()
            {
                ImgData  = desc.ToBytes(),
                Cols     = desc.Cols,
                Rows     = desc.Rows,
                ImgType  = desc.Type(),
                Category = category
            };

            return(result);
        }