public Image<Bgr, Byte> FaceDetection(Image Image) { face = new HaarCascade("haarcascade_frontalface_default.xml"); Utility UTl = new Utility(); //Get the current frame form capture device Image<Bgr, Byte> currentFrame = UTl.ImageToBgrByte(Image); //Convert it to Grayscale gray = currentFrame.Convert<Gray, Byte>(); //Face Detector MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(face,1.2,10,Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,new Size(20, 20)); //Action for element detected try { MCvAvgComp f = facesDetected[0][0]; result = currentFrame.Copy(f.rect).Convert<Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //draw the face detected in the 0th (gray) channel with blue color currentFrame.Draw(f.rect, new Bgr(Color.White), 2); } catch (Exception ex) { MessageBox.Show("Camera Error: Empty frames arrived" + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return currentFrame; }
private void btnUpdate_Click(object sender, EventArgs e) { Utility utl = new Utility(); byte[] photo = utl.ConvertImageToBytes(picUser.Image); User usr = new User(lblUserID.Text, txtFirstName.Text, txtLastName.Text, lblTitle.Text, lblUserLevel.Text, txtUserName.Text, txtPassword.Text, txtEmailAdd.Text, Convert.ToDateTime(lblDate.Text), lblTime.Text,photo); if (txtPassword.Text != "") { if (usr.UpdateUser(usr)) { MessageBox.Show("User Modification is successful!", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); clear_Txt(); } else { MessageBox.Show("Modification Rejected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Empty password not allowed", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Error); } }