private void okBtn_Click(object sender, EventArgs e) { Application.Idle -= new EventHandler(FrameGrabber); grabber.Dispose(); RibbonForm1 form2 = new RibbonForm1(); this.Hide(); form2.ShowDialog(); this.Close(); }
private void tileItem1_ItemClick(object sender, DevExpress.XtraEditors.TileItemEventArgs e) { if (f1 == null) { f1 = new RibbonForm1(yonghu); //将主窗体对象传递过去 f1.yonghu = yonghu; f1.Show(); //显示窗体二 } else { f1.Activate(); f1 = null; } }
private void FrameGrabber(object sender, EventArgs e) { Users.Add(""); //Recheck at this point currentFrame = grabber.QueryFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); gray = currentFrame.Convert <Gray, Byte>(); MCvAvgComp[][] facesDetected = gray.DetectHaarCascade( face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); foreach (MCvAvgComp f in facesDetected[0]) { result = currentFrame.Copy(f.rect).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); currentFrame.Draw(f.rect, new Bgr(Color.Red), 2); if (trainingImages.ToArray().Length != 0) { //TermCriteria for face recognition with numbers of trained images like maxIteration MCvTermCriteria termCrit = new MCvTermCriteria(ContTrain, 0.001); //Eigen face recognizer EigenObjectRecognizer recognizer = new EigenObjectRecognizer( trainingImages.ToArray(), labels.ToArray(), 3000, ref termCrit); name = recognizer.Recognize(result); //Validation = name; //Draw the label for each face detected and recognized currentFrame.Draw(name, ref font, new Point(f.rect.X - 2, f.rect.Y - 2), new Bgr(Color.BlueViolet)); } Users.Add(""); } cameraBox.Image = currentFrame; if (!string.IsNullOrWhiteSpace(name) && name == "Lac") { Application.Idle -= new EventHandler(FrameGrabber); grabber.Dispose(); RibbonForm1 form2 = new RibbonForm1(); this.Hide(); form2.ShowDialog(); this.Close(); } names = ""; Users.Clear(); }