private FrameStats ProceedPredictions(Predictions predictions) { var frameStats = new FrameStats(); foreach (var prediction in predictions.predictions) { if (prediction.probability > Threshold) { if (prediction.tagName.Equals("Car")) { frameStats.NbOfCars++; } else if (prediction.tagName.Equals("Person_BadMask")) { frameStats.NbOfPeopleWithOutMask++; frameStats.NbOfPeopleOnImage++; } else if (prediction.tagName.Equals("Person_GoodMask")) { frameStats.NbOfPeopleWithMask++; frameStats.NbOfPeopleOnImage++; } else if (prediction.tagName.Equals("Person_Rear")) { frameStats.NbOfPeopleOnImage++; } } } return(frameStats); }
private void ProcessFrameStats(BasePacketHeader packet) { FrameStatsMessage frameStatsMessage = FrameStatsMessage.Parser.ParseFrom(packet.PacketBytes, packet.startOfPacketData, packet.messageHeader.DataSize); FrameStats frameStats = new FrameStats(); frameStats.ImportFromPacket(frameStatsMessage); ConstructedFrameStats.Add(packet.messageHeader.FrameId, frameStats); }
public FrameStats getStatistics() { FrameStats ret = new FrameStats(OgrePINVOKE.RenderTarget_getStatistics(swigCPtr), false); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
private void ProcessUpdate() { FrameStats frameStats = GetFrameStats(); bDidLoop = false; int num1 = frameStats.dspBufferCount - lastFrameStats.dspBufferCount; double bufferSampleLength1 = GetBufferSampleLength(frameStats.pitch); double bufferSampleLength2 = GetBufferSampleLength(lastFrameStats.pitch); int samplesRemaining = GetAudioEndSampleExtent() - GetAudioStartSampleExtent() + 1; double num3 = (lastFrameStats.sourceSampleTime + num1 * Math.Max(bufferSampleLength1, bufferSampleLength2)) % samplesRemaining; double num4 = Math.Max(bufferSampleLength1, bufferSampleLength2) * 2.0; double num5 = num3 - num4; double num6 = num3 + num4; if ((num6 <= samplesRemaining && (frameStats.sourceSampleTime > num6 || frameStats.sourceSampleTime < num5) || num6 > samplesRemaining && frameStats.sourceSampleTime < lastFrameStats.sourceSampleTime && ((frameStats.sourceSampleTime + samplesRemaining) > num6 || (frameStats.sourceSampleTime + samplesRemaining) < num5)) && Time.frameCount != 1) { // estimatedSamplePosition = frameStats.sourceSampleTime; } else { double num7 = 0.0; double num8 = bufferSampleLength1 * num7; double num9 = bufferSampleLength1 * (1.0 - num7); double sourceSampleTime = frameStats.sourceSampleTime; double num10 = estimatedSamplePosition + GetRawFrameTime() * (double)outputSampleRate * frameStats.pitch; double num11; if (sourceSampleTime < estimatedSamplePosition) { if (sourceSampleTime + bufferSampleLength2 * num7 >= estimatedSamplePosition && frameStats.sourceSampleTime == lastFrameStats.sourceSampleTime) { num11 = Clamp(num10, sourceSampleTime - num9, sourceSampleTime + num8); } else { double num12 = sourceSampleTime + samplesRemaining; num11 = Clamp(num10, num12 - num9, num12 + num8); } } else { num11 = sourceSampleTime <= estimatedSamplePosition?Clamp(num10, sourceSampleTime - num9, sourceSampleTime + num8) : (sourceSampleTime + bufferSampleLength2 * num7 < estimatedSamplePosition + (double)samplesRemaining || frameStats.sourceSampleTime != this.lastFrameStats.sourceSampleTime ? Clamp(num10, sourceSampleTime - num9, sourceSampleTime + num8) : Clamp(num10 + (double)samplesRemaining, sourceSampleTime - num9, sourceSampleTime + num8) - (double)samplesRemaining); } if (num11 >= samplesRemaining) { num11 -= samplesRemaining; bDidLoop = true; } // estimatedSamplePosition = num11; } lastFrameStats = frameStats; }
public FMODAudioVisor(EventInstance fmodInstance, Koreographer targetKoreographer, AudioClip clip) { koreographerCom = targetKoreographer; if (koreographerCom == null) { koreographerCom = Koreographer.Instance; } this.clip = clip; audioCom = fmodInstance; AudioSettings.OnAudioConfigurationChanged += UpdateAudioConfiguration; UpdateAudioConfiguration(false); lastFrameStats = GetFrameStats(); audioCom.getDescription(out evtDescription); sourceSampleTime = GetAudioSampleTime(); }
/// <summary> /// Start engine rendering. /// </summary> /// Shamelessly taken from Gorgon. public static void Go() { SFML_Threadlock = new System.Threading.Mutex(); if (!IsInitialized) { Initialize(); } Idle += (delegate(object sender, FrameEventArgs e) { SFML_Threadlock.ReleaseMutex(); System.Threading.Thread.Sleep(10); // maybe pickup vsync here? SFML_Threadlock.WaitOne(); }); if ((Screen != null) && (_currentTarget == null)) { throw new InvalidOperationException("The render target is invalid."); } if (IsRunning) { return; } _timer.Restart(); FrameStats.Reset(); if (_currentTarget != null) { for (int i = 0; i < _currentTarget.Length; i++) { if (_currentTarget[0] != null) { //update targets and viewport } } } IsRunning = true; }
public Task <IList <FrameStats> > GetRandomMovieStats(string movieName) { var rand = new Random(); var stats = new List <FrameStats>(); for (var i = 0; i < 20; i++) { var temp_stats = new FrameStats(); temp_stats.FrameNb = i; temp_stats.NbOfCars = 2 - rand.Next(-2, 1); temp_stats.NbOfCyclers = 3 - rand.Next(-3, 1); temp_stats.NbOfPeopleOnImage = i * 2; temp_stats.NbOfPeopleWithMask = i + 3; temp_stats.NbOfPeopleWithOutMask = temp_stats.NbOfPeopleOnImage - temp_stats.NbOfPeopleWithMask - rand.Next(0, 5); temp_stats.NbOfPeopleWithOutMask = Math.Abs(temp_stats.NbOfPeopleWithOutMask); stats.Add(temp_stats); } return(Task.FromResult <IList <FrameStats> >(stats)); }
/// <summary> /// Start engine rendering. /// </summary> /// Shamelessly taken from Gorgon. public static void Go() { if (!IsInitialized) { Initialize(); } FrameEvent += (delegate(object sender, FrameEventArgs e) { System.Threading.Thread.Sleep(10); // maybe pickup vsync here? }); if ((Screen != null) && (renderTargetArray == null)) { throw new InvalidOperationException("Something has gone terribly wrong!"); } if (IsRunning) { return; } _timer.Restart(); FrameStats.Reset(); if (renderTargetArray != null) { for (int i = 0; i < renderTargetArray.Length; i++) { if (renderTargetArray[0] == null) { renderTargetArray[0] = Screen; } } } IsRunning = true; }
public FrameStatsPropertyWrapper(FrameStats stats) { WrappedFrameStats = stats; }
public async Task <List <FrameStats> > GetMovieStats(string movieName) { var isMovieDownloaded = _movieService.DownloadMovie(movieName); var result = new FrameStats(); if (isMovieDownloaded) { var path = Directory.GetCurrentDirectory(); var input_path = Path.Combine(path, "downloads", $"{movieName}"); // var output_path = Path.Combine(path, "uploads", $"{movieName}"); try { FFmpeg.SetExecutablesPath(Path.Combine(path, "ffmpeg")); var info = await FFmpeg.GetMediaInfo(input_path); var duration = info.Duration; // Iterujemy po filmie var samplingRate = 2; for (int sec = 0; sec < duration.Seconds; sec += samplingRate) { var output_path = Path.Combine(path, "uploads", $"snapshot_{sec}.png"); var conversion = await FFmpeg.Conversions.FromSnippet.Snapshot( input_path, output_path, TimeSpan.FromSeconds(sec)); var res = conversion.Start(); } } catch (Exception e) { Console.WriteLine(e.Message); } // Weź wszystkie obrazki z lokalizacji --> Przeanalizuj var movieStats = new List <FrameStats>(); try { var img_paths = Path.Combine(path, "uploads"); var allFiles = Directory.GetFiles(img_paths); var i = 0; foreach (var filePath in allFiles) { var stat = new FrameStats(); // Open the stream and read it back. using (var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None)) { stat = _movieService.GetFrameStats(fs); } File.Delete(filePath); stat.FrameNb = i++; movieStats.Add(stat); } } catch (Exception e) { Console.WriteLine(e.Message); } return(movieStats); // var conversion = await FFmpeg.Conversions.FromSnippet.Snapshot( // input_path, output_path, TimeSpan.FromSeconds(2)); // var res = await conversion.Start(); // var info = await FFmpeg.GetMediaInfo(input_path); // var videoStream = info.VideoStreams.First() // .SetCodec(VideoCodec.h264) // .SetSize(VideoSize.Hd480); // // await Conversion.New() // .AddStream(videoStream) // .SetOutput(output_path) // .Start(); // using (var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None)) // { // var frames = _movieService.GetFramesFromFile(fs); // } } var smsm = new List <FrameStats>(); var a = new FrameStats(); a.NbOfPeopleWithOutMask = 99; smsm.Add(a); return(smsm); // return new List<FrameStats>(); // var path = // $"C:\\Users\\adamk\\OneDrive\\Pulpit\\KODOWANIE\\Hackatony\\CodeNight\\InvigilationApp\\uploads\\7-min.PNG"; // // var result = new FrameStats(); // // Open the stream and read it back. // using (var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None)) // { // result = _movieService.GetFrameStats(fs); // } // return Task.FromResult<IList<FrameStats>>(stats); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FrameStats obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }