Exemplo n.º 1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            // load Model
            var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///emotion_ferplus.onnx"));

            model = await emotion_ferplusModel.CreateFromStreamAsync(file);

            labels = new List <string>()
            {
                "Neutral",
                "Happiness",
                "Surprise",
                "Sadness",
                "Anger",
                "Disgust",
                "Fear",
                "Contempt"
            };

            currentEmotionIndex = 1; //happiness
            EmotionText.Text    = $"Show {labels[currentEmotionIndex]} to Snooze";

            faceDetector = await FaceDetector.CreateAsync();

            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(300);
            timer.Tick    += Timer_Tick;
            timer.Start();

            await camera.StartAsync();

            camera.CameraHelper.FrameArrived += Preview_FrameArrived;
        }
Exemplo n.º 2
0
        public static async Task <emotion_ferplusModel> CreateFromStreamAsync(IRandomAccessStreamReference stream)
        {
            emotion_ferplusModel learningModel = new emotion_ferplusModel();

            learningModel.model = await LearningModel.LoadFromStreamAsync(stream);

            learningModel.session = new LearningModelSession(learningModel.model);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }