private void Predictter() { while (!predictCancellationTokenSource.IsCancellationRequested) { try { if (emgDataList.Count < WinLength) { continue; } try { GestureMavResult = _emgClassifier.GetMAV(emgDataList.GetRange(emgDataList.Count - WinLength, WinLength)); GestureResult = GestureMavResult < ClassMav[0] * ThresholdMavFactor ? 0 : _emgClassifier.Predict(emgDataList.GetRange(emgDataList.Count - WinLength, WinLength)); ResultGenerated?.Invoke(null, new[] { GestureResult, GestureMavResult / ClassMav[GestureResult] }); } catch (Exception) { // } //IntResultGenerated?.Invoke(null,GestureResult); // List<double> resultMavDoubles = new List<double>(){0,0,0,0,0,0,0}; var resultDoubles = new List <double>() { 0, 0, 0, 0, 0, 0, 0 }; resultDoubles[GestureResult] = 1; //resultMavDoubles[GestureResult] = GestureMavResult; ResultData.Add(resultDoubles); lock (emgLock) emgDataList.RemoveRange(0, StepLength); } catch (Exception) { //Console.WriteLine(e); } } }
protected void _Finish() { ResultGenerated?.Invoke(PossibleResult <TOut> .Done()); }
protected void _Notify(TOut result) { ResultGenerated?.Invoke(PossibleResult <TOut> .Of(result)); }
protected void _Err(Exception error) { ResultGenerated?.Invoke(PossibleResult <TOut> .Of(error)); }