/// <summary>
        /// Callback called when a face is detected or recognized
        /// </summary>
        /// <param name="faceRecEvent"></param>
        private void FaceRecCallback(IFaceRecognitionEvent faceRecEvent)
        {
            if (faceRecEvent.Label == "unknown person")
            {
                AudioDetails randomAudio = _audioList[_randomGenerator.Next(0, _audioList.Count - 1)];
                ImageDetails randomImage = _imageList[_randomGenerator.Next(0, _imageList.Count - 1)];
                _misty.DisplayImage(randomImage.Name, 1, null);
                _misty.PlayAudio(randomAudio.Name, 100, null);
            }
            else
            {
                _misty.DisplayImage("e_EcstacyStarryEyed.jpg", 1, null);
                _misty.PlayAudio("sEcstacy.wav", 100, null);
            }

            if (!_misty.Wait(5000))
            {
                return;
            }
            _misty.DisplayImage("e_ContentLeft.jpg", 1, null);
            if (!_misty.Wait(5000))
            {
                return;
            }
            _misty.RegisterFaceRecognitionEvent(FaceRecCallback, 0, false, null, null, null);
        }
Esempio n. 2
0
        /// <summary>
        /// Process Face Recognition events
        /// Should only be called if FaceRec is on
        /// </summary>
        /// <param name="faceRecEvent"></param>
        private async void ProcessFaceRecognitionEvent(IFaceRecognitionEvent faceRecEvent)
        {
            try
            {
                string label = faceRecEvent.Label.ToLower();

                ITakePictureResponse takePictureResponse = await _misty.TakePictureAsync(label, false, true, true, null, null);

                if (label == "unknown person")
                {
                    Stream stream      = new MemoryStream((byte[])takePictureResponse.Data.Image);
                    string description = await _azureCognitive.AnalyzeImage(stream);

                    BroadcastDetails($"I see a person, {(string.IsNullOrWhiteSpace(description) ? "but I cannot describe them." : description)}", _defaultVoice);
                }
                else
                {
                    BroadcastDetails($"Hello, {label}!", _defaultVoice);
                }

                //Wait a bit so we don't flood with face events, how about 10 seconds?
                _misty.Wait(10000);
                _misty.RegisterFaceRecognitionEvent(ProcessFaceRecognitionEvent, 100, false, null, null, null);
                _assetWrapper.ShowSystemImage(SystemImage.Amazement);
            }
            catch (Exception ex)
            {
                _misty.SkillLogger.Log("Failed to process the face recognition event.", ex);
            }
        }
        /// <summary>
        /// Callback called when a face is detected or recognized
        /// </summary>
        /// <param name="faceRecEvent"></param>
        private void FaceRecCallback(IFaceRecognitionEvent faceRecEvent)
        {
            string audioFile;

            if (_busyTalking)
            {
                return;
            }

            if (faceRecEvent.Label == "unknown person")
            {
                // Save randomness for future use
                // AudioDetails randomAudio = _audioList[_randomGenerator.Next(0, _audioList.Count - 1)];
                // ImageDetails randomImage = _imageList[_randomGenerator.Next(0, _imageList.Count - 1)];
                _misty.DisplayImage(eyeImages[_randomGenerator.Next(0, eyeImages.Length - 1)], 1, null);
                audioFile = "Misty_Hi.wav";
                if (AudioFileExist(audioFile))
                {
                    _misty.PlayAudio(audioFile, 80, null);
                }
                else
                {
                    _misty.PlayAudio("s_Awe.wav", 80, null);
                }
            }
            else
            {
                if (faceRecEvent.Label == "Daddy")
                {
                    _misty.DisplayImage("e_EcstacyStarryEyed.jpg", 1, null);
                    audioFile = "Misty_Hi_Daddy.wav";
                }
                else
                {
                    _misty.DisplayImage("e_Joy.jpg", 1, null);
                    audioFile = "Misty_Hi.wav";
                }

                if (AudioFileExist(audioFile))
                {
                    _misty.PlayAudio(audioFile, 80, null);
                }
                else
                {
                    _misty.PlayAudio("s_Awe.wav", 80, null);
                }
            }

            if (!_misty.Wait(5000))
            {
                return;
            }
            _misty.DisplayImage("e_DefaultContent.jpg", 1, null);
            if (!_misty.Wait(5000))
            {
                return;
            }
            _misty.RegisterFaceRecognitionEvent(FaceRecCallback, 0, false, null, null, null);
        }
Esempio n. 4
0
		/// <summary>
		/// Callback called when a face is detected or recognized
		/// </summary>
		/// <param name="faceRecEvent"></param>
		private void FaceRecCallback(IFaceRecognitionEvent faceRecEvent)
		{
			if (faceRecEvent.Label == "unknown person")
			{
				AudioDetails randomAudio = _audioList[_randomGenerator.Next(0, _audioList.Count - 1)];
				ImageDetails randomImage = _imageList[_randomGenerator.Next(0, _imageList.Count - 1)];
				_misty.DisplayImage(randomImage.Name, 1, null);
				_misty.PlayAudio(randomAudio.Name, 100, null);
			}
			else
			{
				if (faceRecEvent.Label == "Adrian")
				{
					_misty.DisplayImage("e_EcstacyStarryEyed.jpg", 1, null);
					//_misty.PlayAudio("s_Ecstacy.wav", 100, null);
					_misty.Speak("You are awesome Adrian!", true, "1", null);
				}
				else
				{
					if (faceRecEvent.Label == "Sharina")
					{
						_misty.DisplayImage("e_Love.jpg", 1, null);
						//_misty.PlayAudio("s_Love.wav", 100, null);
						_misty.Speak("I love you Sharina", true, "1", null);
					}
					else
					{
						_misty.DisplayImage("e_Confused.jpg", 1, null);
						_misty.PlayAudio("s_Confused.wav", 100, null);
						_misty.Speak("Who are you?", true, "1", null);
					}
				}
			}
			
			if(!_misty.Wait(5000)) { return; }
			_misty.DisplayImage("e_ContentLeft.jpg", 1, null);
			if (!_misty.Wait(5000)) { return; }
			_misty.RegisterFaceRecognitionEvent(FaceRecCallback, 0, false, null, null, null);
		}