private void BrowseButton_Click(object sender, EventArgs e) { if (this.openFileDialog1.ShowDialog() != DialogResult.OK) { return; } int larg = this.PhotoPictureBox.Width; int alt = this.PhotoPictureBox.Height; Bitmap face = new Bitmap(Image.FromFile(this.openFileDialog1.FileName), larg, alt); Rectangle rect = PictureCamera.DetectFace(new Image <Bgr, Byte>(face)); if (rect != Rectangle.Empty) { this.PhotoPictureBox.BackgroundImage = face; this.grayFace = new Image <Gray, byte>(face).Copy(rect).Resize(100, 100, INTER.CV_INTER_CUBIC); this.PhotoCheckBox.AutoCheck = true; this.PhotoCheckBox.Checked = true; this.PhotoCheckBox.Enabled = false; } else { MessageBox.Show("The photo is not valid!!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TakePictureButton_Click(object sender, EventArgs e) { this.Enabled = false; PictureCamera pic = new PictureCamera(this, "DATA"); pic.ShowDialog(); }
private void ProcessFrame(object sender, EventArgs arg) { Image <Bgr, Byte> ImageFrame = capture.QueryFrame(); if (ImageFrame != null) { this.rect = PictureCamera.DetectFace(ImageFrame); ImageFrame.Draw(this.rect, new Bgr(Color.DarkRed), 2); } ImageBox.Image = ImageFrame; }
private void SaveButton_Click(object sender, EventArgs e) { bool trovato = false; foreach (DataGridViewCell cella in this.ModUserDataGridView.Rows[0].Cells) { if (cella.Style.BackColor == Color.DarkRed && cella.Style.SelectionBackColor == Color.Maroon) { trovato = true; break; } } if (!trovato) { MessageBox.Show("", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Bitmap bmp = (Bitmap)this.ModUserDataGridView.Rows[0].Cells[4].Value; int codice = Convert.ToInt32(this.ModUserDataGridView.Rows[0].Cells[0].Value); User u = this.db.SelectSimpleUser(codice); Administrator admin = null; if (u == null) { admin = this.db.SelectAdministrator(codice); } Rectangle rect = PictureCamera.DetectFace(new Image <Bgr, Byte>(bmp)); if (rect != Rectangle.Empty) { this.grayFace = new Image <Gray, byte>(bmp).Copy(rect).Resize(100, 100, INTER.CV_INTER_CUBIC); this.db.InsertImage(codice, this.grayFace.Bytes); } if (u != null) { this.db.UpdateTableUser(u, this.ModUserDataGridView.Rows[0]); } else { this.db.UpdateTableUser(admin, this.ModUserDataGridView.Rows[0]); } MessageBox.Show("Information updated successfully!!", "NOTICE", MessageBoxButtons.OK, MessageBoxIcon.Information); }