/* 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(); }
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(); }
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(); }