コード例 #1
0
        private void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            //Get the current frame form capture device
            Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();

            currentFrame    = bitmap.ToImage <Bgr, byte>().Resize(320, 240, Inter.Cubic);
            camViewer.Image = currentFrame.Convert <Bgr, byte>().ToBitmap();
            //show the user what the camera is seeing

            //convert the image into a format readable by the recogniser
            grayFrame = currentFrame.Convert <Gray, byte>();

            //Convert it to Grayscale
            if (grayFrame != null)
            {
                //Face Detector
                Rectangle[] facesDetected = cascadeClassifier.DetectMultiScale(grayFrame);

                //Action for each element detected
                for (int i = 0; i < facesDetected.Length; i++)// (Rectangle face_found in facesDetected)
                {
                    capturedSamples++;
                    //This will focus in on the face from the haar results its not perfect but it will remove a majoriy
                    //of the background noise
                    facesDetected[i].X      += (int)(facesDetected[i].Height * 0.15);
                    facesDetected[i].Y      += (int)(facesDetected[i].Width * 0.22);
                    facesDetected[i].Height -= (int)(facesDetected[i].Height * 0.3);
                    facesDetected[i].Width  -= (int)(facesDetected[i].Width * 0.35);

                    result = grayFrame.Copy(facesDetected[i]).Resize(100, 100, Inter.Cubic);
                    result._EqualizeHist();
                    //camViewer.Image = result.ToBitmap();
                    //draw the face detected in the 0th (gray) channel with blue color
                    currentFrame.ROI = facesDetected[i];
                    resultImages.Add(result.Mat);
                    faceLabels.Add(0);
                    capturedSamples++;
                    if (capProgress.InvokeRequired && capProgress.Value < capProgress.Maximum)
                    {
                        capProgress.Invoke(mi);
                    }
                    else if (capProgress.Value < capProgress.Maximum)
                    {
                        mi.Invoke();
                    }

                    if (capturedSamples == 1000)
                    {
                        CloseMethod method = new CloseMethod(CloseForm);
                        this.BeginInvoke(method);
                    }
                }
            }
        }
コード例 #2
0
 private void checkPassword()
 {
     if (passWrdBx.Text == Resources.Pasword)
     {
         CloseMethod method = new CloseMethod(CloseForm);
         this.BeginInvoke(method);
     }
     else
     {
         this.passWrdBx.Text = "";
     }
 }
コード例 #3
0
 static private void CloseForm(Form form)
 {
     if (!form.IsDisposed)
     {
         if (form.InvokeRequired)
         {
             CloseMethod method = new CloseMethod(CloseForm);
             form.Invoke(method, new object[] { form });
         }
         else
         {
             form.Close();
         }
     }
 }
コード例 #4
0
        private void ZScreen_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Save Destinations
            if (Engine.ConfigUI != null)
            {
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbOutputs, Engine.ConfigUI.ConfOutputs);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbLinkFormat, Engine.ConfigUI.ConfLinkFormat);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbClipboardContent, Engine.ConfigUI.ConfClipboardContent);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestImage, Engine.ConfigUI.MyImageUploaders);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestFile, Engine.ConfigUI.MyFileUploaders);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestText, Engine.ConfigUI.MyTextUploaders);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestLink, Engine.ConfigUI.MyURLShorteners);
            }

            // If UserClosing && ZScreenCloseReason.None then this means close button pressed in title bar
            if (e.CloseReason == CloseReason.UserClosing && CloseMethod == CloseMethod.None)
            {
                if (Engine.ConfigApp.WindowButtonActionClose == WindowButtonAction.ExitApplication)
                {
                    CloseMethod = CloseMethod.CloseButton;
                }
                else if (Engine.ConfigApp.WindowButtonActionClose == WindowButtonAction.MinimizeToTaskbar)
                {
                    WindowState = FormWindowState.Minimized;
                    e.Cancel    = true;
                }
                else if (Engine.ConfigApp.WindowButtonActionClose == WindowButtonAction.MinimizeToTray)
                {
                    Hide();
                    DelayedTrimMemoryUse();
                    if (Engine.ConfigOptions.AutoSaveSettings)
                    {
                        Engine.WriteSettingsAsync();
                    }
                    e.Cancel = true;
                }
            }

            // If really ZScreen is closing
            if (!e.Cancel)
            {
                DebugHelper.WriteLine("ZScreen_FormClosing - CloseReason: {0}, CloseMethod: {1}", e.CloseReason,
                                      CloseMethod);
                Engine.WriteSettings();
                Engine.TurnOff();
            }
        }
