Exemplo n.º 1
0
        private async Task <int> ProcessLabels(ILambdaContext context, string jobId)
        {
            int success = 0; //success

            GetPersonTrackingResponse response = null;

            do
            {
                GetPersonTrackingRequest request = new GetPersonTrackingRequest
                {
                    JobId      = jobId,
                    MaxResults = MaxResults,
                    NextToken  = response?.NextToken,
                    SortBy     = PersonTrackingSortBy.TIMESTAMP
                };

                response = await this.rekClient.GetPersonTrackingAsync(request).ConfigureAwait(false);

                //more than one person detected
                if (response.Persons.Any(x => x.Person.Index != 0))
                {
                    success = 1;
                    break;
                }

                //video brightness is low
                if (response.Persons.Any(x => x.Person.Face?.Quality.Brightness < 50.0f))
                {
                    success = 2;
                    break;
                }

                //instructor is not clear in the video
                if (response.Persons.Any(x => x.Person.Face?.Confidence < 50))
                {
                    success = 3;
                    break;
                }

                //facial expressions are acceptable
                if (response.Persons.Any(x => x.Person.Face != null && x.Person.Face.Emotions.Any(y => invalidEmotions.Contains(y.Type))))
                {
                    success = 4;
                    break;
                }
            } while (response?.NextToken != null);

            return(success);
        }
Exemplo n.º 2
0
        //private readonly List<EmotionName> invalidEmotions = new List<EmotionName>
        //{
        //  EmotionName.SAD, EmotionName.SURPRISED, EmotionName.ANGRY, EmotionName.CONFUSED, EmotionName.DISGUSTED,
        //  EmotionName.UNKNOWN
        //};

        private async Task <bool> ProcessLabels(ILambdaContext context, string jobId)
        {
            bool success = true;

            GetPersonTrackingResponse response = null;

            do
            {
                GetPersonTrackingRequest request = new GetPersonTrackingRequest
                {
                    JobId      = jobId,
                    MaxResults = MaxResults,
                    NextToken  = response?.NextToken,
                    SortBy     = PersonTrackingSortBy.TIMESTAMP
                };

                response = await this.rekClient.GetPersonTrackingAsync(request).ConfigureAwait(false);

                //more than one person detected

                if (response.Persons.Any(x => x.Person.Index != 0))
                {
                    success = false;
                    break;
                }

                if (response.Persons.Any(x => x.Person.Face?.Quality.Brightness < 50.0f || x.Person.Face?.Quality.Sharpness < 50.0f))
                {
                    success = false;
                    break;
                }

                if (response.Persons.Any(x => x.Person.Face?.Confidence < 50))
                {
                    success = false;
                    break;
                }

                //if(response.Persons.Any(x => x.Person.Face?.Emotions.Any(y => invalidEmotions.Contains(y.Type))))
            } while (response?.NextToken != null);

            return(success);
        }