public bool Compared(IReadOnlyDictionary <JointType, Joint> joints3, out RecognitionResult result) { return(Compared(joints3, AllowableAngularError, AllowableKeyBoneError, out result)); }
public bool Compared(IReadOnlyDictionary <JointType, Joint> joints3, float angularError, float keyBoneError, out RecognitionResult result) { result = new RecognitionResult() { AttitudeName = this.ActionName, InfoMessages = "" }; if (0 < Index && Index < ActionFrames.Count - 1) { bool temp = ActionFrames[Index].Compared(joints3, JointAngles, KeyBones, angularError, keyBoneError, out result.InfoMessages); if (Index % 20 == 0) { result.InfoMessages = $"动作已完成{(Index * 0.1 / ActionFrames.Count * 100).ToString("####")}%,加油!"; } Index++; return(temp); } if (Index == 0 && !ActionFrames[Index].IsCompared) //第一帧 { bool temp = ActionFrames[Index].Compared(joints3, JointAngles, KeyBones, angularError, keyBoneError, out result.InfoMessages); if (temp) { Index++; return(true); } result.InfoMessages = "请做好准备动作"; return(false); } if (Index == ActionFrames.Count - 1) //最后一帧 { if (!ActionFrames[Index].IsCompared) { bool temp = ActionFrames[Index].Compared(joints3, JointAngles, KeyBones, angularError, keyBoneError, out result.InfoMessages); if (temp) { result.InfoMessages = $"请保持{LastFrameDurationTime}秒,坚持住!"; starTime = DateTime.Now; } return(temp); } else { bool temp = ActionFrames[Index].Compared(joints3, JointAngles, KeyBones, angularError, keyBoneError, out result.InfoMessages); if (temp) { double span = LastFrameDurationTime - (DateTime.Now - starTime).TotalSeconds; if (span <= 0) { result.InfoMessages = "动作已经对比完成"; IsCompared = true; return(true); } result.InfoMessages = $"请再坚持{span.ToString("0")}秒!"; return(false); } else { starTime = DateTime.Now; return(false); } } } return(true); }
/// <summary> /// 模型帧与目标帧做对比 /// </summary> /// <param name="jointAngleList">要对比的骨骼帧关节角度列表</param> /// <param name="keyBoneList">要对比的骨骼帧关键骨骼列表</param> /// <param name="result">对比的提示信息</param> /// <returns></returns> public bool Compared(List <JointAngle> jointAngleList, List <KeyBone> keyBoneList, out RecognitionResult result) { this.IsCompared = Compared(jointAngleList, keyBoneList, this.AllowableAngularError, this.AllowableKeyBoneError, out result); return(this.IsCompared); }