public Owas(CostaPosicao bp, BracosPosicao ap, PernasPosicao lp, Weigth weight) { this.BackPosition = bp; this.ArmsPosition = ap; this.LegsPosition = lp; this._Weight = weight; }
public String updateLegsPosition(long start, long end, PernasPosicao lp) { if (start > end) { return(""); } String fileName = this.FileName; String xml = ""; XElement root = XElement.Load(fileName); IEnumerable <XElement> frame = from el in root.Elements("Frame") where (long)el.Attribute("timestamp") >= start select el; foreach (XElement el in frame) { if ((long)(Double.Parse(el.Attribute("timestamp").Value)) < end) { el.Attribute("legs").Value = lp.ToString(); xml += el.ToString(); } else { break; } } root.Save(fileName); return(xml); }
public PernasPosicao getPernasPosition() { PernasPosicao posicao = PernasPosicao.Desconhecida; if (this._Skeleton != null) { posicao = this.GetLegsClassification(FloorClipPlane); } return(posicao); }
public String updateLegsPosition(String timestamp, PernasPosicao lp) { String fileName = this.FileName; String xml = ""; XElement root = XElement.Load(fileName); IEnumerable <XElement> frame = from el in root.Elements("Frame") where (string)el.Attribute("timestamp") == timestamp select el; foreach (XElement el in frame) { el.Attribute("legs").Value = lp.ToString(); xml += el.ToString(); } root.Save(fileName); return(xml); }
public static Results riskLegs(PernasPosicao pp, double percent) { //Duas pernas retas if (pp == PernasPosicao.twoLegUp) { if (percent < 90) { return(Results.Nivel1); } else { return(Results.Nivel2); } } //Uma perna reta else if (pp == PernasPosicao.OneLegUp) { if (percent < 80) { return(Results.Nivel1); } else { return(Results.Nivel2); } } //Duas pernas flexionadas else if (pp == PernasPosicao.twoLegFlex) { if (percent < 30) { return(Results.Nivel1); } else if (percent >= 30 && percent < 80) { return(Results.Nivel2); } else { return(Results.Nivel3); } } //Uma perna flexionada else if (pp == PernasPosicao.OneLegFlex) { if (percent < 10) { return(Results.Nivel1); } else if (percent >= 10 && percent < 30) { return(Results.Nivel2); } else if (percent >= 30 && percent < 80) { return(Results.Nivel3); } else { return(Results.Nivel4); } } //Perna ajoelhada else if (pp == PernasPosicao.OneLegknee) { if (percent < 10) { return(Results.Nivel1); } else if (percent >= 10 && percent < 30) { return(Results.Nivel2); } else if (percent >= 30 && percent < 80) { return(Results.Nivel3); } else { return(Results.Nivel4); } } return(Results.Nivel1); }
public PernasPosicao GetLegsClassification(Tuple <float, float, float, float> FloorPlane) { Skeleton skeleton = this._Skeleton; //Legs Position SkeletonPoint SkeletonPointAnkleLeft = new SkeletonPoint(); SkeletonPoint SkeletonPointAnkleRight = new SkeletonPoint(); SkeletonPoint SkeletonPointKneeLeft = new SkeletonPoint(); SkeletonPoint SkeletonPointKneeRight = new SkeletonPoint(); SkeletonPoint SkeletonPointHipLeft = new SkeletonPoint(); SkeletonPoint SkeletonPointHipRight = new SkeletonPoint(); PernasPosicao posicaoPernas = PernasPosicao.Desconhecida; //+(13) Position:{Microsoft.Kinect.SkeletonPoint} JointType:KneeLeft {13} TrackingState:Inferred {1} Microsoft.Kinect.Joint //+(14) Position:{Microsoft.Kinect.SkeletonPoint} JointType:AnkleLeft {14} TrackingState:Inferred {1} Microsoft.Kinect.Joint //+(15) Position:{Microsoft.Kinect.SkeletonPoint} JointType:FootLeft {15} TrackingState:Inferred {1} Microsoft.Kinect.Joint //+(17) Position:{Microsoft.Kinect.SkeletonPoint} JointType:KneeRight {17} TrackingState:Inferred {1} Microsoft.Kinect.Joint //+(18) Position:{Microsoft.Kinect.SkeletonPoint} JointType:AnkleRight {18} TrackingState:Inferred {1} Microsoft.Kinect.Joint //+(12) Position:{Microsoft.Kinect.SkeletonPoint} JointType:HipLeft {12} TrackingState:Tracked {2} Microsoft.Kinect.Joint //+(16) Position:{Microsoft.Kinect.SkeletonPoint} JointType:HipRight {16} TrackingState:Tracked {2} Microsoft.Kinect.Joint //+(19) Position:{Microsoft.Kinect.SkeletonPoint} JointType:FootRight {19} TrackingState:Inferred {1} Microsoft.Kinect.Joint if (skeleton.Joints[JointType.KneeRight].TrackingState == JointTrackingState.Tracked) { SkeletonPointKneeRight.X = skeleton.Joints[JointType.KneeRight].Position.X; SkeletonPointKneeRight.Y = skeleton.Joints[JointType.KneeRight].Position.Y; SkeletonPointKneeRight.Z = skeleton.Joints[JointType.KneeRight].Position.Z; } if (skeleton.Joints[JointType.KneeLeft].TrackingState == JointTrackingState.Tracked) { SkeletonPointKneeLeft.X = skeleton.Joints[JointType.KneeLeft].Position.X; SkeletonPointKneeLeft.Y = skeleton.Joints[JointType.KneeLeft].Position.Y; SkeletonPointKneeLeft.Z = skeleton.Joints[JointType.KneeLeft].Position.Z; } if (skeleton.Joints[JointType.FootRight].TrackingState == JointTrackingState.Tracked) { SkeletonPointAnkleRight.X = skeleton.Joints[JointType.FootRight].Position.X; SkeletonPointAnkleRight.Y = skeleton.Joints[JointType.FootRight].Position.Y; SkeletonPointAnkleRight.Z = skeleton.Joints[JointType.FootRight].Position.Z; } if (skeleton.Joints[JointType.FootLeft].TrackingState == JointTrackingState.Tracked) { SkeletonPointAnkleLeft.X = skeleton.Joints[JointType.FootLeft].Position.X; SkeletonPointAnkleLeft.Y = skeleton.Joints[JointType.FootLeft].Position.Y; SkeletonPointAnkleLeft.Z = skeleton.Joints[JointType.FootLeft].Position.Z; } if (skeleton.Joints[JointType.HipRight].TrackingState == JointTrackingState.Tracked) { SkeletonPointHipRight.X = skeleton.Joints[JointType.HipRight].Position.X; SkeletonPointHipRight.Y = skeleton.Joints[JointType.HipRight].Position.Y; SkeletonPointHipRight.Z = skeleton.Joints[JointType.HipRight].Position.Z; } if (skeleton.Joints[JointType.HipLeft].TrackingState == JointTrackingState.Tracked) { SkeletonPointHipLeft.X = skeleton.Joints[JointType.HipLeft].Position.X; SkeletonPointHipLeft.Y = skeleton.Joints[JointType.HipLeft].Position.Y; SkeletonPointHipLeft.Z = skeleton.Joints[JointType.HipLeft].Position.Z; } posicaoPernas = LegOWASClassification(SkeletonPointAnkleRight, SkeletonPointKneeRight, SkeletonPointAnkleLeft, SkeletonPointKneeLeft, SkeletonPointHipLeft, SkeletonPointHipRight, FloorPlane); return(posicaoPernas); }
public PernasPosicao LegOWASClassification(SkeletonPoint SkeletonPointAnkleRight, SkeletonPoint SkeletonPointKneeRight, SkeletonPoint SkeletonPointAnkleLeft, SkeletonPoint SkeletonPointKneeLeft, SkeletonPoint SkeletonPointHipLeft, SkeletonPoint SkeletonPointHipRight, Tuple <float, float, float, float> FloorPlane) { PernasPosicao posicaoPernas = PernasPosicao.Desconhecida; //--------------------------------------------------------------------------------------------------- //Classification of Leg //1) Duas pernas retas: As duas pernas esta no chão (classificação 2 = True) e as duas penas estão retas (classificação 1 = True para as duas pernas) . //2) Uma perna reta : As duas pernas não estão no chão (classificação 2 = False) e uma das pernas está reta ( classificação 1 = False) //3) Duas pernas flexionadas: As duas pernas esta no chão ( classificação 2 = True) e as duas penas não estão retas (classificação 1 =False para as duas pernas) . //4) Uma Perna Flexionada: As duas pernas não estão no chão (classificação 2 = False) e a perna que está no chão não está reta ( classificação 1 = False) //5) Uma perna Ajoelhada: As duas pernas esta no chão ( classificação 2 = True) e as duas pernas estão flexionada (classificação 1 =False para as duas pernas ) e pelo menos uma perna está ajoelhada (classificação 1 = False) //--------------------------------------------------------------------------------------------------- //Inicialize the value Point3D PointHipLeft = new Point3D(); Point3D PointKneeLeft = new Point3D(); Point3D PointHipRight = new Point3D(); Point3D PointKneeRight = new Point3D(); //to do: Mudar parametros da função //IsStraightByDotProduct(SkeletonPointKneeRight, SkeletonPointKneeRight, SkeletonPointHipRight, 2.8) //Perna Reta: Point3Z0GetAngleBetween(XMLSkeletonPointKneeRight, XMLSkeletonPointKneeRight) > 80 //Pé no Chão: IsFloorPlane(SkeletonPointKneeRight, FloorPlane, 0.1) PointHipLeft.X = SkeletonPointHipLeft.X; PointHipLeft.Y = SkeletonPointHipLeft.Y; PointHipLeft.Z = SkeletonPointHipLeft.Z; PointKneeLeft.X = SkeletonPointKneeLeft.X; PointKneeLeft.Y = SkeletonPointKneeLeft.Y; PointKneeLeft.Z = SkeletonPointKneeLeft.Z; PointHipRight.X = SkeletonPointHipRight.X; PointHipRight.Y = SkeletonPointHipRight.Y; PointHipRight.Z = SkeletonPointHipRight.Z; PointKneeRight.X = SkeletonPointKneeRight.X; PointKneeRight.Y = SkeletonPointKneeRight.Y; PointKneeRight.Z = SkeletonPointKneeRight.Z; if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) > 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) & (OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) > 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.35 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.35)) { posicaoPernas = PernasPosicao.OneLegknee; } else { posicaoPernas = PernasPosicao.twoLegUp; } } if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) > 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) | (OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) > 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { posicaoPernas = PernasPosicao.OneLegUp; } if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) <= 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) & (OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) <= 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.3 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.3)) { posicaoPernas = PernasPosicao.OneLegknee; } else { posicaoPernas = PernasPosicao.twoLegFlex; } } if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) <= 80 & OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) <= 80) & (IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1) | IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.3 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.3)) { posicaoPernas = PernasPosicao.OneLegknee; } else { posicaoPernas = PernasPosicao.OneLegFlex; } } return(posicaoPernas); }
public void addPosition(long timestamp, CostaPosicao costaPosicao, BracosPosicao bracoPosicao, PernasPosicao pernasPosicao) { writer.WriteStartElement("Frame"); writer.WriteAttributeString(null, "timestamp", null, timestamp + ""); writer.WriteAttributeString(null, "spine", null, costaPosicao + ""); writer.WriteAttributeString(null, "arms", null, bracoPosicao + ""); writer.WriteAttributeString(null, "legs", null, pernasPosicao + ""); // writer.WriteElementString("timestamp", timestamp + ""); //writer.WriteElementString("timestamp", TimeSpan.FromMilliseconds(timestamp).TotalSeconds+""); //writer.WriteElementString("Spine", (int)((CostaPosicao)Enum.Parse(typeof(CostaPosicao), costaPosicao + ""))+""); //writer.WriteElementString("Arms", (int)((BracosPosicao)Enum.Parse(typeof(BracosPosicao), bracoPosicao + "")) + ""); //writer.WriteElementString("Legs", (int)((PernasPosicao)Enum.Parse(typeof(PernasPosicao), pernasPosicao + "")) + ""); /*writer.WriteElementString("Spine", costaPosicao + ""); * writer.WriteElementString("Arms", bracoPosicao + ""); * writer.WriteElementString("Legs", pernasPosicao + "");*/ writer.WriteEndElement(); }
public List <KeyValuePair <string, double> > RelatorioListLegs() { String fileName = this.FileName; XElement root = XElement.Load(fileName); IEnumerable <XElement> frame = from el in root.Elements("Frame") select el; int[] arms = new int[4]; int[] spine = new int[5]; int[] legs = new int[6]; List <KeyValuePair <string, double> > posicoes = new List <KeyValuePair <string, double> >(); // for (int i = 0; i < arms.Length; i++) { arms[i] = 0; spine[i] = 0; legs[i] = 0; } int index, kindex, jindex; int totalFrames = 0; foreach (XElement el in frame) { index = (int)((BracosPosicao)Enum.Parse(typeof(BracosPosicao), el.Attribute("arms").Value.ToString())); kindex = (int)((CostaPosicao)Enum.Parse(typeof(CostaPosicao), el.Attribute("spine").Value.ToString())); jindex = (int)((PernasPosicao)Enum.Parse(typeof(PernasPosicao), el.Attribute("legs").Value.ToString())); arms[index] += 1; spine[kindex] += 1; legs[jindex] += 1; totalFrames++; } double percent = 0.0; String nomePosicao = "Desconhecida"; PernasPosicao pernasP = PernasPosicao.Desconhecida; for (int i = 1; i < legs.Length; i++) { switch (i) { case 1: nomePosicao = "Pernas estão retas"; pernasP = PernasPosicao.twoLegUp; break; case 2: nomePosicao = "Uma perna está reta"; pernasP = PernasPosicao.OneLegUp; break; case 3: nomePosicao = "Duas pernas flexionadas"; pernasP = PernasPosicao.twoLegFlex; break; case 4: nomePosicao = "Uma perna flexionada"; pernasP = PernasPosicao.OneLegFlex; break; case 5: nomePosicao = "Ajoelhado"; pernasP = PernasPosicao.OneLegknee; break; } percent = ((double)legs[i] / (double)totalFrames * 100); posicoes.Add(new KeyValuePair <string, double>(nomePosicao, percent)); } return(posicoes); }
public void Relatorio(String relatorioName) { String fileName = this.FileName; XElement root = XElement.Load(fileName); IEnumerable <XElement> frame = from el in root.Elements("Frame") select el; int[] arms = new int[4]; int[] spine = new int[5]; int[] legs = new int[6]; for (int i = 0; i < arms.Length; i++) { arms[i] = 0; spine[i] = 0; legs[i] = 0; } int index, kindex, jindex; int totalFrames = 0; // DDebug db = new DDebug(); db.Show(); foreach (XElement el in frame) { index = (int)((BracosPosicao)Enum.Parse(typeof(BracosPosicao), el.Attribute("arms").Value.ToString())); kindex = (int)((CostaPosicao)Enum.Parse(typeof(CostaPosicao), el.Attribute("spine").Value.ToString())); jindex = (int)((PernasPosicao)Enum.Parse(typeof(PernasPosicao), el.Attribute("legs").Value.ToString())); arms[index] += 1; spine[kindex] += 1; legs[jindex] += 1; totalFrames++; } XmlWriter writer = XmlWriter.Create(relatorioName); writer.WriteStartDocument(); writer.WriteStartElement("classOwas"); double percent = 0.0; CostaPosicao costaP = CostaPosicao.Desconhecida; for (int i = 1; i < spine.Length; i++) { percent = ((double)spine[i] / (double)totalFrames * 100); writer.WriteStartElement("member"); writer.WriteAttributeString(null, "name", null, "spine"); switch (i) { case 1: costaP = CostaPosicao.Ereta; break; case 2: costaP = CostaPosicao.Inclinada; break; case 3: costaP = CostaPosicao.EretaETorcida; break; case 4: costaP = CostaPosicao.InclinadaETorcida; break; } writer.WriteAttributeString(null, "position", null, costaP + ""); writer.WriteAttributeString(null, "percent", null, percent + ""); writer.WriteAttributeString(null, "risk", null, Owas.riskSpine(costaP, percent) + ""); writer.WriteEndElement(); } BracosPosicao bracosP = BracosPosicao.Desconhecida; for (int i = 1; i < arms.Length; i++) { switch (i) { case 1: bracosP = BracosPosicao.BothArmsareDown; break; case 2: bracosP = BracosPosicao.OneHandUp; break; case 3: bracosP = BracosPosicao.TwoHandUp; break; } percent = ((double)arms[i] / (double)totalFrames * 100); writer.WriteStartElement("member"); writer.WriteAttributeString(null, "name", null, "arms"); writer.WriteAttributeString(null, "position", null, bracosP + ""); writer.WriteAttributeString(null, "percent", null, percent + ""); writer.WriteAttributeString(null, "risk", null, Owas.riskArms(bracosP, percent) + ""); writer.WriteEndElement(); } PernasPosicao pernasP = PernasPosicao.Desconhecida; for (int i = 0; i < legs.Length; i++) { switch (i) { case 1: pernasP = PernasPosicao.twoLegUp; break; case 2: pernasP = PernasPosicao.OneLegUp; break; case 3: pernasP = PernasPosicao.twoLegFlex; break; case 4: pernasP = PernasPosicao.OneLegFlex; break; case 5: pernasP = PernasPosicao.OneLegknee; break; } percent = ((double)legs[i] / (double)totalFrames * 100); writer.WriteStartElement("member"); writer.WriteAttributeString(null, "name", null, "legs"); writer.WriteAttributeString(null, "position", null, pernasP + ""); writer.WriteAttributeString(null, "percent", null, percent + ""); writer.WriteAttributeString(null, "risk", null, Owas.riskLegs(pernasP, percent) + ""); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); }