protected virtual void OnPlayerIdentified(BiometricData e) { // Note the use of a temporary variable here to make the event raisin // thread-safe; may or may not be necessary in your case. var evt = this.PlayerIdentified; if (evt != null) evt(this, e); }
public void Listen(string source) { Random rnd = new Random(); var demogrphics = new BiometricData() { Age = rnd.Next(19, 55), Gender = (rnd.NextDouble() < 0.5) ? Gender.Male : Gender.Female }; var handler = this.DemographicsReceived; if (handler != null) handler(this, demogrphics); }
void _interactionService_KioskStateChanged(object sender, KioskStateEventArgs e) { if (e.KioskState == "Tracking") { Debug.Print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Media Content Kiosk State Change " + e.CurrentZone); if (_currentZone != e.CurrentZone) { if (_currentZone == NOTRACK) IsVideoPlaying = false; _currentZone = e.CurrentZone; DisplayZoneName = _currentZone; if (e.Demographics == null) { _missingDemographicData = true; _missingUsersTrackingID = e.TrackingID; } else { _missingDemographicData = false; } if (e.Demographics != null) Debug.Print("Demographics during Kiosk State Change" + e.Demographics.Gender.ToString()); _demographics = e.Demographics; SelectContentBasedOnDemographics(e.Demographics); OnActivated(); } } else if (e.KioskState == NOTRACK) { _currentZone = NOTRACK; DisplayZoneName = _currentZone; SelectContentBasedOnDemographics(null); OnActivated(); } else OnDeactivated(); }
void _demographicsService_DemographicsReceived(object sender, BiometricData e) { if (_missingDemographicData) { if (e.TrackingId == _missingUsersTrackingID) { SelectContentBasedOnDemographics(e); } } }
private void SelectContentBasedOnDemographics(BiometricData currentUser, string itemSelected = null) { bool hasContent = false; if (string.IsNullOrEmpty(itemSelected)) { if (currentUser == null) hasContent = _contentManagement.LoadContents(_currentZone); else hasContent = _contentManagement.LoadContents(_currentZone, (m) => { return (currentUser.Age >= m.Age && currentUser.Age < m.MaxAge) && m.Gender.ToString().ToLower() == currentUser.Gender.ToString().ToLower(); }); } else { if (currentUser == null) hasContent = _contentManagement.LoadContents(itemSelected); else hasContent = _contentManagement.LoadContents(itemSelected, (m) => { return (currentUser.Age >= m.Age && currentUser.Age < m.MaxAge) && m.Gender.ToString().ToLower() == currentUser.Gender.ToString().ToLower(); }); } if (hasContent) { if (!IsVideoPlaying) MediaSource = _contentManagement.MoveNext().ContentPath; } else { ConfigurationProvider cp = new ConfigurationProvider(); IConfigSettings cs = cp.Load(); if (string.IsNullOrEmpty(itemSelected)) { if (currentUser == null) ErrorMessage = String.Format(@"Media Content is missing in the following directory: {0}\{1}", cs.RootContentDirectory, _currentZone); else ErrorMessage = String.Format(@"Media Content is missing in the following directory: {0}\{1} for {2}yo {3}", cs.RootContentDirectory, _currentZone, currentUser.Age.ToString(), currentUser.Gender.ToString()); } else { if (currentUser == null) ErrorMessage = String.Format(@"Media Content is missing in the following directory: {0}\{1}", cs.RootContentDirectory, itemSelected); else ErrorMessage = String.Format(@"Media Content is missing in the following directory: {0}\{1} for {2}yo {3}", cs.RootContentDirectory, itemSelected, currentUser.Age.ToString(), currentUser.Gender.ToString()); } } }
void _demographicsService_DemographicsReceived(object sender, BiometricData e) { Dispatcher.Invoke(() => { var output = string.Format("\r\n" + "{6} @ " + DateTime.Now.ToLongTimeString() + " > Gender: {0} - Age: {1} - Confidence: {2} - Id: {3} Match: {4} FaceID: {5}", e.Gender.ToString(), e.Age, e.GenderConfidence, e.TrackingId, e.FaceMatch, e.FaceID, e.TrackingState); textLog.Text += output; if (e.FaceImage != null) { _currentPlayImage = e.FaceImage; face.Source = ToBitmapImage(e.FaceImage); } }); }
void _interactionService_KioskStateChanged(object sender, KioskStateEventArgs e) { if (e.KioskState == "Tracking") { if (_currentZone != e.CurrentZone || _currentUserTrackingID != e.TrackingID) { //remember the last state we had before selecting content. _currentZone = e.CurrentZone; _currentUserTrackingID = e.TrackingID; DisplayZoneName = _currentZone; if (e.Demographics == null) { _missingDemographicData = true; _missingUsersTrackingID = e.TrackingID; } else { _missingDemographicData = false; } if (e.Demographics != null) Debug.Print("Demographics during Kiosk State Change " + e.Demographics.Gender.ToString()); _demographics = e.Demographics; SelectContentBasedOnDemographics(e.Demographics); OnActivated(); } } else if (e.KioskState == NOTRACK) { _currentZone = NOTRACK; DisplayZoneName = _currentZone; SelectContentBasedOnDemographics(null); OnActivated(); } else OnDeactivated(); }
public void Add(BiometricData BiometricSample) { LastSeen = DateTime.Now; this.ActivelyTracked = true; _biometricDataSamples.Add(BiometricSample); }
public PlayerBiometrics(BiometricData Data) { LastSeen = DateTime.Now; this.ActivelyTracked = true; _biometricDataSamples = new List<BiometricData>(); _biometricDataSamples.Add(Data); TrackingID = Data.TrackingId; }
private void RaiseDemographicsEvent(BiometricData payload) { var handler = this.DemographicsReceived; if (handler != null && payload != null) { handler(this, payload); //This code is only for situations where you want the app to remember the user. It requires that we perform face recoginition UserExperienceContext uec = new UserExperienceContext(); uec.Age = payload.Age; uec.Gender = payload.Gender; uec.FaceID = payload.FaceID; uec.InteractionCount = 1; if (payload.FaceMatch) { //Find out if we've already seen this person var orginalUser = (from users in _userExperiences where users.FaceID == payload.FaceID select users).FirstOrDefault(); if (orginalUser == null) { uec.TrackingId = payload.TrackingId; _userExperiences.Add(uec); } else { orginalUser.TrackingId = payload.TrackingId; orginalUser.InteractionCount++; } } else { uec.TrackingId = payload.TrackingId; _userExperiences.Add(uec); } } }
private BiometricData GetDemographics(ulong id, List<Face> Results) { if (TestMode) { var confidence = _rnd.NextDouble(); var result = new BiometricData() { Age = _rnd.Next(10, 90), Gender = (_rnd.NextDouble() <= 0.3) ? Gender.Male : Gender.Female, GenderConfidence = (confidence < 0.5) ? 0.5 : confidence, TrackingId = id }; return result; } else { if (Results.Count() > 0) { var demographic = new BiometricData(); demographic.TrackingId = id; demographic.Age = Results[0].Age; demographic.Gender = Results[0].Gender.ToUpper().Contains("F") ? Gender.Female : Gender.Male; demographic.GenderConfidence = Results[0].GenderConfidence; demographic.FaceMatch = Results[0].MatchResult; demographic.FaceID = Results[0].Name; return demographic; } else { return null; } } }