Beispiel #1
0
        private void ImageTagging_Task(List <String> ImageList, bool ShowImages = false, String ImageOutputPath = "ImageTag", String DataOutputPath = "ImageData")
        {
            // MessageBox.Show();
            String DarknetDir   = Properties.Settings.Default.Darknet_Path;
            String WorkspaceDir = Properties.Settings.Default.ProjectDir;

            CmdProcess Proc = new CmdProcess(DarknetDir);

            foreach (String str in ImageList)
            {
                // Section to copy over image
                // String ImageCopyStartPath = Path.Combine(DarknetDir, "predictions.jpg");
                String ImageCopyEndPath = Path.Combine(WorkspaceDir, ImageOutputPath, Path.GetFileName(str));

                // Check if file already exists (Bounding rectangle output file)
                // String ResultFileStartPath = Path.Combine(DarknetDir, "result.json");
                String ResultFileEndPath = Path.Combine(WorkspaceDir, DataOutputPath, Path.GetFileName(str) + ".txt");

                if (ShowImages)
                {
                    Proc.AddToQueue(@"darknet.exe detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights -ext_output -out result.json " + str);
                    Proc.QueueCopy("predictions.jpg", ImageCopyEndPath);
                }
                else
                {
                    Proc.AddToQueue(@"darknet.exe detect cfg/yolov3.cfg weights/yolov3.weights -ext_output -dont_show -out result.json " + str);
                }
                Proc.QueueCopy("result.json", ResultFileEndPath);
            }
            Proc.ExecuteAndDispose();
        }
Beispiel #2
0
        /* Processes individual image entries one by one.
         * NOTE: There is an overhead for reading the weight file every iteration.
         * Route to the other async function to batch process files
         */
        private void Async_ImageTagging_Start()
        {
            String DarknetDir   = Properties.Settings.Default.Darknet_Path;
            String WorkspaceDir = Properties.Settings.Default.ProjectDir;

            CmdProcess Proc = new CmdProcess(DarknetDir);

            foreach (string str in ImageQueue)
            {
                // Section to copy over image
                String ImageCopyStartPath = Path.Combine(DarknetDir, "predictions.jpg");
                String ImageCopyEndPath   = Path.Combine(WorkspaceDir, "ImageTag", Path.GetFileName(str));

                // Check if file already exists (Bounding rectangle output file)
                String ResultFileStartPath = Path.Combine(DarknetDir, "output.txt");
                String ResultFileEndPath   = Path.Combine(WorkspaceDir, "ImageData", Path.GetFileName(str) + ".txt");

                if (ShowResultImage)
                {
                    Proc.AddToQueue(@"darknet.exe detect cfg/yolov3.cfg weights/yolov3.weights " + str);
                    Proc.QueueCopy(ImageCopyStartPath, ImageCopyEndPath);
                }
                else
                {
                    Proc.AddToQueue(@"darknet.exe detect cfg/yolov3.cfg -dont_show weights/yolov3.weights " + str);
                }
                Proc.QueueCopy(ResultFileStartPath, ResultFileEndPath);
            }
            Proc.ExecuteAndDispose();
        }
Beispiel #3
0
        // STEP 3
        private void ImageBatchProcessQueue_Task()
        {
            String DarknetDir   = Properties.Settings.Default.Darknet_Path;
            String QueueFileDir = Path.Combine(Properties.Settings.Default.ProjectDir, "ImageBatch", "ImageQueue.txt");
            String WorkspaceDir = Properties.Settings.Default.ProjectDir;
            String VideoName    = Path.GetFileName(VideoPath);

            CmdProcess Proc = new CmdProcess(DarknetDir);

            if (ShowResultImage)
            {
                Proc.AddToQueue(@"darknet.exe detect cfg/yolov3.cfg weights/yolov3.weights " + " > " + QueueFileDir);
                // Proc.QueueCopy(ImageCopyStartPath, ImageCopyEndPath);
            }
            else
            {
                Proc.AddToQueue(@"darknet.exe detect cfg/yolov3.cfg -dont_show weights/yolov3.weights " + " > " + QueueFileDir);
            }
            // Proc.QueueCopy(ResultFileStartPath, ResultFileEndPath);

            int    counter = 0;
            string line;


            System.Console.WriteLine("There were {0} lines.", counter);
            // Suspend the screen.
            System.Console.ReadLine();
        }
Beispiel #4
0
        private void TagImages_NeverShow_Task(String InputFile)
        {
            String DarknetDir        = Properties.Settings.Default.Darknet_Path;
            String WorkspaceDir      = Properties.Settings.Default.ProjectDir;
            String ResultFileEndPath = Path.Combine(WorkspaceDir, "VideoData", Path.GetFileName(VideoPath) + ".json");

            CmdProcess Proc2 = new CmdProcess(DarknetDir);

            Proc2.AddToQueue("type nul > " + ResultFileEndPath);
            Proc2.AddToQueue(@"darknet.exe detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights -ext_output -dont_show -out " + ResultFileEndPath + " < " + InputFile);
            Proc2.ExecuteAndDispose();
            Proc2.Dispose();
        }
