public IActionResult OnGet() { Predictions = _predictionData.GetAll(); var EntityGames = Predictions.Select(p => p.Game).Distinct().OrderBy(g => g.Order); Games = new List <GameEditModel>(); foreach (var game in EntityGames) { if (Games.All(g => g.Id != game.Id)) { Games.Add(_gameConverter.ToEditModel(game)); } } Users = _userData.GetAll(); TotalScores = new Dictionary <int, int>(); foreach (var user in Users) { var total = 0; foreach (var p in Predictions.Where(p => p.User.Id == user.Id)) { total += _scoreCalculator.Calculate(p.Game.HalftimeScore, p.Game.FulltimeScore, p.HalftimeScore, p.FulltimeScore); } TotalScores.Add(user.Id, total); } return(Page()); }
/// <summary> /// Serialize the current object to storage /// </summary> /// <param name="predictions">predictions</param> /// <param name="captureNum">integer to make the file unique</param> public void SaveHologram(int captureNum) { var texture = GetComponent <Renderer>().sharedMaterial.GetTexture("_MainTex") as Texture2D; var imageBytes = texture.GetRawTextureData(); var holoObj = new Holo() { confidences = Predictions.Select(p => p.Confidence).ToList(), labels = Predictions.Select(p => p.Label).ToList(), predictedRects = Predictions.Select(p => p.Rect).ToList(), image = imageBytes, cameraToWorldMatrix = camera2WorldFloat, projectionMatrix = projectionFloat, x = transform.position.x, y = transform.position.y, z = transform.position.z, qx = transform.rotation.x, qy = transform.rotation.y, qz = transform.rotation.z, qw = transform.rotation.w, width = texture.width, height = texture.height, headX = HeadPos.x, headY = HeadPos.y, headZ = HeadPos.z }; string path = Path.Combine(Application.persistentDataPath, $"{FilePrefix}{captureNum++}.json"); HoloSaver.Instance.SaveHologram(holoObj, path); }