Ejemplo n.º 1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            if (imageForeground != null)
            {
                facedetector.DetectObj(imageForeground);

                imageForeground.ROI = facedetector.FirstFace;
                mouthdetector.DetectObj(imageForeground);
                nosedetector.DetectObj(imageForeground);
                eyedetector.DetectObj(imageForeground);
                imageForeground.ROI = Rectangle.Empty;

                mouthdetector.FilterResult();
                nosedetector.FilterResult();

                eyedetector.DrawColor   = Color.Pink;
                mouthdetector.DrawColor = Color.Yellow;
                nosedetector.DrawColor  = Color.White;

                facedetector.DrawObj(imageForeground);
                imageForeground.ROI = facedetector.FirstFace;
                eyedetector.DrawObj(imageForeground);
                mouthdetector.DrawObj(imageForeground);
                nosedetector.DrawObj(imageForeground);
                imageForeground.ROI = Rectangle.Empty;

                rcfFace     = facedetector.FirstFace;
                rcfLeftEye  = eyedetector.BestLeftEye;
                rcfRightEye = eyedetector.BestRightEye;
                rcfMouth    = mouthdetector.BestResult;
                rcfNose     = nosedetector.BestResult;

                imgboxBackground.Image = imageForeground;
            }
            if (imageBackground != null)
            {
                facedetector.DetectObj(imageBackground);

                imageBackground.ROI = facedetector.FirstFace;
                mouthdetector.DetectObj(imageBackground);
                nosedetector.DetectObj(imageBackground);
                eyedetector.DetectObj(imageBackground);
                imageBackground.ROI = Rectangle.Empty;

                mouthdetector.FilterResult();
                nosedetector.FilterResult();

                eyedetector.DrawColor   = Color.Pink;
                mouthdetector.DrawColor = Color.Yellow;
                nosedetector.DrawColor  = Color.White;

                facedetector.DrawObj(imageBackground);
                imageBackground.ROI = facedetector.FirstFace;
                eyedetector.DrawObj(imageBackground);
                mouthdetector.DrawObj(imageBackground);
                nosedetector.DrawObj(imageBackground);
                imageBackground.ROI = Rectangle.Empty;

                rcbFace     = facedetector.FirstFace;
                rcbLeftEye  = eyedetector.BestLeftEye;
                rcbRightEye = eyedetector.BestRightEye;
                rcbMouth    = mouthdetector.BestResult;
                rcbNose     = nosedetector.BestResult;

                imgboxBackground.Image = imageBackground;
            }
        }