コード例 #5
0
 private void CloseForm()
 {
     cam.Stop();
     cam.NewFrame -= Cam_NewFrame;
     if (!this.IsDisposed)
     {
         if (this.InvokeRequired)
         {
             CloseMethod method = new CloseMethod(CloseForm);
             this.Invoke(method);
         }
         else
         {
             this.Close();
         }
     }
 }
コード例 #6
0
 private void CloseForm()
 {
     cam.Stop();
     cam.NewFrame -= Cam_NewFrame;
     if (!this.IsDisposed)
     {
         if (this.InvokeRequired)
         {
             CloseMethod method = new CloseMethod(CloseForm);
             this.Invoke(method);
         }
         else
         {
             trainRecogniser();
             Console.WriteLine("Form is now closing");
             MessageBox.Show("Done! Form will now close");
             this.Close();
         }
     }
 }
コード例 #7
0
        private void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            //Get the current frame form capture device
            Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();

            currentFrame = bitmap.ToImage <Bgr, byte>().Resize(320, 240, Inter.Cubic);
            grayFrame    = currentFrame.Convert <Gray, byte>();

            //Convert it to Grayscale
            if (grayFrame != null)
            {
                //Face Detector
                Rectangle[] facesDetected = classifier.DetectMultiScale(grayFrame);
                //Action only for most promissing detection
                for (int i = 0; i < facesDetected.Length; i++)// (Rectangle face_found in facesDetected)
                {
                    //This will focus in on the face from the haar results its not perfect but it will remove a majoriy
                    //of the background noise
                    facesDetected[0].X      += (int)(facesDetected[0].Height * 0.15);
                    facesDetected[0].Y      += (int)(facesDetected[0].Width * 0.22);
                    facesDetected[0].Height -= (int)(facesDetected[0].Height * 0.3);
                    facesDetected[0].Width  -= (int)(facesDetected[0].Width * 0.35);
                    result = grayFrame.Copy(facesDetected[0]).Resize(100, 100, Inter.Cubic);
                    result._EqualizeHist();
                    foreach (FaceRecognizer recogniser in recognisers)
                    {
                        if (recogniser.Predict(result).Label == 0)
                        {
                            CloseMethod method = new CloseMethod(CloseForm);
                            this.BeginInvoke(method);
                        }
                    }
                    //foreach(FaceRecognizer recogniser in recognisers)
                    //{
                    //    detectionLabel = recogniser.Predict(result).Label;
                    //}
                }
            }
        }
コード例 #8
0
        // Вызывает метод из пары "метод+имя" methodInputInfo для массива array.
        private static MethodInfo RunMethod(MethodInfo_Pair methodInputInfo, int[] array)
        {
            MethodInfo outStruct; int[] sortedArray;
            Stopwatch  timer = new Stopwatch();

            timer.Start();
            sortedArray = methodInputInfo.Value(array);
            timer.Stop();

            outStruct.name     = methodInputInfo.Key;
            outStruct.time     = (int)timer.Elapsed.TotalSeconds; // Время в секундах.
            outStruct.capacity = sortedArray.Length;              // Спорный вопрос: на кой черт метод возвращает размер обработанного массива,
                                                                  // если мы вызываем все методы для одного массива за раз и этот размер не меняется со временем.

            System.Threading.Thread.Sleep(3);                     // даем потоку передохнуть

            if (CloseMethod != null)
            {
                CloseMethod.Invoke();
            }

            return(outStruct);
        }
