public bool ExportFolder(string path) { xmlFolder.Load(path); files = xmlFolder.GetAll(); foreach (string f in files) { ExporttoDB(f); } return(true); }
public static XmlFolder openFolder() { string[] arr = new string[0]; string path = ""; if (Properties.Settings.Default.last_path_to_cascades != "") { path = Properties.Settings.Default.last_path_to_cascades; } var dialog = new FolderBrowserDialog(); dialog.SelectedPath = path; if (dialog.ShowDialog() == DialogResult.OK) { path = dialog.SelectedPath; xmlFolder = new XmlFolder(); xmlFolder.Load(path); } return(xmlFolder); }
public MainForm() { InitializeComponent(); if ((Properties.Settings.Default.last_path_to_videos != "") && (Directory.Exists(Properties.Settings.Default.last_path_to_videos))) { vidFolder = new VideoFolder(); vidFolder.Load(Properties.Settings.Default.last_path_to_videos); lVideos_count.Text = "Found " + vidFolder.getCount(); tb_videos_path.Text = vidFolder.getPath(); } else { vidFolder = new VideoFolder(); } if (Properties.Settings.Default.last_path_for_images_to_save != "") { var path = Properties.Settings.Default.last_path_for_images_to_save; tb_images_to_save_path.Text = path; } if ((Properties.Settings.Default.last_path_for_images_to_detect != "") && (Directory.Exists(Properties.Settings.Default.last_path_for_images_to_detect))) { path_to_detect_images = Properties.Settings.Default.last_path_for_images_to_detect; tb_images_to_detect_path.Text = path_to_detect_images; folders_to_detect.Add(path_to_detect_images); foreach (string s in Directory.GetDirectories(path_to_detect_images)) { folders_to_detect.Add(s); } lFoldersToDetectCount.Text = folders_to_detect.Count.ToString(); images_count_to_detect = 0; foreach (string p in folders_to_detect) { string[] dirs = Directory.GetFiles(p, "*.jpg"); images_count_to_detect += dirs.Length; } lImagesToDetectCount.Text = images_count_to_detect.ToString(); } if (Properties.Settings.Default.last_path_to_cascades != "") { path_to_cascades = Properties.Settings.Default.last_path_to_cascades; if (path_to_cascades.Length != 0) { xmlFolder = new XmlFolder(); xmlFolder.Load(path_to_cascades); tb_cascade_path.Text = path_to_cascades; if (xmlFolder.GetCount() > 0) { lCascadeLoaded.Text = "Loaded " + xmlFolder.GetCount().ToString(); } else { lCascadeLoaded.Text = "Not Exists"; } tb_cascade_path.Text = Properties.Settings.Default.last_path_to_cascades; } else { lCascadeLoaded.Text = "Not loaded"; } } else { xmlFolder = new XmlFolder(); } if (Properties.Settings.Default.last_path_for_detected_images_to_save != "") { var path = Properties.Settings.Default.last_path_for_detected_images_to_save; tb_detected_images_to_save_path.Text = path; } if ((Properties.Settings.Default.last_path_to_learn_pictures != "") && (Directory.Exists(Properties.Settings.Default.last_path_to_learn_pictures))) { trainFolder = new ImageFolder(); trainFolder.Load(Properties.Settings.Default.last_path_to_learn_pictures); lLearn_count.Text = "Found " + trainFolder.GetCount(); tb_train_imgs_path.Text = trainFolder.GetPath(); } if ((Properties.Settings.Default.last_path_to_test_pictures != "") && (Directory.Exists(Properties.Settings.Default.last_path_to_test_pictures))) { testFolder = new ImageFolder(); testFolder.Load(Properties.Settings.Default.last_path_to_test_pictures); lTest_count.Text = "Found " + testFolder.GetCount(); tb_test_imgs_path.Text = testFolder.GetPath(); } if ((Properties.Settings.Default.last_path_to_pictures != "") && (Directory.Exists(Properties.Settings.Default.last_path_to_pictures))) { recognizeImageFolder = new ImageFolder(); recognizeImageFolder.Load(Properties.Settings.Default.last_path_to_pictures); lImages.Text = "Found " + recognizeImageFolder.GetCount(); tb_imgs_path.Text = recognizeImageFolder.GetPath(); } if (Properties.Settings.Default.last_path_to_results_save != "") { path_to_results_save = Properties.Settings.Default.last_path_to_results_save; if (Directory.Exists(path_to_results_save)) { tb_result_save_path.Text = path_to_results_save; } } if (Properties.Settings.Default.last_path_to_network != "") { lNetwork.Text = "exists"; var path = Properties.Settings.Default.last_path_to_network; tb_network_path.Text = path; network = new CNN(path); } else { network = new CNN(""); } //Properties.Settings.Default.is_opened_first_time = true; /*if (Properties.Settings.Default.is_opened_first_time) * { * MessageBox.Show("Hello new User"); * Properties.Settings.Default.is_opened_first_time = false; * Properties.Settings.Default.Save(); * }*/ }
private void btn_Haar_Detect_Click(object sender, EventArgs e) { if (tb_cascade_path.Text == "") { MessageBox.Show("Please choose path to folder with at least 1 cascade", "ERROR"); return; } if (!Directory.Exists(tb_cascade_path.Text)) { MessageBox.Show("Cascade Folder does not exists", "ERROR"); return; } xmlFolder.Load(tb_cascade_path.Text); if (xmlFolder.GetCount() == 0) { MessageBox.Show("Cascade Folder is empty", "ERROR"); return; } if (tb_images_to_detect_path.Text == "") { MessageBox.Show("Please choose path to image folder", "ERROR"); return; } if (!Directory.Exists(tb_images_to_detect_path.Text)) { MessageBox.Show("Image Folder does not exist", "ERROR"); return; } MessageBox.Show("Please Wait"); tb_images_to_detect_path.Text = path_to_detect_images; folders_to_detect.Clear(); folders_to_detect.Add(path_to_detect_images); foreach (string s in Directory.GetDirectories(path_to_detect_images)) { folders_to_detect.Add(s); } lFoldersToDetectCount.Text = folders_to_detect.Count.ToString(); int count = 0; foreach (string p in folders_to_detect) { string[] dirs = Directory.GetFiles(p, "*.jpg"); count += dirs.Length; } if (count == 0) { MessageBox.Show("No images to detect found", "ERROR"); lImagesToDetectCount.Text = "No images found"; return; } lImagesToDetectCount.Text = count.ToString(); if (!Directory.Exists(tb_detected_images_to_save_path.Text)) { MessageBox.Show("Save Folder does not exist", "ERROR"); return; } foreach (string path in folders_to_detect) { DetectFolder.DetectAll(path, xmlFolder.GetAll(), tb_detected_images_to_save_path.Text); } MessageBox.Show("Successfull"); }