public GestureCreatorMatchingTask(List <MyoDataProfile> toMatch, MyomiGestureOptions toMatchOptions) { this.ToMatch = toMatch; this.ToMatchOptions = toMatchOptions; this.ToMatchFrameIndex = 0; this.CurrentFrameRepeat = 0; }
private Result Analyze(PoseProfileData profile, MyomiGestureOptions options) { //we might have an edge or soft mode where a swift transition from one pose to another will have a leeway time if (!options.PoseEnabled) { return(Result.NotAnalyzed); } if (profile.Pose == this.Data.Pose) { return(Result.Match); } else { if (!(profile.Pose == Pose.Rest && this.Data.Pose == Pose.Rest)) { return(Result.NotRest); } else { return(Result.NoMatch); } } }
private MyomiGestureOptions SetOptions() { var options = new MyomiGestureOptions(); Console.WriteLine("Would you like to change any of the default configurations for this gesture?"); if (CommonOperations.GetYesOrNo()) { return(options); } EnableComponents("pose"); options.PoseEnabled = CommonOperations.GetYesOrNo(); EnableComponents("acceleration"); options.AccelEnabled = CommonOperations.GetYesOrNo(); EnableComponents("gyroscope"); options.GyroEnabled = CommonOperations.GetYesOrNo(); EnableComponents("orientation"); options.OrienEnabled = CommonOperations.GetYesOrNo(); SetAsNormal("acceleration"); options.AccelNormOnly = CommonOperations.GetYesOrNo(); SetAsNormal("gyroscope"); options.GyroNormOnly = CommonOperations.GetYesOrNo(); Console.WriteLine("Would you like to use half mode for orientation only?"); Console.WriteLine("Half mode will only split orientation into 2 halves instead of 4 quarters for processing."); options.OrienHalfMode = CommonOperations.GetYesOrNo(); Console.WriteLine("Would you like to ignore the frame counts for this gesture?"); options.IgnoreFrameCounts = CommonOperations.GetYesOrNo(); return(options); }
//here, we create a myomi gesture profile from the data and options given private MyomiGesture AnalyzeData(List <MyoData> data, MyomiGestureOptions options) { //the idea is that we are comparing it frame by frame var profileFrames = new List <MyoDataProfile>(); //we want to isolate the first frame for comparison, the prev frame will be the first unique frame listed var prevFrame = data.First(); profileFrames.Add(MyoDataProfile.ConvertToProfile(prevFrame)); data.RemoveAt(0); //this is just original data profiling, later, we need to create a new profile based on the options foreach (var dataFrame in data) { //returning 1 would mean they are the same if (prevFrame.CompareTo(dataFrame) == 1) { profileFrames.Last().Frames++; } else { //they are different, so we have a new frame set, we want this as the unique frame now profileFrames.Add(MyoDataProfile.ConvertToProfile(dataFrame)); prevFrame = dataFrame; } } return(new MyomiGesture(options, profileFrames)); }
public int Evaluator(MyoDataProfile toCompare, MyomiGestureOptions options, int initialScore) { //initial score should be 100 unless there's frame mismatches int score = initialScore; score -= _poseAnalyzer.GetPoint(toCompare.Pose, options); score -= _accelAnalyzer.GetPoint(toCompare.Accel, options); score -= _gyroAnalyzer.GetPoint(toCompare.Gyro, options); score -= _orienAnalyzer.GetPoint(toCompare.Orien, options); return(score); }
private bool CalibrateGesture(MyomiGesture gesture, MyomiGestureOptions options) { var task = new GestureCreatorMatchingTask(gesture.SegmentsWithOptions, options); var manager = new MyomiTaskManager(Context.Instance.DefaultFrequency, task); for (int i = 0; i < 3 || task.Matched; i++) { var taskThread = new Thread(manager.Run); taskThread.Start(); //sleep until it has finished while (!manager.StopExecution) { } if (!task.Matched) { return(false); } } return(true); }
public int GetPoint(OrientationProfileData profile, MyomiGestureOptions options) { if (!options.OrienEnabled) { return(CalculatePoint(Result.NotAnalyzed)); } if (options.OrienHalfMode) { Data.Pitch = CommonOperations.GetHalfModeValue(Data.Pitch); Data.Roll = CommonOperations.GetHalfModeValue(Data.Roll); Data.Azimuth = CommonOperations.GetHalfModeValue(Data.Azimuth); } int points = 0; var result = Analyze(profile.Pitch, Data.Pitch); points += CalculatePoint(result); result = Analyze(profile.Roll, Data.Roll); points += CalculatePoint(result); result = Analyze(profile.Azimuth, Data.Azimuth); points += CalculatePoint(result); return(points); }
public int GetPoint(GyroscopeProfileData profile, MyomiGestureOptions option) { if (!option.GyroEnabled) { return(CalculatePoint(Result.NotAnalyzed)); } else if (option.GyroNormOnly) { var result = Analyze(profile.Normal, Data.Normal); return(CalculatePoint(result)); } //full analysis else { int points = 0; var result = Analyze(profile.X, Data.X); points += CalculatePoint(result) / 3; result = Analyze(profile.Y, Data.Y); points += CalculatePoint(result) / 3; result = Analyze(profile.Z, Data.Z); points += CalculatePoint(result) / 3; return(points); } }
public int GetPoint(PoseProfileData profile, MyomiGestureOptions options) { Result result = Analyze(profile, options); switch (result) { case Result.NotAnalyzed: return(Context.Instance.Points.NotAnalyzedPose); case Result.Match: return(Context.Instance.Points.Match); case Result.NotRest: return(Context.Instance.Points.NotRestPose); case Result.NoMatch: return(Context.Instance.Points.NoMatchPose); default: //should never happen, but if it does, count it as invalid Console.Write("Invalid result of {0} for pose", result); return(100); } }