Exemple #1
0
        public async Task <IActionResult> linkFace([FromBody] CustReq req)
        {
            Claim oid      = User.Claims.FirstOrDefault(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier");
            var   personId = await _userFunctions.getPersonIdAsync(oid.Value);

            if (String.IsNullOrEmpty(personId))
            {
                var person = await _faceClient.CreatePersonAsync(_configuration["personGroupId"], oid.Value);

                await _userFunctions.setPersonIdAsync(oid.Value, person.PersonId.ToString());

                personId = person.PersonId.ToString();
            }

            byte[]       bytes = Convert.FromBase64String(req.image);
            MemoryStream ms    = new MemoryStream(bytes);

            try
            {
                var returnedFace = await _faceClient.AddPersonFaceAsync(_configuration["personGroupId"], Guid.Parse(personId), ms);

                await _faceClient.TrainPersonGroupAsync(_configuration["personGroupId"]);

                return(Json(returnedFace));
            }
            catch (FaceAPIException e)
            {
                return(Json(new { error = e.ErrorMessage }));
            }
        }
Exemple #2
0
        public async Task <IActionResult> checkFace([FromBody] CustReq req)
        {
            byte[]       bytes = Convert.FromBase64String(req.image);
            MemoryStream ms    = new MemoryStream(bytes);

            var returnedFace = await _faceClient.DetectAsync(ms);

            return(Json(returnedFace));
        }
Exemple #3
0
        public async Task <IActionResult> deleteIdentity([FromBody] CustReq req)
        {
            Claim oid      = User.Claims.FirstOrDefault(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier");
            var   personId = await _userFunctions.getPersonIdAsync(oid.Value);

            if (personId == null)
            {
                return(Json(new { message = "No identity linked to your account..." }));
            }

            await _faceClient.DeletePersonAsync(_configuration["personGroupId"], Guid.Parse(personId));

            await _userFunctions.setPersonIdAsync(oid.Value, null);

            return(Json(new { message = "Identity deleted..." }));
        }