Exemplo n.º 1
0
        public static void TestExtractFrame()
        {
            string dataPath = @"C:\research\dataset\TomLaPorta\";

            string[] files = Directory.GetFiles(dataPath);
            foreach (string f in files)
            {
                string   fn           = URIUtilities.filenameFromDirectory(f);
                string[] ff           = fn.Split('.');
                string   fname        = ff[0];
                string   outputFolder = dataPath + fname + "\\";
                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }
                FFMpegWrappers.ExtractFrames(ffmpeg, f,
                                             outputFolder, fname, DateTime.MinValue, 0.1);
            }
        }
Exemplo n.º 2
0
        //public static void GroupFramesIntoChunksAndUploadChunks(string videoName, string CurrentDir, int noFramePerChunk, int noFramesOverlap, string satyamContainerName, string satyamDirectoryName)
        //{
        //    SatyamJobStorageAccountAccess satyamStorage = new SatyamJobStorageAccountAccess();
        //    List<string> files = Directory.GetFiles(CurrentDir).ToList();
        //    int chunkSequence = 0;
        //    List<List<string>> allFilesPerChunk = new List<List<string>>();
        //    for(int i=0;i<files.Count;i++)
        //    {

        //        int index = (int)Math.Ceiling((double)(i + 1) / (double)noFramePerChunk);
        //        if ( index > chunkSequence)
        //        {

        //            allFilesPerChunk.Add(new List<string>());
        //            chunkSequence++;
        //            if (chunkSequence > 1)
        //            {
        //                //starting the 2nd chunk, add frames before
        //                for (int j = 0; j < noFramesOverlap; j++)
        //                {
        //                    allFilesPerChunk[chunkSequence-1].Add(files[i - noFramesOverlap + j]);
        //                }
        //            }
        //        }
        //        allFilesPerChunk[index - 1].Add(files[i]);
        //    }
        //    for (int i = 0; i < allFilesPerChunk.Count; i++)
        //    {
        //        string subDir = CurrentDir + "\\" + i;
        //        Directory.CreateDirectory(subDir);
        //        foreach(string file in allFilesPerChunk[i])
        //        {
        //            string fileName = URIUtilities.filenameFromDirectory(file);
        //            File.Copy(file, subDir + "\\" + fileName);
        //        }
        //        satyamStorage.uploadALocalFolder(subDir, satyamContainerName, satyamDirectoryName +"/Video_" + videoName + "_startingFrame_" + noFramePerChunk * i);
        //    }
        //}

        public static List <string> GroupFramesIntoChunks(string CurrentDir, int noFramePerChunk, int noFramesOverlap = 0)
        {
            List <string>         files            = Directory.GetFiles(CurrentDir).ToList();
            int                   chunkSequence    = 0;
            List <List <string> > allFilesPerChunk = new List <List <string> >();

            for (int i = 0; i < files.Count; i++)
            {
                int index = (int)Math.Ceiling((double)(i + 1) / (double)noFramePerChunk);
                if (index > chunkSequence)
                {
                    allFilesPerChunk.Add(new List <string>());
                    chunkSequence++;
                    if (chunkSequence > 1)
                    {
                        //starting the 2nd chunk, add frames before
                        for (int j = 0; j < noFramesOverlap; j++)
                        {
                            allFilesPerChunk[chunkSequence - 1].Add(files[i - noFramesOverlap + j]);
                        }
                    }
                }
                allFilesPerChunk[index - 1].Add(files[i]);
            }

            List <string> chunkFolders = new List <string>();

            for (int i = 0; i < allFilesPerChunk.Count; i++)
            {
                string subDir = CurrentDir + "\\" + i;
                Directory.CreateDirectory(subDir);
                chunkFolders.Add(subDir);
                foreach (string file in allFilesPerChunk[i])
                {
                    string fileName = URIUtilities.filenameFromDirectory(file);
                    File.Copy(file, subDir + "\\" + fileName);
                }
            }

            return(chunkFolders);
        }