private void OnMainFacesAvailable(object sender, FaceRegionsEventArgs e)
        {
            FaceRegion2D leftRegion;
            FaceRegion2D rightRegion;

            if (IsRecording == false
                || e.Left == null
                || e.Right == null
                || e.Left.Count() != 1
                || e.Right.Count() != 1
                || (leftRegion = e.Left.First()).LeftEye == null
                || (rightRegion = e.Right.First()).LeftEye == null
                || leftRegion.RightEye == null
                || rightRegion.RightEye == null
                || leftRegion.Mouth == null
                || rightRegion.Mouth == null)
            {
                return;
            }

            _leftFaceRegions.Add(leftRegion);
            _rightFaceRegions.Add(rightRegion);

            Invoke(new Action(delegate { labelAvailableImages.Text = _leftFaceRegions.Count.ToString(CultureInfo.InvariantCulture); }));
        }
Пример #2
0
        private void OnMainFacesAvailable(object sender, FaceRegionsEventArgs e)
        {
            if (IsRecording == false)
            {
                return;
            }

            var faceRegions = new List<FaceRegion2D>();

            #region Add Face Regions

            if (e.Left != null)
            {
                faceRegions.AddRange(e.Left);
            }

            if (e.Right != null)
            {
                faceRegions.AddRange(e.Right);
            }

            #endregion

            TrainingFaceModel.Images.AddRange(faceRegions.
                Where(faceRegion => faceRegion.LeftEye != null && faceRegion.RightEye != null).
                Select(faceRegion => faceRegion.FaceImage));

            this.Invoke(new Action(delegate()
            {
                dgvFaces.DataSource = null;
                dgvFaces.DataSource = HelperFaces.Faces;
            }));
        }