Exemplo n.º 1
0
        private void FaceDetectionUpdate()
        {
            faceDetector.DrawEnabled  = cbFDDraw.Checked;
            faceDetector.DrawColor    = Color.Green;
            faceDetector.FramesToSkip = tbFDSkipFrames.Value;
            faceDetector.MinNeighbors = tbFDMinNeighbors.Value;
            faceDetector.ScaleFactor  = tbFDScaleFactor.Value / 100.0f;
            faceDetector.VideoScale   = tbFDDownscale.Value / 10.0f;

            if (rbFDCircle.Checked)
            {
                faceDetector.DrawShapeType = CVShapeType.Circle;
            }
            else
            {
                faceDetector.DrawShapeType = CVShapeType.Rectangle;
            }

            faceDetector.MinFaceSize = new Size(Convert.ToInt32(edFDMinFaceWidth.Text), Convert.ToInt32(edFDMinFaceHeight.Text));

            var    path      = Path.GetDirectoryName(Application.ExecutablePath) + "\\";
            string facePath  = cbFDFace.Checked ? path + "haarcascade_frontalface_default.xml" : null;
            string eyesPath  = cbFDEyes.Checked ? path + "haarcascade_eye.xml" : null;
            string nosePath  = cbFDNose.Checked ? path + "haarcascade_mcs_nose.xml" : null;
            string mouthPath = cbFDMouth.Checked ? path + "haarcascade_mcs_mouth.xml" : null;

            faceDetector.Init(
                facePath,
                eyesPath,
                nosePath,
                mouthPath,
                true);

            faceDetector.UpdateSettings();
        }
Exemplo n.º 2
0
        private void FaceDetectionAdd()
        {
            faceDetector = new FaceDetector
            {
                DrawEnabled  = cbFDDraw.Checked,
                DrawColor    = Color.Green,
                FramesToSkip = tbFDSkipFrames.Value,
                MinNeighbors = tbFDMinNeighbors.Value,
                ScaleFactor  = tbFDScaleFactor.Value / 100.0f,
                VideoScale   = tbFDDownscale.Value / 10.0f
            };

            if (rbFDCircle.Checked)
            {
                this.faceDetector.DrawShapeType = CVShapeType.Circle;
            }
            else
            {
                this.faceDetector.DrawShapeType = CVShapeType.Rectangle;
            }

            var path = Path.GetDirectoryName(Application.ExecutablePath) + "\\";

            faceDetector.Init(
                path + "haarcascade_frontalface_default.xml",
                path + "haarcascade_eye.xml",
                path + "haarcascade_mcs_nose.xml",
                path + "haarcascade_mcs_mouth.xml",
                true);

            faceDetector.OnFaceDetected += OnFaceDetected;
        }