예제 #1
0
 private void addAllImagesToDBToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FBD = new FolderBrowserDialog();
     if (FBD.ShowDialog() == DialogResult.OK)
     {
         DirectoryInfo myFolder = new DirectoryInfo(FBD.SelectedPath);
         foreach (string filename in Directory.GetFiles(FBD.SelectedPath))
         {
             bitmap = new Bitmap(filename);
             hog    = new HistogramsOfOrientedGradients();
             hog.ProcessImage(bitmap);
             human = new Human();
             if (filename.Contains("image_human"))
             {
                 human.IsHuman = 1;
             }
             else
             {
                 human.IsHuman = 0;
             }
             line       = AuxiliaryFunctions.ToOneLine(hog.Histograms);
             byteArray  = AuxiliaryFunctions.DoubleArrayToByte(line);
             human.HOG  = byteArray;
             humanModel = new HumanModel();
             humanModel.Insert(human);
         }
     }
 }
예제 #2
0
        private void addAllImagesToDBToolStripMenuItem_Click(object sender, EventArgs e)
        {
            humanList = new List <Human>();
            if (FBD.ShowDialog() == DialogResult.OK)
            {
                DirectoryInfo myFolder = new DirectoryInfo(FBD.SelectedPath);
                fileCount = Directory.GetFiles(FBD.SelectedPath).Count();
                InitializeProgressBar();
                foreach (string filename in Directory.GetFiles(FBD.SelectedPath))
                {
                    bitmap = new Bitmap(filename);
                    hog    = new HistogramsOfOrientedGradients();
                    hog.ProcessImage(bitmap);
                    human = new Human();
                    if (filename.Contains("image_human"))
                    {
                        human.IsHuman = 1;
                    }
                    else
                    {
                        human.IsHuman = -1;
                    }
                    line      = AuxiliaryFunctions.ToOneLine(hog.Histograms);
                    byteArray = AuxiliaryFunctions.DoubleArrayToByte(line);
                    human.HOG = byteArray;

                    //XML file
                    humanList.Add(human);


                    index++;

                    if (index % (fileCount / 100) == 0)
                    {
                        progressValue++;
                        label1.Text = (progressValue + " %").ToString();
                        pb.Value    = progressValue <= 100?progressValue:100;
                        Thread.Sleep(10);
                    }
                }
                if (!File.Exists("Database.xml"))
                {
                    AuxiliaryFunctions.Serialize(humanList, "Database.xml");
                }
                else
                {
                    humanList.AddRange(AuxiliaryFunctions.Deserialize <List <Human> >("Database.xml"));
                    AuxiliaryFunctions.Serialize(humanList, "Database.xml");
                }
            }
        }