예제 #1
0
        private void Start_Click(object sender, EventArgs e)
        {
            if ((int)CurrentLifeInp.Value > (int)LifeLevInp.Value)
            {
                OutPutBox.Text = "Curent life level should be less then wish level"; return;
            }
            stata = new string[2];
            OutPutBox.Clear();
            OutPutBox.Text = (++countElection) + " Election\n\n";
            j            = 0;
            activePeople = new ActivePeople((int)CurrentLifeInp.Value, (int)LifeLevInp.Value, (int)PopulationInp.Value);
            activePeople.CalcActive();
            election = new Election((int)CandidatesInp.Value, (int)ConditionsInp.Value, activePeople.GetActivePeople());
            CandidatesInp.Enabled  = false;
            PopulationInp.Enabled  = false;
            ConditionsInp.Enabled  = false;
            LifeLevInp.Enabled     = false;
            CurrentLifeInp.Enabled = false;
            timer1.Start();
            chart1.Series.Clear();
            for (int i = 0; i < (int)CandidatesInp.Value; i++)
            {
                chart1.Series.Add("Candidate " + (i + 1));
                chart1.Series[i].BorderWidth = 4;
                chart1.Series[i].ChartType   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
                chart1.Series[i].Points.AddXY(i, 0);
            }

            election.Run();
            //for(int i = 0; i< (int)CandidatesInp.Value;i++)
            //    Console.WriteLine(election.statistics.FinalVoices[i]+"kkkkkk");
            Start.Enabled = false;
            //countElection++;
        }
 private void ChannelSynthesis_Click(object sender, RoutedEventArgs e)
 {
     if (!WorkIng)
     {
         WorkIng = true;
         process = new Process();
         process.StartInfo.FileName  = $"{Environment.CurrentDirectory}/ChannelSynthesisByCPU.exe";
         process.StartInfo.Arguments = $"\"{OutPutPath}/Photo\"";
         //process.StartInfo.UseShellExecute = false;
         //process.StartInfo.RedirectStandardOutput = true;
         //process.StartInfo.CreateNoWindow = true;
         Cancel.IsEnabled = true;
         OutPutBox.Text   = "";
         task             = new Task(() =>
         {
             this.OutPutBox.Dispatcher.Invoke(new Action(() =>
             {
                 OutPutBox.AppendText("Alpha通道与RGB通道合成程序已启动,请等待");
                 OutPutBox.ScrollToEnd();
             }));
             process.Start();
             while (!process.HasExited)
             {
                 Thread.Sleep(100);
             }
             this.OutPutBox.Dispatcher.Invoke(new Action(() =>
             {
                 OutPutBox.Text = OutPutBox.Text + $"{Environment.NewLine}核心程序已退出";
                 OutPutBox.ScrollToEnd();
             }));
             if (Directory.Exists($"{OutPutPath}/Photo/OutPut"))
             {
                 Process.Start($"{OutPutPath}/Photo/OutPut");
             }
             if (CanCel)
             {
                 CanCel = false;
             }
             this.ChannelSynthesis.Dispatcher.Invoke(new Action(() =>
             {
                 ChannelSynthesis.IsEnabled = false;
             }));
             this.Cancel.Dispatcher.Invoke(new Action(() =>
             {
                 Cancel.IsEnabled = false;
             }));
             WorkIng = false;
         });
         task.Start();
     }
     else
     {
         MessageBox.Show("已有项目在运行,请等待");
     }
 }
예제 #3
0
        private void BeginWebCam()
        {
            if (webCam == null)
            {
                webCam = new VideoCapture();
            }

            webCam.ImageGrabbed += webCam_ImageGrabbed;
            webCam.Start();
            OutPutBox.AppendText($"WebCam Started...{Environment.NewLine}");
        }
