public FeatureSet(FeatureSet other)
        {
            this.KeyPoints = new VectorOfKeyPoint();
            this.KeyPoints.Push(other.KeyPoints.ToArray());

            this.Descriptors = other.Descriptors.Clone();

            this.Allocated = other.Allocated;
        }
        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;
        }
Example #3
0
 abstract public bool Accept(FeatureSet FeatureSet, int Index);
        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsChanged)
            {
                foreach(var set in sets)
                {
                    if (set != null)
                    {
                        set.Update -= new EventHandler(update);
                    }
                }

                this.sets.Clear();

                foreach (var set in FInput)
                {
                    if (set != null)
                    {
                        set.Update += new EventHandler(update);
                        this.sets.Add(set);
                    }
                }

                FPerform = true;
            }

            if (FCriteria.IsChanged)
            {
                foreach (var criteria in criterias)
                {
                    if (criteria != null)
                        criteria.Update -= new EventHandler(update);
                }

                this.criterias.Clear();

                foreach (var criteria in FCriteria)
                {
                    if (criteria != null)
                    {
                        criteria.Update += new EventHandler(update);
                        this.criterias.Add(criteria);
                    }
                }

                FPerform = true;
            }

            if (FPerform)
            {
                FPerform = false;

                FOutput.SliceCount = SpreadMax;

                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FInput[i] == null)
                        FOutput[i] = null;
                    else
                        FOutput[i] = new FeatureSet(FInput[i], FCriteria[i]);
                }
            }
        }