コード例 #9
0
ファイル: ShaderViewer.cs プロジェクト: tomas-k/renderdoc
        public ShaderViewer(Core core, bool custom, string entry, Dictionary<string, string> files, SaveMethod saveCallback, CloseMethod closeCallback)
        {
            InitializeComponent();

            constantRegs.Font =
                variableRegs.Font =
                watchRegs.Font =
                inSig.Font =
                outSig.Font =
                core.Config.PreferredFont;

            Icon = global::renderdocui.Properties.Resources.icon;

            this.SuspendLayout();

            mainLayout.Dock = DockStyle.Fill;

            snippetDropDown.Visible = custom;

            debuggingStrip.Visible = false;

            inSigBox.Visible = false;
            outSigBox.Visible = false;

            m_Core = core;
            m_SaveCallback = saveCallback;
            m_CloseCallback = closeCallback;

            if (m_Core.LogLoaded)
                pointLinearSamplersToolStripMenuItem.Visible = (m_Core.APIProps.pipelineType == APIPipelineStateType.D3D11);

            DockContent sel = null;

            foreach (var f in files)
            {
                var name = f.Key;

                ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true);
                scintilla1.IsReadOnly = false;
                scintilla1.Tag = name;

                scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown);
                scintilla1.KeyDown += new KeyEventHandler(editScintilla_KeyDown);

                m_Scintillas.Add(scintilla1);

                var w = Helpers.WrapDockContent(dockPanel, scintilla1, name);
                w.CloseButton = false;
                w.CloseButtonVisible = false;
                w.Show(dockPanel);

                if (f.Value.Contains(entry))
                    sel = w;

                Text = string.Format("{0} - Edit ({1})", entry, f.Key);
            }

            m_FindAll = new FindAllDialog(FindAllFiles);
            m_FindAll.Hide();

            if (files.Count > 3)
                AddFileList();

            if (sel != null)
                sel.Show();

            ShowConstants();
            ShowVariables();
            ShowWatch();
            ShowErrors();

            {
                m_ConstantsDock.Hide();
                m_VariablesDock.Hide();
                m_WatchDock.Hide();
            }

            this.ResumeLayout(false);
        }
コード例 #10
0
 private static void CloseForm(Form form)
 {
     if (!form.IsDisposed) {
         if (form.InvokeRequired) {
             CloseMethod method = new CloseMethod(CloseForm);
             form.Invoke(method, new object[] { form });
         }
         else {
             form.Close();
         }
     }
 }
コード例 #11
0
ファイル: ShaderViewer.cs プロジェクト: Waferix/renderdoc
        public ShaderViewer(Core core, bool custom, string entry, Dictionary<string, string> files, SaveMethod saveCallback, CloseMethod closeCallback)
        {
            InitializeComponent();

            Icon = global::renderdocui.Properties.Resources.icon;

            this.SuspendLayout();

            mainLayout.Dock = DockStyle.Fill;

            snippetDropDown.Visible = custom;

            debuggingStrip.Visible = false;

            inSigBox.Visible = false;
            outSigBox.Visible = false;

            m_Core = core;
            m_SaveCallback = saveCallback;
            m_CloseCallback = closeCallback;

            DockContent sel = null;

            foreach (var f in files)
            {
                var name = f.Key;

                ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true);
                scintilla1.IsReadOnly = false;
                scintilla1.Tag = name;

                scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown);
                scintilla1.KeyDown += new KeyEventHandler(scintilla1_KeyDown);

                m_Scintillas.Add(scintilla1);

                var w = Helpers.WrapDockContent(dockPanel, scintilla1, name);
                w.CloseButton = false;
                w.CloseButtonVisible = false;
                w.Show(dockPanel);

                if (f.Value.Contains(entry))
                    sel = w;

                Text = string.Format("{0} - Edit ({1})", entry, f.Key);
            }

            if(sel != null)
                sel.Show();

            ShowConstants();
            ShowVariables();
            ShowWatch();
            ShowErrors();

            {
                m_ConstantsDock.Hide();
                m_VariablesDock.Hide();
                m_WatchDock.Hide();
            }

            this.ResumeLayout(false);
        }
