예제 #1
0
        static void Main(string[] args)
        {
            List <Video> videos = FileOperations.ReadDatabaseRandomly(Parameters.TrainPath, Parameters.NumVideosEachTree);
            //FileOperations.WriteVideos(videos, @"C:\Users\Celebi\Desktop\A");
            List <Video> motionVideos = ImageOperations.CreateMotions(videos);

            //FileOperations.WriteVideos(motionVideos, @"C:\Users\Celebi\Desktop\B");

            motionVideos.CreateIntegralVideos();

            Tube   tb      = new Tube(99);
            double result1 = motionVideos[0].GetVolume(new Tube(99));

            Console.WriteLine(result1);

            //for (int i = tb.Index; i < tb.Index + tb.Length; i++) {
            //    for(int j = tb.Rect.
            //}

            //using (StreamWriter writer = File.CreateText(Parameters.GlobalLogPath))
            //{
            //    writer.WriteLine(Parameters.Log());
            //}

            //Forest fr = new Forest();

            //using (StreamWriter writer = File.AppendText(Parameters.GlobalLogPath))
            //{
            //    writer.WriteLine();
            //    writer.WriteLine("Finished at: " + DateTime.Now);
            //}
        }
예제 #2
0
        private DecisionNode[] Split(Tube tb)
        {
            this.Branches = new DecisionNode[2];

            List <Video>[] partitions = new List <Video> [2];
            partitions[0] = new List <Video>();
            partitions[1] = new List <Video>();

            for (int i = 0; i < this.Inputs.Count; i++)
            {
                if (this.Inputs[i].ApplyTube(tb))
                {
                    partitions[0].Add(this.Inputs[i]);
                }
                else
                {
                    partitions[1].Add(this.Inputs[i]);
                }
            }

            if (partitions[0].Count == 0 || partitions[1].Count == 0)
            {
                return(null);
            }

            this.Branches[0] = new DecisionNode(this.Owner, this, partitions[0]);
            this.Branches[1] = new DecisionNode(this.Owner, this, partitions[1]);

            this.Inputs       = null;
            this.SplitFeature = tb;

            return(this.Branches);
        }
예제 #3
0
        private Tube[] CreateFeatureCandidates()
        {
            Tube[] rVal = new Tube[Parameters.UsedFeatureCountAtEveryNode];

            for (int i = 0; i < Parameters.UsedFeatureCountAtEveryNode; i++)
            {
                rVal[i] = new Tube(199);
            }
            return(rVal);
        }
예제 #4
0
        public DecisionNode[] Split()
        {
            if (this.Level > Parameters.MaxDepth)
            {
                return(null);
            }

            Tube[] features = CreateFeatureCandidates();
            Tube   bestTube = GetBestFeature(features);

            return(Split(bestTube));
        }
예제 #5
0
        public static double GetBestDistance(double[] volumes, Tube feature)
        {
            double rVal = 0;

            int    counter = 0;
            double diff    = double.MaxValue;

            double mid = volumes.Average(); // best place to start

            double mean0, mean1;

            List <double>[] parts = new List <double> [2];
            parts[0] = new List <double>();
            parts[1] = new List <double>();

            do
            {
                for (int i = 0; i < volumes.Length; i++)
                {
                    if (volumes[i] < mid)
                    {
                        parts[0].Add(volumes[i]);
                    }
                    else
                    {
                        parts[1].Add(volumes[i]);
                    }
                }

                mean0 = parts[0].Count > 0 ? parts[0].Average() : 0;
                mean1 = parts[1].Count > 0 ? parts[1].Average() : 0;

                mid = (mean0 + mean1) / 2;
                feature.Threshold = mid;

                rVal = mean1 - mean0;

                counter++;
            }while (counter < 4 && diff > Parameters.DiffThreshold);

            rVal = rVal / feature.NormalizationScalar;

            return(rVal);
        }