Example #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);
         }
     }
 }
Example #2
0
        public static bool CompareHOG(double[, ][] hogHist)
        {
            double[, ][] hogHistogram = hogHist;
            double[]     line         = AuxiliaryFunctions.ToOneLine(hogHistogram);
            double       percent      = SVM.Probability(line);
            bool         isHuman      = percent >= 0.5;

            if (isHuman)
            {
                tuple.Add(Tuple.Create(Counter, percent, isHuman, cropRect));
            }
            return(isHuman);
        }
Example #3
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");
                }
            }
        }
Example #4
0
        public static void AllPassesOfWindow(System.Drawing.Image src, int step)
        {
            tuple.Clear();
            progressValue = 0;
            Counter       = 0;
            Counter       = 0;
            int width  = 64;
            int height = 128;

            while (width < src.Width && height < src.Height)
            {
                OnePassOfWindow(src, width, height, step);

                width  = (int)Math.Round(width * 1.5);
                height = (int)Math.Round(height * 1.5);
            }
            tuple = tuple.OrderByDescending(x => x.Item2).ToList();
            AuxiliaryFunctions.WritePercentage(tuple.ToArray(), @"Output\percentage.txt");
        }
Example #5
0
        private void trainHumansToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            //XML file
            humanList   = new List <Human>();
            humanList   = AuxiliaryFunctions.Deserialize <List <Human> >("Database.xml");
            trainArray  = new double[humanList.Count][];
            outputArray = new double[humanList.Count];
            fileCount   = humanList.Count;
            InitializeProgressBar();
            for (int i = 0; i < humanList.Count; i++)
            {
                trainArray[i]  = AuxiliaryFunctions.ByteArrayToDouble(humanList[i].HOG);
                outputArray[i] = humanList[i].IsHuman;
                index++;

                if (index % (fileCount / 100) == 0)
                {
                    progressValue++;
                    label1.Text = (progressValue + " %").ToString();
                    pb.Value    = progressValue <= 100 ? progressValue : 100;
                    Thread.Sleep(10);
                }
            }
            //trainArray = humanList.Select(x => AuxiliaryFunctions.ByteArrayToDouble(x.HOG)).ToArray();
            //outputArray = humanList.Select(x => (double)x.IsHuman).ToArray();

            var teacher = new SequentialMinimalOptimization <Gaussian>()
            {
                UseComplexityHeuristic = true,
                UseKernelEstimation    = true
            };
            SupportVectorMachine <Gaussian> svm = teacher.Learn(trainArray, outputArray);

            resultLine = svm.Weights;
            AuxiliaryFunctions.WriteWeight(resultLine, "weight.txt");
            AuxiliaryFunctions.MakeSerialization(svm, "SVM_G.xml");
        }