コード例 #12
0
        public ShaderViewer(Core core, bool custom, string entry, Dictionary <string, string> files, SaveMethod saveCallback, CloseMethod closeCallback)
        {
            InitializeComponent();

            Icon = global::renderdocui.Properties.Resources.icon;

            this.SuspendLayout();

            mainLayout.Dock = DockStyle.Fill;

            snippetDropDown.Visible = custom;

            debuggingStrip.Visible = false;

            inSigBox.Visible  = false;
            outSigBox.Visible = false;

            m_Core          = core;
            m_SaveCallback  = saveCallback;
            m_CloseCallback = closeCallback;

            DockContent sel = null;

            foreach (var f in files)
            {
                var name = f.Key;

                ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true);
                scintilla1.IsReadOnly = false;
                scintilla1.Tag        = name;

                scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown);
                scintilla1.KeyDown        += new KeyEventHandler(scintilla1_KeyDown);

                m_Scintillas.Add(scintilla1);

                var w = Helpers.WrapDockContent(dockPanel, scintilla1, name);
                w.CloseButton        = false;
                w.CloseButtonVisible = false;
                w.Show(dockPanel);

                if (f.Value.Contains(entry))
                {
                    sel = w;
                }

                Text = string.Format("{0} - Edit ({1})", entry, f.Key);
            }

            if (sel != null)
            {
                sel.Show();
            }

            ShowConstants();
            ShowVariables();
            ShowWatch();
            ShowErrors();

            {
                m_ConstantsDock.Hide();
                m_VariablesDock.Hide();
                m_WatchDock.Hide();
            }

            this.ResumeLayout(false);
        }
コード例 #13
0
        private void ZScreen_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Save Destinations
            if (Engine.ConfigUI != null)
            {
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbOutputs, Engine.ConfigUI.ConfOutputs);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbLinkFormat, Engine.ConfigUI.ConfLinkFormat);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbClipboardContent, Engine.ConfigUI.ConfClipboardContent);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestImage, Engine.ConfigUI.MyImageUploaders);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestFile, Engine.ConfigUI.MyFileUploaders);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestText, Engine.ConfigUI.MyTextUploaders);
                Adapter.SaveMenuConfigToList(ucDestOptions.tsddbDestLink, Engine.ConfigUI.MyURLShorteners);
            }

            // If UserClosing && ZScreenCloseReason.None then this means close button pressed in title bar
            if (e.CloseReason == CloseReason.UserClosing && CloseMethod == CloseMethod.None)
            {
                if (Engine.ConfigApp.WindowButtonActionClose == WindowButtonAction.ExitApplication)
                {
                    CloseMethod = CloseMethod.CloseButton;
                }
                else if (Engine.ConfigApp.WindowButtonActionClose == WindowButtonAction.MinimizeToTaskbar)
                {
                    WindowState = FormWindowState.Minimized;
                    e.Cancel = true;
                }
                else if (Engine.ConfigApp.WindowButtonActionClose == WindowButtonAction.MinimizeToTray)
                {
                    Hide();
                    DelayedTrimMemoryUse();
                    if (Engine.ConfigOptions.AutoSaveSettings) Engine.WriteSettingsAsync();
                    e.Cancel = true;
                }
            }

            // If really ZScreen is closing
            if (!e.Cancel)
            {
                DebugHelper.WriteLine("ZScreen_FormClosing - CloseReason: {0}, CloseMethod: {1}", e.CloseReason,
                                       CloseMethod);
                Engine.WriteSettings();
                Engine.TurnOff();
            }
        }
コード例 #14
0
 public void Execute(object param)
 {
     CloseState = bool.Parse((string)param);
     CloseMethod.Invoke();
 }