Beispiel #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();
        }