예제 #4
0
 // DIVIDE BUTTON CLICKED
 private void Divide_Click(object sender, EventArgs e)
 {
     try
     {
         FirstNumber = Convert.ToDouble(OutPutBox.Text);
         OutPutBox.Clear();
         Operation = "/";
     }
     catch (FormatException)
     {
     }
 }
예제 #5
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            webCam.Retrieve(frame);
            var imageFrame = frame.ToImage <Gray, byte>();

            if (TimerCounter < TimeLimit)
            {
                TimerCounter++;

                if (imageFrame != null)
                {
                    var faces = faceDetection.DetectMultiScale(imageFrame, 1.3, 5);

                    if (faces.Count() > 0)
                    {
                        var processedImage = imageFrame.Copy(faces[0]).Resize(ProcessedImageWidth, ProcessedImageHeight, Emgu.CV.CvEnum.Inter.Cubic);
                        Faces.Add(processedImage);
                        IDs.Add(Convert.ToInt32(IdBox.Text));
                        ScanCounter++;
                        OutPutBox.AppendText($"{ScanCounter} Success Scan Taken... {Environment.NewLine}");
                        OutPutBox.ScrollToCaret();
                    }
                }
            }
            else
            {
                Mat[] faceImages = new Mat[Faces.Count];

                faceImages = Faces.Select(c => c.Mat).ToArray();

                faceRecognition.Train(faceImages, IDs.ToArray());
                faceRecognition.Write(YMLPath);
                timer.Stop();
                Trainbottom.Enabled = !Trainbottom.Enabled;
                IdBox.Enabled       = !IdBox.Enabled;

                OutPutBox.AppendText($"Training Complete!{Environment.NewLine}");
                MessageBox.Show("Training Completed!");

                PredictButton.Enabled = true;
            }
        }
 private void ResourcesRelease_Click(object sender, RoutedEventArgs e)
 {
     if (Directory.Exists(InPutPath) && !WorkIng)
     {
         WorkIng = true;
         process = new Process();
         process.StartInfo.FileName               = $"{Environment.CurrentDirectory}/ResourcesReleaseTool.exe";
         process.StartInfo.Arguments              = $"-t -i \"{InPutPath}\" -o \"{OutPutPath}\"";
         process.StartInfo.UseShellExecute        = false;
         process.StartInfo.RedirectStandardOutput = true;
         process.StartInfo.CreateNoWindow         = true;
         //process.StartInfo.StandardOutputEncoding = Encoding.ASCII;
         process.Start();
         Cancel.IsEnabled = true;
         OutPutBox.Text   = "";
         task             = new Task(() =>
         {
             while (!process.HasExited)
             {
                 string buffer = process.StandardOutput.ReadLine();
                 this.OutPutBox.Dispatcher.Invoke(new Action(() =>
                 {
                     OutPutBox.AppendText(buffer + Environment.NewLine);
                     OutPutBox.ScrollToEnd();
                 }));
             }
             this.OutPutBox.Dispatcher.Invoke(new Action(() =>
             {
                 OutPutBox.AppendText($"{Environment.NewLine}核心程序已退出");
                 OutPutBox.ScrollToEnd();
             }));
             if (Directory.Exists($"{OutPutPath}/Photo"))
             {
                 Process.Start($"{OutPutPath}/Photo");
             }
             if (CanCel)
             {
                 CanCel = false;
             }
             else
             {
                 this.ChannelSynthesis.Dispatcher.Invoke(new Action(() =>
                 {
                     ChannelSynthesis.IsEnabled = true;
                 }));
             }
             this.Cancel.Dispatcher.Invoke(new Action(() =>
             {
                 Cancel.IsEnabled = false;
             }));
             WorkIng = false;
         });
         task.Start();
     }
     else if (WorkIng)
     {
         MessageBox.Show("已有项目在运行,请等待");
     }
     else
     {
         MessageBox.Show("源目录不正确");
     }
 }
예제 #7
0
 // C BUTTON CLICKED
 private void ClearButton_Click(object sender, EventArgs e)
 {
     OutPutBox.Clear();
 }