Ejemplo n.º 1
0
            public SequenceMetadata GetMetadata(Func <T, double> GetAccel = null, int startIndex = 0, int count = -1)
            {
                // Establish the actual defaults based on the passed parameters.
                count    = (count <= 0 || count + startIndex > VectorProvider.LoggedData.Count) ? VectorProvider.LoggedData.Count - startIndex : count;
                GetAccel = GetAccel ?? SequenceMetadata.GetOverallMagnitude;

                // Initialize the result with the relevant
                var result = new SequenceMetadata()
                {
                    NumPoints = count,
                    Delay     = VectorProvider.Timestamps.ElementAtOrDefault(startIndex),
                    Duration  = VectorProvider.Timestamps.ElementAtOrDefault(startIndex + count - 1) - VectorProvider.Timestamps.ElementAtOrDefault(startIndex)
                };

                //Android.Util.Log.Debug("MachineLearning|MLStage", $"Sequence logged with {count} points, {result.Delay.TotalMilliseconds} ms delay, and {result.Duration.TotalMilliseconds} ms duration.");
                //Android.Util.Log.Debug("MachineLearning|MLStage", $"Timestamps went from {VectorProvider.Timestamps[0].TotalMilliseconds:f1}, {VectorProvider.Timestamps[1].TotalMilliseconds:f1}, {VectorProvider.Timestamps[2].TotalMilliseconds:f1}, to {VectorProvider.Timestamps.Last().TotalMilliseconds:f1} ");

                // Scan through (while we have the data to do so) and get the peak accel value using the supplied function
                foreach (int i in Enumerable.Range(startIndex, count))
                {
                    result.PeakAccel = Math.Max(result.PeakAccel, GetAccel(VectorProvider.LoggedData.ElementAtOrDefault(i)));
                }

                // We can't get the Quality Score yet - have to fill that in after analysis (see Classifier.Recognize()).
                return(result);
            }
Ejemplo n.º 2
0
 // When we assess a representative of this class, we use this to update the characteristics of the gesture.
 public void UpdateMetadata(SequenceMetadata newData)
 {
     AverageMetadata.QualityScore = rollinAverage(AverageMetadata.QualityScore, newData.QualityScore);
     AverageMetadata.Delay        = rollinAverage(AverageMetadata.Delay, newData.Delay);
     AverageMetadata.Duration     = rollinAverage(AverageMetadata.Duration, newData.Duration);
     AverageMetadata.NumPoints    = rollinAverage(AverageMetadata.NumPoints, newData.NumPoints);
     AverageMetadata.PeakAccel    = rollinAverage(AverageMetadata.PeakAccel, newData.PeakAccel);
     numMetadataPoints++;
     Android.Util.Log.Debug("MachineLearning|GC", $"Updating average metadata for {className} to Qual {AverageMetadata.QualityScore}, Delay {AverageMetadata.Delay.TotalMilliseconds}, Duration {AverageMetadata.Duration.TotalMilliseconds}, #pts {AverageMetadata.NumPoints}, and peak accel {AverageMetadata.PeakAccel}.");
 }
Ejemplo n.º 3
0
 public void ResetMetadata()
 {
     AverageMetadata   = new SequenceMetadata();
     numMetadataPoints = 0;
 }