Esempio n. 1
0
        public FeatureSet(FeatureSet other, ICriteria criteria)
        {
            var copy = new FeatureSet(other);

            this.KeyPoints   = copy.KeyPoints;
            this.Descriptors = copy.Descriptors;
            this.Allocated   = copy.Allocated;

            if (criteria == null)
            {
                return;
            }

            var keypoints   = new List <MKeyPoint>(this.KeyPoints.ToArray());
            var descriptors = new List <Matrix <float> >();

            int i = 0;

            while (i < keypoints.Count)
            {
                if (criteria.Accept(this, i))
                {
                    descriptors.Add(this.Descriptors.GetRow(i));
                    i++;
                }
                else
                {
                    keypoints.RemoveAt(i);
                }
            }

            this.KeyPoints.Clear();
            this.KeyPoints.Push(keypoints.ToArray());

            var newDescriptors = new Matrix <float>(descriptors.Count, this.Descriptors.Cols);

            for (int j = 0; j < descriptors.Count; j++)
            {
                for (int col = 0; col < this.Descriptors.Cols; col++)
                {
                    this.Descriptors[j, col] = descriptors[j][0, col];
                }
            }

            this.Descriptors = newDescriptors;
        }