private async Task ShowPredictionResults(CustomVisionModelOutput output, double latency) { List <Tuple <string, float> > result = output.GetPredictionResult(); Tuple <string, float> topMatch = result?.Where(x => x.Item2 > MinProbabilityValue)?.OrderByDescending(x => x.Item2).FirstOrDefault(); // Update tags in the result panel if (topMatch != null && topMatch.Item1 != "Negative") { if (_lastMatchLabel != topMatch.Item1) { _lastMatchLabel = topMatch.Item1; // if we want to only send alerts when a detected class changes, use this line instead //IoTHubHelper.Instance.SendDetectedClassAlertToCloudsync(topMatch.Item1, topMatch.Item2); UpdateSenseHatLights(lightsOn: true); } await IoTHubWrapper.Instance.SendDetectedClassAlertToCloudAsync(topMatch.Item1, Math.Round(topMatch.Item2, 2)); await UpdateStatus("Scoring", $"{topMatch.Item1} ({Math.Round(topMatch.Item2 * 100)}%)", $"{Math.Round(1000 / latency)}fps", sendMessageToIoTHub : false); } else { _lastMatchLabel = null; UpdateSenseHatLights(lightsOn: false); await UpdateStatus("Scoring", "Nothing detected", $"{Math.Round(1000 / latency)}fps"); } }
private async Task ShowPredictionResults(CustomVisionModelOutput output, double latency) { string fpsValue = latency > 0 ? $"{Math.Round(1000 / latency)} fps" : string.Empty; List <Tuple <string, float> > result = output.GetPredictionResult(); Tuple <string, float> topMatch = result?.Where(x => x.Item2 > MinProbabilityValue)?.OrderByDescending(x => x.Item2).FirstOrDefault(); // Update tags in the result panel if (topMatch != null && topMatch.Item1 != CustomVisionServiceWrapper.NegativeTag) { await UpdateStatus(topMatch.Item1, Math.Round(topMatch.Item2 * 100), fpsValue); } else { await UpdateStatus("Nothing detected", details : fpsValue); } }