コード例 #1
0
        private void InitTrainButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(selected_file) && DataSetNameField.Text != "Enter DataSet Name")
                {
                    Console.WriteLine("Processing Images...");

                    string[] files = Directory.GetFiles(selected_file);

                    Objects.DataSet new_dataset = new Objects.DataSet()
                    {
                        NumImages           = files.Length,
                        Trained             = false,
                        NumImagesNotPlastic = files.Length,
                        NumImagesPlastic    = files.Length,
                        Name = DataSetNameField.Text
                    };

                    Console.WriteLine("Images Added To Set...");

                    dataset_db.DataSets.Add(new_dataset);

                    dataset_db.SaveChanges();

                    Console.WriteLine("Images Copying To Local Folder...");

                    ImageHelper.addImagesToSet(selected_file, new_dataset);

                    MessageBox.Show("DataSet created");

                    this.Close();
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(selected_file) && DataSetNameField.Text == "Enter DataSet Name")
                    {
                        MessageBox.Show("Please select a folder and a name for the DataSet");
                    }
                    else if (string.IsNullOrWhiteSpace(selected_file))
                    {
                        MessageBox.Show("Please select a folder");
                    }
                    else
                    {
                        MessageBox.Show("Please select a name");
                    }
                }
            } catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            finally
            {
                this.Close();
            }
        }
コード例 #2
0
 private void DataSetListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         selected_dataset    = (Objects.DataSet)DataSetListBox.SelectedItem;
         selected_dataset_id = selected_dataset.Id;
         if (!selected_dataset.Trained)
         {
             SelectedDataSetField.Text = "Selected DataSet needs training!";
         }
         else if (selected_dataset.Trained)
         {
             SelectedDataSetField.Text = selected_dataset.Name + "; #Image in set: " + selected_dataset.NumImages;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }