async Task OnAddImage() { await ExecuteAsync(async() => { await CheckPermissionAndAskIfIsNeeded(Permission.Camera); await CheckPermissionAndAskIfIsNeeded(Permission.Storage); _photo = await GetFacePhotoTaked(); if (_photo == null) { return; } PhotoTaked = _photo.Path; byte[] byteArray = GetByteArray(_photo); var detectResults = await FaceApiService.DetectFaces(byteArray); if (!(await IsPhotoValid(detectResults))) { return; } var identifyResults = await FaceApiService.Identify(new IdentifyFaceRequest() { FaceIds = detectResults.Select(x => x.FaceId).ToList(), MaxNumOfCandidatesReturned = 10, PersonGroupId = _personGroup.PersonGroupId, ConfidenceThreshold = 0.5 }); var persons = await FaceApiService.GetPersons(); if (detectResults == null || identifyResults == null || persons == null) { return; } FacesDetected = identifyResults.Select(res => new FaceDetectedItemViewModel() { FaceId = res.FaceId, FaceRectangle = detectResults.FirstOrDefault(detResults => detResults.FaceId == res.FaceId).FaceRectangle, FaceAttributes = detectResults.FirstOrDefault(detResults => detResults.FaceId == res.FaceId).FaceAttributes, PersonName = persons?.FirstOrDefault(p => p.PersonId == res.Candidates?.FirstOrDefault(cand => cand.PersonId == p.PersonId)?.PersonId)?.Name }).ToList(); }); }