Example #1
0
        public async Task CreatePersonGroup(string personGroupId, string name, string userData)
        {
            var personGroup = await _service.GetPersonGroupsByNameAsync(Configurations.PersonGroup);

            if (personGroup == null)
            {
                await _service.CreatePersonGroupAsync(personGroupId, name, userData);
            }
        }
Example #2
0
        public async Task <string> RegisterYourNameWithImage(Stream stream, string uniqueId)
        {
            var personGroup = await _service.GetPersonGroupsByNameAsync(Configurations.PersonGroup);

            var psersons = await _service.GetPersonsAsync(personGroup.PersonGroupId);

            if (psersons.Any(x => x.Name == uniqueId))
            {
                var person = psersons.Where(x => x.Name == uniqueId).First();
                await _service.AddPersonFaceAsync(personGroup.PersonGroupId, person.PersonId, stream, uniqueId, null);
            }
            else
            {
                var result = await _service.CreatePersonWithResultAsync(personGroup.PersonGroupId, uniqueId);

                await _service.AddPersonFaceAsync(personGroup.PersonGroupId, result.PersonId, stream, uniqueId, null);
            }

            //await _service.TrainPersonGroupAsync(personGroup.PersonGroupId);

            return(uniqueId);
        }
Example #3
0
        public async Task <IEnumerable <Tuple <Person, Face, Candidate> > > CheckNameFromImage(Stream stream)
        {
            var faces = await _service.DetectAsync(
                stream,
                returnFaceId : true,
                returnFaceLandmarks : false,
                returnFaceAttributes : FaceApiService.DefaultFaceAttributeTypes);

            var outs = new List <Tuple <Person, Face, Candidate> >();

            if (faces.Count() > 0)
            {
                var personGroup = await _service.GetPersonGroupsByNameAsync(Configurations.PersonGroup);

                var identityResults = await _service.IdentifyAsync(personGroup.PersonGroupId,
                                                                   faces.Select(x => x.FaceId).ToArray());

                foreach (var face in faces)
                {
                    var result = identityResults.Where(x => x.FaceId == face.FaceId).First();
                    if (result.Candidates.Count() > 0)
                    {
                        var candidate = result.Candidates.OrderByDescending(x => x.Confidence).First();
                        var person    = await _service.GetPersonAsync(personGroup.PersonGroupId, candidate.PersonId);

                        outs.Add(Tuple.Create(person, face, candidate));
                    }
                    else
                    {
                        var candidate = new Candidate();
                        var person    = new Person();
                        outs.Add(Tuple.Create(person, face, candidate));
                    }
                    //yield return face;
                }

                return(outs);
            }
            return(outs);
        }