Action_Recognition_2._0.FeatureExtractor2D.ExtractTrainingData C# (CSharp) Метод

ExtractTrainingData() публичный Метод

public ExtractTrainingData ( string vidDir, string vidFileString, bool allFiles ) : void
vidDir string
vidFileString string
allFiles bool
Результат void
        public void ExtractTrainingData(string vidDir, string vidFileString, bool allFiles)
        {
            int margin = 5;
            int counter = 0;
            Random r = new Random();

            if (!allFiles)  //search for files matching a specific pattern, i.e. actioncliptrain*
            {
                vidFileString = vidFileString + "*";    //concatenate this into a search pattern so that get files returns only files that match
                TrainFiles = Directory.GetFiles(vidDir, vidFileString);    //get all the files beginning with vidFileString and anything following. Returns a string[]
            }
            else
                TrainFiles = Directory.GetFiles(vidDir);    //get all files in the specified directory. Returns a string[]

            Matrix X = new Matrix(SpatialSize * SpatialSize * TemporalSize, TrainFiles.Length * NumPatches);

            for (int i = 0; i < TrainFiles.Length; i++)     //load in each clip from the list of videos and perform convolution
            {
                Console.WriteLine("loading clip: {0}", TrainFiles[i]);
                Matrix[] M = LoadClip(TrainFiles[i]);
                int xDim = M[0].getColumnDimension();   //number of columns = x dimension
                int yDim = M[0].getRowDimension();      //number of rows = y dimension
                int tDim = M.Length;                    //number of 2D matrices in M = t dimension

                for (int j = 0; j < NumPatches; j++)    //convolution step
                {
                    int lowerBound = ++margin;
                    int upperBound = xDim - margin - SpatialSize + 1;
                    int xPos = r.Next(lowerBound, upperBound);          //unlabeled data, so pick a random x.......

                    upperBound = yDim - margin - SpatialSize + 1;
                    int yPos = r.Next(lowerBound, upperBound);          //....and a random y....

                    upperBound = tDim - TemporalSize + 1;
                    int tPos = r.Next(1, upperBound);                   //....and a random t within the image boundaries from which to extract features

                    Matrix[] block = GetBlock(M, xPos, yPos, tPos);
                    double[] reshapedBlock = Reshape(block, false);
                    SetColumn(X, counter, reshapedBlock);
                    counter++;
                }
            }
        }