Пример #1
0
        /// <summary> Function which submits a frame to the Computer Vision API for celebrity
        ///     detection. </summary>
        /// <param name="frame"> The video frame to submit. </param>
        /// <returns> A <see cref="Task{LiveCameraResult}"/> representing the asynchronous API call,
        ///     and containing the celebrities returned by the API. </returns>
        private async Task <LiveCameraResult> AtosEmployeeAnalysisFunction(VideoFrame frame)
        {
            var jpg = frame.Image.ToMemoryStream(".jpg", s_jpegParams);
            // Submit image to API.
            var attrs = new List <FaceAPI.FaceAttributeType> {
                FaceAPI.FaceAttributeType.Age,
                FaceAPI.FaceAttributeType.Gender,
                FaceAPI.FaceAttributeType.HeadPose,
                FaceAPI.FaceAttributeType.Glasses,
                FaceAPI.FaceAttributeType.Hair,
                FaceAPI.FaceAttributeType.FacialHair,
                FaceAPI.FaceAttributeType.Makeup,
                FaceAPI.FaceAttributeType.Smile,
                FaceAPI.FaceAttributeType.Emotion,
                FaceAPI.FaceAttributeType.Accessories,
                FaceAPI.FaceAttributeType.Occlusion,
                FaceAPI.FaceAttributeType.Blur
            };
            var faces = await _faceClient.DetectAsync(jpg, returnFaceAttributes : attrs);

            // Count the API call.
            Properties.Settings.Default.FaceAPICallCount++;

            FaceRecognition fr     = new FaceRecognition();
            var             person = await fr.Identify(_faceClient, faces);

            var pName = "";

            List <AtosEmployee> aeList = new List <AtosEmployee>();

            if (person != null)
            {
                pName = person.Name;
                var employee = AtosEmployeesDetails.Get(pName);

                if (employee != null)
                {
                    aeList.Add(employee);
                    pName = employee.FirstName + " " + employee.LastName;
                }
            }
            return(new LiveCameraResult
            {
                // Extract face rectangles from results.
                Faces = faces.Take(1).ToArray(),
                // Extract celebrity names from results.
                CelebrityNames = aeList.ToArray(),
                EmotionScores = faces.Select(e => e.FaceAttributes.Emotion).ToArray()
            });
        }
Пример #2
0
 private async void UploadFacesButton_Click(object sender, RoutedEventArgs e)
 {
     FaceRecognition fr = new FaceRecognition();
     await fr.UploadFaces();
 }
Пример #3
0
 private async void StartTrainingButton_Click(object sender, RoutedEventArgs e)
 {
     FaceRecognition fr = new FaceRecognition();
     await fr.StartTraining();
 }
Пример #4
0
 private async void CreateDBButton_Click(object sender, RoutedEventArgs e)
 {
     FaceRecognition fr = new FaceRecognition();
     await fr.UpdatePerson("Person 3 Sabina");
 }