Beispiel #5
0
        public static void TagVideo(String VideoPath, bool PreviewOutput = false)
        {
            String VideoOutputPath = Path.Combine(Properties.Settings.Default.ProjectDir, "TaggedVideos", Path.GetFileName(VideoPath));

            CmdProcess Proc = new CmdProcess(Properties.Settings.Default.Darknet_Path);

            Proc.AddToQueue(@"darknet.exe detector demo data/coco.data cfg/yolov3.cfg weights/yolov3.weights " + VideoPath + " -out_filename " + VideoOutputPath);
            Proc.ExecuteAndDispose();
        }
        public static void RunDOT(String filePath, String outputPath)
        {
            String CWD = Properties.Settings.Default.GraphViz_Path;

            CmdProcess Proc = new CmdProcess(CWD);

            Proc.AddToQueue("dot -Tpng " + filePath + " > " + outputPath);
            Proc.ExecuteAndDispose();
        }
Beispiel #7
0
        // STEP 2
        private void MakeImageQueueFileFromFolder_Task()
        {
            String CWD = Path.Combine(Properties.Settings.Default.ProjectDir, "ImageBatch");

            CmdProcess Proc = new CmdProcess(CWD);

            Proc.AddToQueue("dir /s/b *.jpg > ImageQueue.txt");
            Proc.Execute();
            Proc.Dispose();
        }
Beispiel #8
0
        // STEP 1
        private void GenerateImageBatch_Task()
        {
            String BatchOutputDir = API_FS.GetSpecialFolderPath(SpecialFolder.ImageBatch);

            CmdProcess Proc = new CmdProcess(Environment.CurrentDirectory);

            Proc.AddToQueue(@"VideoToImage.exe " + BatchOutputDir + " cap_video " + VideoPath + " " + FramesToDrop);
            Proc.ExecuteAndDispose();

            // PowerShell_Process.Invoke("", "Scripts/SampleVideo.ps1", VideoPath);
        }
Beispiel #9
0
        private void TagImages_NeverShow_Task(List <String> ImageList, String DataOutputPath = "ImageData")
        {
            String DarknetDir        = Properties.Settings.Default.Darknet_Path;
            String WorkspaceDir      = Properties.Settings.Default.ProjectDir;
            String ResultFileEndPath = Path.Combine(WorkspaceDir, DataOutputPath, "_Result.json");
            String ImageListDir      = Path.Combine(Environment.CurrentDirectory, "Resources/ImageList.txt");

            CmdProcess Proc = new CmdProcess(DarknetDir);

            Proc.AddToQueue("type nul > " + ImageListDir);
            Proc.AddToQueue("type nul > " + ResultFileEndPath);
            Proc.ExecuteAndDispose();
            Proc.Dispose();

            // Write the string array to a new file named "WriteLines.txt".
            using (StreamWriter outputFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "Resources", "ImageList.txt")))
            {
                foreach (string line in ImageList)
                {
                    outputFile.WriteLine(line);
                }
                outputFile.Close();
            }

            CmdProcess Proc2 = new CmdProcess(DarknetDir);

            Proc2.AddToQueue(@"darknet.exe detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights -ext_output -dont_show -out " + ResultFileEndPath + " < " + ImageListDir);
            Proc2.ExecuteAndDispose();
            Proc2.Dispose();

            // String ScriptPath = Path.Combine(Environment.CurrentDirectory, "Scripts/Darknet_ImageBatch.ps1");
            // Powershell_Custom cust = new Powershell_Custom(Properties.Settings.Default.Darknet_Path, ScriptPath);
            // cust.AddParameter("Images", ImageList);
            // cust.AddParameter("ImageListLoc", ImageListDir);
            // cust.AddParameter("OutputDataDir", ResultFileEndPath);
            // cust.Execute();
        }
Beispiel #10
0
        private void TagImages_AlwaysShow_Task(List <String> ImageList, String ImageOutputPath = "ImageTag", String DataOutputPath = "ImageData")
        {
            String DarknetDir   = Properties.Settings.Default.Darknet_Path;
            String WorkspaceDir = Properties.Settings.Default.ProjectDir;

            CmdProcess Proc = new CmdProcess(DarknetDir);

            foreach (String str in ImageList)
            {
                // Section to copy over image
                String ImageCopyStartPath = Path.Combine(DarknetDir, "predictions.jpg");
                String ImageCopyEndPath   = Path.Combine(WorkspaceDir, ImageOutputPath, Path.GetFileName(str));
                String ResultFileEndPath  = Path.Combine(WorkspaceDir, DataOutputPath, Path.GetFileName(str) + ".json");

                Proc.AddToQueue(@"darknet.exe detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights -ext_output -out " + ResultFileEndPath + " " + str);
                Proc.QueueCopy(ImageCopyStartPath, ImageCopyEndPath);
            }
            Proc.Execute();
            Proc.Dispose();
        }