Exemple #1
0
        /// <summary>
        /// Match the Image feature from the observed image to the features from the model image, using brute force matcher
        /// </summary>
        /// <param name="observedFeatures">The Image feature from the observed image</param>
        /// <param name="k">The number of neighbors to find</param>
        /// <returns>The matched features</returns>
        public MatchedImageFeature[] MatchFeature(ImageFeature <TDescriptor>[] observedFeatures, int k)
        {
            VectorOfKeyPoint     obsKpts;
            Matrix <TDescriptor> observedDescriptors;

            ImageFeature <TDescriptor> .ConvertToRaw(observedFeatures, out obsKpts, out observedDescriptors);

            try
            {
                DistanceType dt = typeof(TDescriptor) == typeof(Byte) ? DistanceType.Hamming : DistanceType.L2;
                using (Matrix <int> indices = new Matrix <int>(observedDescriptors.Rows, k))
                    using (Matrix <float> dists = new Matrix <float>(observedDescriptors.Rows, k))
                        using (BruteForceMatcher <TDescriptor> matcher = new BruteForceMatcher <TDescriptor>(dt))
                        {
                            matcher.Add(_modelDescriptors);
                            matcher.KnnMatch(observedDescriptors, indices, dists, k, null);
                            return(ConvertToMatchedImageFeature(_modelKeyPoints, _modelDescriptors, obsKpts, observedDescriptors, indices, dists, null));
                        }
            }
            finally
            {
                obsKpts.Dispose();
                observedDescriptors.Dispose();
            }
        }
Exemple #2
0
 /// <summary>
 /// Create a Image tracker, where Image is matched with flann
 /// </summary>
 /// <param name="modelFeatures">The Image feature from the model image</param>
 public Features2DTracker(ImageFeature <TDescriptor>[] modelFeatures)
 {
     ImageFeature <TDescriptor> .ConvertToRaw(modelFeatures, out _modelKeyPoints, out _modelDescriptors);
 }