Smoothing data from a sensor

前端 未结 5 539
抹茶落季
抹茶落季 2020-11-29 17:06

I have a 3D sensor which measures v(x,y,z) data. I\'m only using the x and y data. Smoothing only x and y would be enough.

If I use a log to show the data, it shows

5条回答
  •  无人及你
    2020-11-29 17:27

    Digging up an old question here, but if you're in .NET land, you can use the RX to do this for you.

    For example, using RX in conjunction with WebClient.DownloadFileAsync to calculate a "smoothed" download speed:

    double interval = 2.0; // 2 seconds
    long bytesReceivedSplit = 0;
    
    WebClient wc = new WebClient();
    var downloadProgress = Observable.FromEventPattern<
        DownloadProgressChangedEventHandler, DownloadProgressChangedEventArgs>(
        h => wc.DownloadProgressChanged += h,
        h => wc.DownloadProgressChanged -= h)
        .Select(x => x.EventArgs);
    
    downloadProgress.Sample(TimeSpan.FromSeconds(interval)).Subscribe(x =>
        {
            Console.WriteLine((x.BytesReceived - bytesReceivedSplit) / interval);
            bytesReceivedSplit = x.BytesReceived;
        });
    
    Uri source = new Uri("http://someaddress.com/somefile.zip");
    wc.DownloadFileAsync(source, @"C:\temp\somefile.zip");
    

    Obviously the longer the interval, the greater the smoothing will be, but also the longer you will have to wait for an initial reading.

提交回复
热议问题