public Bitmap markRects() { if (eyeRects.Length > 0) { RectanglesMarker marker = new RectanglesMarker(eyeRects, Color.Red); image = MainForm.ConvertToFormat(image, System.Drawing.Imaging.PixelFormat.Format24bppRgb); image = marker.Apply(image); } if (noseRects.Length > 0) { RectanglesMarker marker = new RectanglesMarker(noseRects, Color.Blue); image = MainForm.ConvertToFormat(image, System.Drawing.Imaging.PixelFormat.Format24bppRgb); image = marker.Apply(image); } if (mouthRects.Length > 0) { RectanglesMarker marker = new RectanglesMarker(mouthRects, Color.Purple); image = MainForm.ConvertToFormat(image, System.Drawing.Imaging.PixelFormat.Format24bppRgb); image = marker.Apply(image); } return image; }
private void ProcessButton_Click(object sender, EventArgs e) { if (image != null) { if (MedianFilterCB.Checked) image = new MedianFilter().ApplyMedianFilter(image, (int)medianUpDown.Value); if (GaussianBlurFilterCB.Checked) image = new GaussianBlurFilter().ApplyGaussianBlur(image, new Rectangle(0, 0, image.Width, image.Height), (int)gaussianUpDown.Value); if (ContrastCB.Checked && contrast_textBox.Text != "100") { int percent = Int32.Parse(contrast_textBox.Text); image = new ContrastFilter().apply2(image, new Rectangle(0, 0, image.Width, image.Height), percent); contrast_textBox.Text = "100"; } /*if (ColorMatchingCB.Checked) { image = new ColorMatchingFilter().apply(image, (int)red_numeric.Value, (int)green_numeric.Value, (int)blueNumeric.Value); }*/ detector.ScalingMode = ObjectDetectorScalingMode.SmallerToGreater; detector.ScalingFactor = 1.5f; Rectangle[] objects = detector.ProcessFrame(image); if (objects.Length > 0) { RectanglesMarker marker = new RectanglesMarker(objects, Color.Yellow); image = ConvertToFormat(image, System.Drawing.Imaging.PixelFormat.Format24bppRgb); image = marker.Apply(image); } MainPictureBox.Image = image; List<Face> faces = new List<Face>(); foreach (var rect in objects) { Face face = new Face(CropImage(image, rect)); faces.Add(face); face.detectAll(); //MainPictureBox.Image = face.markRects(); //DefinePoints(CropImage(image, rect)); } //MainPictureBox.Image = image; } else { MessageBox.Show("There is no image to process. Load it and try again."); } }