コード例 #1
0
        private void train_Click(object sender, EventArgs e)
        {
            //string line;
            //DirectoryInfo dir = new DirectoryInfo("E:/libbs");
            //dir.Create();
            //StreamReader file = new StreamReader("SystemLibPath.txt");
            //while ((line = file.ReadLine()) != null)
            //{
            //    Console.WriteLine(line);
            //    FileInfo f = new FileInfo(line);

            //    File.Copy(line, dir.FullName + "/" + f.Name);

            //}
            EDRIPMain.getInstance().loadPredictor();
            FolderBrowserDialog fbd    = new FolderBrowserDialog();
            DialogResult        result = fbd.ShowDialog();

            string[] files = { };
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                files = Directory.GetFiles(fbd.SelectedPath, "*", SearchOption.AllDirectories);
            }

            if (Methodology.SelectedIndex == 1)
            {
                EDRIPMainDistanceAndWrinkledBased.getInstance().TrainSystemForEmotionDistanceAndWrinkledBased(files);
            }

            else if (Methodology.SelectedIndex == 0)
            {
                EDRIPMainDistanceBased.getInstance().TrainSystemForEmotionDistancedBased(files);
            }
            else if (Methodology.SelectedIndex == 2)
            {
                EDRIPMainReducedDimensionsBased.getInstance().TrainSystemForEmotionReducedDimentionsBased(files);
            }
            else if (Methodology.SelectedIndex == 3)
            {
                OpticalflowViewTrain(files);
            }
            else if (Methodology.SelectedIndex == 4)
            {
                EDRIPHybridMethodologyBasedMain.getInstance().TrainSystemForEmotionHybrid(files);
            }
        }
コード例 #2
0
        private void Upload_Click(object sender, EventArgs e)
        {
            Stream fileStream = null;

            UploadImage.Multiselect = true;
            if ((UploadImage.ShowDialog() == DialogResult.OK) && (fileStream = UploadImage.OpenFile()) != null)
            {
                string   fileName = UploadImage.FileName;
                FileInfo file     = new FileInfo(UploadImage.FileName);
                Mat      ImageMat = new Mat(file.FullName);

                string emotions          = "";
                EmotionBusinessModel mod = new EmotionBusinessModel();
                if (Methodology.SelectedIndex == 1)
                {
                    mod = EDRIPMainDistanceAndWrinkledBased.getInstance().DetectEmotionsDistanceAndWrinkledBased(new Mat[] { ImageMat }, FDIPMAin.DetectFace(ImageMat));
                }

                else if (Methodology.SelectedIndex == 2)
                {
                    mod = EDRIPMainReducedDimensionsBased.getInstance().DetectEmotionsReducedDimentionsBased(new Mat[] { ImageMat });
                }
                //   emotions = EDRIPMainReducedDimensionsBased.getInstance().DetectEmotionsReducedDimentionsBased(new Mat[] { ImageMat }).outputResult;
                else if (Methodology.SelectedIndex == 3)
                {
                    OpticalflowView(UploadImage);
                    OpticalFlow.Visible = true;
                }
                else if (Methodology.SelectedIndex == 4)
                {
                    EDRIPHybridMethodologyBasedMain.getInstance().testSystemForEmotionHybrid(UploadImage.FileNames);
                }
                emotions = mod.outputMessage;
                CvInvoke.Resize(ImageMat, ImageMat, new Size(320, 240), 0, 0, Inter.Linear);
                Image <Bgr, byte> I2 = mod.images[0].image.ToImage <Bgr, byte>();
                GC.Collect();
                Logger log = new Logger();
                log.LogIntoFile(Log.logType.INFO, "message to be written");

                //  I2.Draw(emotions, new Point(10, 30), FontFace.HersheyPlain, 2.0, new Bgr(10, 0, 255));
                imageBox1.Image = I2;
            }
        }