Пример #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                if (!PiMonitRHub._isStreamRunning)
                {
                    var stream = await _piCameraService.CapturePictureAsStream();

                    //Testing without rasperry PI with the below line of code
                    //var stream = new MemoryStream(System.IO.File.ReadAllBytes("cry.jpg"));
                    if (await _faceClientCognitiveService.IsCryingDetected(stream))
                    {
                        await _piMonitRHub.Clients.All.SendAsync("ReceiveNotification", "Baby Crying Detected! You want to start streaming?");
                    }
                }
                //Run the background service for every 10 seconds
                await Task.Delay(10000);
            }
        }