Beispiel #1
0
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        ///
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        ///
        public object Clone()
        {
            HaarFeatureNode[][] newTrees = new HaarFeatureNode[Trees.Length][];

            for (int i = 0; i < newTrees.Length; i++)
            {
                HaarFeatureNode[] tree    = Trees[i];
                HaarFeatureNode[] newTree = newTrees[i] =
                    new HaarFeatureNode[tree.Length];

                for (int j = 0; j < newTree.Length; j++)
                {
                    newTree[j] = (HaarFeatureNode)tree[j].Clone();
                }
            }

            HaarCascadeStage r = new HaarCascadeStage();

            r.NextIndex   = NextIndex;
            r.ParentIndex = ParentIndex;
            r.Threshold   = Threshold;
            r.Trees       = newTrees;

            return(r);
        }
Beispiel #2
0
        private void writeTrees(HaarCascadeStage stage, int j)
        {
            writer.Write("            nodes.Add(new[] { ");

            // Assume trees have single node
            writeFeature(stage.Trees[j][0]);

            writer.WriteLine(" });");
        }
Beispiel #3
0
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        ///
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        ///
        public object Clone()
        {
            HaarCascadeStage[] newStages = new HaarCascadeStage[Stages.Length];
            for (int i = 0; i < newStages.Length; i++)
            {
                newStages[i] = (HaarCascadeStage)Stages[i].Clone();
            }

            HaarCascade r = new HaarCascade(Width, Height);

            r.HasTiltedFeatures = this.HasTiltedFeatures;
            r.Stages            = newStages;

            return(r);
        }
Beispiel #4
0
        private void writeStage(int i, HaarCascadeStage stage)
        {
            writer.WriteLine("            #region Stage {0}", i);
            writer.WriteLine("            stage = new HaarCascadeStage({0}, {1}, {2}); nodes = new List<HaarFeatureNode[]>();",
                             stage.Threshold.ToString("R", NumberFormatInfo.InvariantInfo),
                             stage.ParentIndex, stage.NextIndex);

            // Write stage trees
            for (int j = 0; j < stage.Trees.Length; j++)
            {
                writeTrees(stage, j);
            }

            writer.WriteLine("            stage.Trees = nodes.ToArray(); stages.Add(stage);");
            writer.WriteLine("            #endregion");
            writer.WriteLine();
        }