Esempio n. 1
0
 public static String findValueInTree(DTNode root, Example test)
 {
     if (root.getChildren().Count > 0)
     {
         double value;
         // foreach child
         foreach (KeyValuePair<DTNode, Condition> entry in root.getChildren())
         {
             switch (entry.Value.getOperator())
             {
                 case Constants.conditionType.GEQT:
                     if (test.getAttributes().TryGetValue(entry.Value.getMember1(), out value) == true)
                     {
                         if (value >= entry.Value.getMember2())
                             return findValueInTree(entry.Key, test);
                     }
                     break;
                 case Constants.conditionType.LT:
                     if (test.getAttributes().TryGetValue(entry.Value.getMember1(), out value) == true)
                     {
                         if (value < entry.Value.getMember2())
                             return findValueInTree(entry.Key, test);
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     return root.getResult();
 }
        private void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {

            SkeletonFrame skeletonFrame = e.SkeletonFrame;
            //tw = new StreamWriter("date.txt", true);
            //KinectSDK TODO: this shouldn't be needed, but if Power is removed from the Kinect, you may still get an event here, but skeletonFrame will be null.
            if (skeletonFrame == null)
            {
                return;
            }

            int iSkeleton = 0;
            Brush[] brushes = new Brush[6];
            brushes[0] = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            brushes[1] = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            brushes[2] = new SolidColorBrush(Color.FromRgb(64, 255, 255));
            brushes[3] = new SolidColorBrush(Color.FromRgb(255, 255, 64));
            brushes[4] = new SolidColorBrush(Color.FromRgb(255, 64, 255));
            brushes[5] = new SolidColorBrush(Color.FromRgb(128, 128, 255));

            skeletonCanvas.Children.Clear();

            foreach (SkeletonData data in skeletonFrame.Skeletons)
            {
                if (SkeletonTrackingState.Tracked == data.TrackingState)
                {
                    // Draw bones
                    Brush brush = brushes[iSkeleton % brushes.Length];
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.Spine, JointID.ShoulderCenter, JointID.Head));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderLeft, JointID.ElbowLeft, JointID.WristLeft, JointID.HandLeft));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderRight, JointID.ElbowRight, JointID.WristRight, JointID.HandRight));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipLeft, JointID.KneeLeft, JointID.AnkleLeft, JointID.FootLeft));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipRight, JointID.KneeRight, JointID.AnkleRight, JointID.FootRight));

                    // Draw joints
                    //tw.WriteLine("");

                    Point3D[] points = new Point3D[20];
                    foreach (Joint joint in data.Joints)
                    {
                        //tw.WriteLine(joint.Position.X + " " + joint.Position.Y + " " + joint.Position.Z);
                        Point jointPos = getDisplayPosition(joint);
                        Line jointLine = new Line();
                        jointLine.X1 = jointPos.X - 3;
                        jointLine.X2 = jointLine.X1 + 6;
                        jointLine.Y1 = jointLine.Y2 = jointPos.Y;
                        jointLine.Stroke = jointColors[joint.ID];
                        jointLine.StrokeThickness = 6;
                        skeletonCanvas.Children.Add(jointLine);
                        points[(int)joint.ID] = new Point3D(joint.Position.X, joint.Position.Y, joint.Position.Z);

                    }

                    if (b1.IsEnabled == false)
                    {
                        // get position for each body part
                        // BODY
                        Example bodyExample = new Example();
                        double angle = GeometryUtils.getAngle(points[2], points[1], points[13]);
                        bodyExample.add("A.2.1.13", angle);
                        angle = GeometryUtils.getAngle(points[2], points[1], points[17]);
                        bodyExample.add("A.2.1.17", angle);
                        angle = GeometryUtils.getAngle(points[1], points[2], Constants.planeType.XOY);
                        bodyExample.add("A.1.2.XoY", angle);
                        angle = GeometryUtils.getAngle(points[1], points[2], Constants.planeType.YOZ);
                        bodyExample.add("A.1.2.YoZ", angle);

                        // LEFT HAND
                        Example leftHandExample = new Example();
                        angle = GeometryUtils.getAngle(points[4], points[5], Constants.planeType.XOY);
                        leftHandExample.add("A.4.5.XoY", angle);
                        angle = GeometryUtils.getAngle(points[4], points[5], Constants.planeType.YOZ);
                        leftHandExample.add("A.4.5.YoZ", angle);
                        angle = points[4].getY() - points[5].getY();
                        leftHandExample.add("D.4y.5y", angle);

                        Example rightHandExample = new Example();
                        angle = GeometryUtils.getAngle(points[8], points[9], Constants.planeType.XOY);
                        rightHandExample.add("A.8.9.XoY", angle);
                        angle = GeometryUtils.getAngle(points[8], points[9], Constants.planeType.YOZ);
                        rightHandExample.add("A.8.9.YoZ", angle);
                        angle = points[8].getY() - points[9].getY();
                        rightHandExample.add("D.8y.9y", angle);

                        Example leftLegExample = new Example();
                        angle = GeometryUtils.getAngle(points[12], points[13], points[14]);
                        leftLegExample.add("A.12.13.14", angle);
                        angle = GeometryUtils.getAngle(points[13], points[14], Constants.planeType.XOY);
                        leftLegExample.add("A.13.14.XoY", angle);
                        angle = GeometryUtils.getAngle(points[13], points[14], Constants.planeType.YOZ);
                        leftLegExample.add("A.13.14.YoZ", angle);

                        Example rightLegExample = new Example();
                        angle = GeometryUtils.getAngle(points[16], points[17], points[18]);
                        rightLegExample.add("A.16.17.18", angle);
                        angle = GeometryUtils.getAngle(points[17], points[18], Constants.planeType.XOY);
                        rightLegExample.add("A.17.18.XoY", angle);
                        angle = GeometryUtils.getAngle(points[17], points[18], Constants.planeType.YOZ);
                        rightLegExample.add("A.17.18.YoZ", angle);
                        rightLegPositionText.Text = DTUtils.findValueInTree(rightLegDT, rightLegExample);

                        String bodyPosition = DTUtils.findValueInTree(bodyDT, bodyExample);
                        String leftHandPosition = DTUtils.findValueInTree(leftHandDT, leftHandExample);
                        String rightHandPosition = DTUtils.findValueInTree(rightHandDT, rightHandExample);
                        String leftLegPosition = DTUtils.findValueInTree(leftLegDT, leftLegExample);
                        String rightLegPosition = DTUtils.findValueInTree(rightLegDT, rightLegExample);

                        if (contor < Constants.SnapshotFrequency)
                        {
                            bodyCommonPosition.Add(bodyPosition);
                            rightHandCommonPosition.Add(rightHandPosition);
                            leftHandCommonPosition.Add(leftHandPosition);
                            rightLegCommonPosition.Add(rightLegPosition);
                            leftLegCommonPosition.Add(leftLegPosition);
                            contor++;
                        }
                        else
                        {
                            if (rightLegPosition.Equals("indoit") && leftLegPosition.Equals("indoit") && bodyPosition.Equals("aplecat frontal"))
                            {
                                bodyPositionText.Text = "spre ghemuire";
                            }
                            else
                            {
                                // get position and motion
                                bodyPositionText.Text = PositionUtils.getCommon(bodyCommonPosition);
                                if (bodyPositionText.Text.Equals("culcat") == true)
                                {
                                    leftHandPositionText.Text = "";
                                    rightHandPositionText.Text = "";
                                    leftLegPositionText.Text = "";
                                    rightLegPositionText.Text = "";

                                    bodyState = motionUtils.getNextBodyState(bodyState.getName(), bodyPositionText.Text);

                                    //bodyMotionText.Text = bodyState.getMotion();
                                    leftHandMotionText.Text = "";
                                    rightHandMotionText.Text = "";
                                    leftLegMotionText.Text = "";
                                    rightLegMotionText.Text = "";

                                    bodyCommonPosition = new List<string>();
                                    leftHandCommonPosition = new List<string>();
                                    rightHandCommonPosition = new List<string>();
                                    leftLegCommonPosition = new List<string>();
                                    rightLegCommonPosition = new List<string>();
                                }
                                else
                                {
                                    leftHandPositionText.Text = PositionUtils.getCommon(leftHandCommonPosition);
                                    rightHandPositionText.Text = PositionUtils.getCommon(rightHandCommonPosition);
                                    leftLegPositionText.Text = PositionUtils.getCommon(leftLegCommonPosition);
                                    rightLegPositionText.Text = PositionUtils.getCommon(rightLegCommonPosition);

                                    bodyState = motionUtils.getNextBodyState(bodyState.getName(), bodyPositionText.Text);
                                    leftHandState = motionUtils.getNextHandState(leftHandState.getName(), leftHandPositionText.Text);
                                    rightHandState = motionUtils.getNextHandState(rightHandState.getName(), rightHandPositionText.Text);
                                    leftLegState = motionUtils.getNextLegState(leftLegState.getName(), leftLegPositionText.Text);
                                    rightLegState = motionUtils.getNextLegState(rightLegState.getName(), rightLegPositionText.Text);

                                    bodyMotionText.Text = bodyState.getMotion();
                                    leftHandMotionText.Text = leftHandState.getMotion();
                                    rightHandMotionText.Text = rightHandState.getMotion();
                                    leftLegMotionText.Text = leftLegState.getMotion();
                                    rightLegMotionText.Text = rightLegState.getMotion();

                                    bodyCommonPosition = new List<string>();
                                    leftHandCommonPosition = new List<string>();
                                    rightHandCommonPosition = new List<string>();
                                    leftLegCommonPosition = new List<string>();
                                    rightLegCommonPosition = new List<string>();
                                }
                                // reset counter
                                contor = 0;
                            }
                        }
                    }
                }
                iSkeleton++;

            } // for each skeleton
            //tw.Close();
        }
Esempio n. 3
0
     public static void buildTree(DTNode root) {
     if (isTrivial(root) == true) {
         root.setResult(root.getTrainingSet()[0].getResult());
     }
     else if (root.getAttrNames().Count == 0) {
         // set as a result the most frequent class in training set
         Dictionary<String, int> classCount = new Dictionary<String, int>(); 
         foreach (String className in root.getClasses()) {
             classCount.Add(className, 0);
         }
         // get entropy of all training set
         foreach (Example example in root.getTrainingSet()) {
             int value;
             if (classCount.TryGetValue(example.getResult(), out value)) 
             {
                 classCount[example.getResult()] = value+1;
             }
             
         }     
         int maxCount = 0;
         String classResult = "";
         foreach(KeyValuePair<String, int> entry in classCount)
         {
             if (maxCount < entry.Value) {
                 maxCount = entry.Value;
                 classResult = entry.Key;
             }
         }
         
         root.setResult(classResult);
     }
     else {
         // find attribute with maximum gain
         GainResult gainResult = new GainResult();
         GainResult gainResultMax = new GainResult();
         gainResultMax.setGain(0.0);
         int resultIndex = 0;
         for (int i=0; i<root.getAttrNames().Count; i++) {
             gainResult = getGain(root.getTrainingSet(), root.getAttrNames()[i], root.getClasses());
             gainResult.setGain(getEntropy(root.getTrainingSet(), root.getClasses(), root.getAttrNames()[i], -1) - 
                     gainResult.getGain());
             if (gainResultMax.getGain() < gainResult.getGain()) {
                 gainResultMax.setGain(gainResult.getGain());
                 gainResultMax.setPartitionIndex(gainResult.getPartitionIndex());
                 resultIndex = i;
             }
         }
         String attributeNode = root.getAttrNames()[resultIndex];
         root.getAttrNames().RemoveAt(resultIndex);
         // sort training list by the attribute with maximum gain
         root.getTrainingSet().Sort(new ExampleComparator(attributeNode));
         // form children
         for (int i=0; i<2; i++)
         {
             List<String> newAttrNames = new List<String>();
             foreach (String str in root.getAttrNames()) {
                 newAttrNames.Add(str);
             }
             
             List<String> newClassNames = new List<String>();
             foreach (String str in root.getClasses()) {
                 newClassNames.Add(str);
             }
             DTNode child = new DTNode(new List<Example>(), newAttrNames, newClassNames);
             List<Example> newTrainingSet = new List<Example>();
             Condition condition = new Condition();
             if (i == 0) {
                 for (int p=0; p <= gainResultMax.getPartitionIndex(); p++) {
                     Example example = root.getTrainingSet()[p];
                     Example newExample = new Example();
                     // copy result
                     newExample.setResult(example.getResult());
                     // copy attribute values
                     Dictionary<String, Double> newAttributes = new Dictionary<String, Double>();
                     foreach (KeyValuePair<String, Double> entry in example.getAttributes())
                     {
                         newAttributes.Add(entry.Key, entry.Value);
                     }
                     newExample.setAttributes(newAttributes);                        
                     newTrainingSet.Add(newExample); 
                 }
                 condition.setOperator(Constants.conditionType.LT);                    
             }
             else {
                 for (int p=gainResultMax.getPartitionIndex()+1; p<root.getTrainingSet().Count; p++) {
                     Example example = root.getTrainingSet()[p];
                     Example newExample = new Example();
                     // copy result
                     newExample.setResult(example.getResult());
                     // copy attribute values
                     Dictionary<String, Double> newAttributes = new Dictionary<String, Double>();
                     foreach (KeyValuePair<String, Double> entry in example.getAttributes())
                     {
                         newAttributes.Add(entry.Key, entry.Value);
                     }
                     newExample.setAttributes(newAttributes);
                     newTrainingSet.Add(newExample);
                 }
                 condition.setOperator(Constants.conditionType.GEQT);
             }
             condition.setMember1(attributeNode);
             double leftValue = root.getTrainingSet()[gainResultMax.getPartitionIndex()].getValue(attributeNode);
             double rightValue = root.getTrainingSet()[gainResultMax.getPartitionIndex()+1].getValue(attributeNode);
             condition.setMember2((leftValue+rightValue)/2);                
             child.setTrainingSet(newTrainingSet);
             root.getChildren().Add(child, condition);                
             buildTree(child);
         }
     }
 }
Esempio n. 4
0
        private void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            SkeletonFrame skeletonFrame = e.SkeletonFrame;

            //tw = new StreamWriter("date.txt", true);
            //KinectSDK TODO: this shouldn't be needed, but if Power is removed from the Kinect, you may still get an event here, but skeletonFrame will be null.
            if (skeletonFrame == null)
            {
                return;
            }

            int iSkeleton = 0;

            Brush[] brushes = new Brush[6];
            brushes[0] = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            brushes[1] = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            brushes[2] = new SolidColorBrush(Color.FromRgb(64, 255, 255));
            brushes[3] = new SolidColorBrush(Color.FromRgb(255, 255, 64));
            brushes[4] = new SolidColorBrush(Color.FromRgb(255, 64, 255));
            brushes[5] = new SolidColorBrush(Color.FromRgb(128, 128, 255));

            skeletonCanvas.Children.Clear();

            foreach (SkeletonData data in skeletonFrame.Skeletons)
            {
                if (SkeletonTrackingState.Tracked == data.TrackingState)
                {
                    // Draw bones
                    Brush brush = brushes[iSkeleton % brushes.Length];
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.Spine, JointID.ShoulderCenter, JointID.Head));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderLeft, JointID.ElbowLeft, JointID.WristLeft, JointID.HandLeft));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderRight, JointID.ElbowRight, JointID.WristRight, JointID.HandRight));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipLeft, JointID.KneeLeft, JointID.AnkleLeft, JointID.FootLeft));
                    skeletonCanvas.Children.Add(getBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipRight, JointID.KneeRight, JointID.AnkleRight, JointID.FootRight));

                    // Draw joints
                    //tw.WriteLine("");

                    Point3D[] points = new Point3D[20];
                    foreach (Joint joint in data.Joints)
                    {
                        //tw.WriteLine(joint.Position.X + " " + joint.Position.Y + " " + joint.Position.Z);
                        Point jointPos  = getDisplayPosition(joint);
                        Line  jointLine = new Line();
                        jointLine.X1              = jointPos.X - 3;
                        jointLine.X2              = jointLine.X1 + 6;
                        jointLine.Y1              = jointLine.Y2 = jointPos.Y;
                        jointLine.Stroke          = jointColors[joint.ID];
                        jointLine.StrokeThickness = 6;
                        skeletonCanvas.Children.Add(jointLine);
                        points[(int)joint.ID] = new Point3D(joint.Position.X, joint.Position.Y, joint.Position.Z);
                    }

                    if (b1.IsEnabled == false)
                    {
                        // get position for each body part
                        // BODY
                        Example bodyExample = new Example();
                        double  angle       = GeometryUtils.getAngle(points[2], points[1], points[13]);
                        bodyExample.add("A.2.1.13", angle);
                        angle = GeometryUtils.getAngle(points[2], points[1], points[17]);
                        bodyExample.add("A.2.1.17", angle);
                        angle = GeometryUtils.getAngle(points[1], points[2], Constants.planeType.XOY);
                        bodyExample.add("A.1.2.XoY", angle);
                        angle = GeometryUtils.getAngle(points[1], points[2], Constants.planeType.YOZ);
                        bodyExample.add("A.1.2.YoZ", angle);

                        // LEFT HAND
                        Example leftHandExample = new Example();
                        angle = GeometryUtils.getAngle(points[4], points[5], Constants.planeType.XOY);
                        leftHandExample.add("A.4.5.XoY", angle);
                        angle = GeometryUtils.getAngle(points[4], points[5], Constants.planeType.YOZ);
                        leftHandExample.add("A.4.5.YoZ", angle);
                        angle = points[4].getY() - points[5].getY();
                        leftHandExample.add("D.4y.5y", angle);

                        Example rightHandExample = new Example();
                        angle = GeometryUtils.getAngle(points[8], points[9], Constants.planeType.XOY);
                        rightHandExample.add("A.8.9.XoY", angle);
                        angle = GeometryUtils.getAngle(points[8], points[9], Constants.planeType.YOZ);
                        rightHandExample.add("A.8.9.YoZ", angle);
                        angle = points[8].getY() - points[9].getY();
                        rightHandExample.add("D.8y.9y", angle);

                        Example leftLegExample = new Example();
                        angle = GeometryUtils.getAngle(points[12], points[13], points[14]);
                        leftLegExample.add("A.12.13.14", angle);
                        angle = GeometryUtils.getAngle(points[13], points[14], Constants.planeType.XOY);
                        leftLegExample.add("A.13.14.XoY", angle);
                        angle = GeometryUtils.getAngle(points[13], points[14], Constants.planeType.YOZ);
                        leftLegExample.add("A.13.14.YoZ", angle);

                        Example rightLegExample = new Example();
                        angle = GeometryUtils.getAngle(points[16], points[17], points[18]);
                        rightLegExample.add("A.16.17.18", angle);
                        angle = GeometryUtils.getAngle(points[17], points[18], Constants.planeType.XOY);
                        rightLegExample.add("A.17.18.XoY", angle);
                        angle = GeometryUtils.getAngle(points[17], points[18], Constants.planeType.YOZ);
                        rightLegExample.add("A.17.18.YoZ", angle);
                        rightLegPositionText.Text = DTUtils.findValueInTree(rightLegDT, rightLegExample);

                        String bodyPosition      = DTUtils.findValueInTree(bodyDT, bodyExample);
                        String leftHandPosition  = DTUtils.findValueInTree(leftHandDT, leftHandExample);
                        String rightHandPosition = DTUtils.findValueInTree(rightHandDT, rightHandExample);
                        String leftLegPosition   = DTUtils.findValueInTree(leftLegDT, leftLegExample);
                        String rightLegPosition  = DTUtils.findValueInTree(rightLegDT, rightLegExample);

                        if (contor < Constants.SnapshotFrequency)
                        {
                            bodyCommonPosition.Add(bodyPosition);
                            rightHandCommonPosition.Add(rightHandPosition);
                            leftHandCommonPosition.Add(leftHandPosition);
                            rightLegCommonPosition.Add(rightLegPosition);
                            leftLegCommonPosition.Add(leftLegPosition);
                            contor++;
                        }
                        else
                        {
                            if (rightLegPosition.Equals("indoit") && leftLegPosition.Equals("indoit") && bodyPosition.Equals("aplecat frontal"))
                            {
                                bodyPositionText.Text = "spre ghemuire";
                            }
                            else
                            {
                                // get position and motion
                                bodyPositionText.Text = PositionUtils.getCommon(bodyCommonPosition);
                                if (bodyPositionText.Text.Equals("culcat") == true)
                                {
                                    leftHandPositionText.Text  = "";
                                    rightHandPositionText.Text = "";
                                    leftLegPositionText.Text   = "";
                                    rightLegPositionText.Text  = "";

                                    bodyState = motionUtils.getNextBodyState(bodyState.getName(), bodyPositionText.Text);

                                    //bodyMotionText.Text = bodyState.getMotion();
                                    leftHandMotionText.Text  = "";
                                    rightHandMotionText.Text = "";
                                    leftLegMotionText.Text   = "";
                                    rightLegMotionText.Text  = "";

                                    bodyCommonPosition      = new List <string>();
                                    leftHandCommonPosition  = new List <string>();
                                    rightHandCommonPosition = new List <string>();
                                    leftLegCommonPosition   = new List <string>();
                                    rightLegCommonPosition  = new List <string>();
                                }
                                else
                                {
                                    leftHandPositionText.Text  = PositionUtils.getCommon(leftHandCommonPosition);
                                    rightHandPositionText.Text = PositionUtils.getCommon(rightHandCommonPosition);
                                    leftLegPositionText.Text   = PositionUtils.getCommon(leftLegCommonPosition);
                                    rightLegPositionText.Text  = PositionUtils.getCommon(rightLegCommonPosition);

                                    bodyState      = motionUtils.getNextBodyState(bodyState.getName(), bodyPositionText.Text);
                                    leftHandState  = motionUtils.getNextHandState(leftHandState.getName(), leftHandPositionText.Text);
                                    rightHandState = motionUtils.getNextHandState(rightHandState.getName(), rightHandPositionText.Text);
                                    leftLegState   = motionUtils.getNextLegState(leftLegState.getName(), leftLegPositionText.Text);
                                    rightLegState  = motionUtils.getNextLegState(rightLegState.getName(), rightLegPositionText.Text);

                                    bodyMotionText.Text      = bodyState.getMotion();
                                    leftHandMotionText.Text  = leftHandState.getMotion();
                                    rightHandMotionText.Text = rightHandState.getMotion();
                                    leftLegMotionText.Text   = leftLegState.getMotion();
                                    rightLegMotionText.Text  = rightLegState.getMotion();

                                    bodyCommonPosition      = new List <string>();
                                    leftHandCommonPosition  = new List <string>();
                                    rightHandCommonPosition = new List <string>();
                                    leftLegCommonPosition   = new List <string>();
                                    rightLegCommonPosition  = new List <string>();
                                }
                                // reset counter
                                contor = 0;
                            }
                        }
                    }
                }
                iSkeleton++;
            } // for each skeleton
              //tw.Close();
        }
Esempio n. 5
0
        public static List<Example> readRightHandTS() {
         // TRAIN RIGHT HAND PART...
        if (Constants.DEBUG) {
            // Attributes: A.8.9.XOY, A.8.9.YOZ, D.8y.9y
            Console.WriteLine("\n=====\tMANA DREAPTA =====");  
            Console.WriteLine("\tLanga corp");
        }
        StreamReader sr;
        String strLine;
        List<Example> rightHandTS = new List<Example>();
        
        double maxim1 = 0.0;
        double minim1 = 180.0;
        double average1 = 0.0;

        double maxim2 = 0.0;
        double minim2 = 180.0;
        double average2 = 0.0;

        double maxim3 = 0.0;
        double minim3 = 180.0;
        double average3 = 0.0;
        
        try {
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\msd\\langa corp.txt");
            double fileSize = 22323;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right  
                string[] words = strLine.Split(' ');
                Point3D P8 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 9:elbow right
                words = strLine.Split(' ');
                Point3D P9 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left                
                strLine = sr.ReadLine(); // 13:knee left
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.XOY);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.8.9.XoY", angle);
                
                angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.YOZ);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.8.9.YoZ", angle);
                
                angle = P8.getY() - P9.getY();
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("D.8y.9y", angle);
                
                example.setResult("langa corp");
                rightHandTS.Add(example);
            }    
            if (Constants.DEBUG) {
                Console.WriteLine("A.8.9.XOY:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.8.9.YOZ:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("D.8y.9y:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }
            
            //RIDICAT LATERAL
            if (Constants.DEBUG) {
                Console.WriteLine("\tRidicat lateral");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\msd\\ridicat lateral.txt");
            fileSize = 24444;

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right  
                string[] words = strLine.Split(' ');
                Point3D P8 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 9:elbow right
                words = strLine.Split(' ');
                Point3D P9 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left                
                strLine = sr.ReadLine(); // 13:knee left
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.XOY);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.8.9.XoY", angle);
                
                angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.YOZ);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.8.9.YoZ", angle);
                
                angle = P8.getY() - P9.getY();
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("D.8y.9y", angle);
                
                example.setResult("ridicat lateral");
                rightHandTS.Add(example);
            }  
            if (Constants.DEBUG) {
                Console.WriteLine("A.8.9.XOY:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.8.9.YOZ:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("D.8y.9y:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }
            
            // RIDICAT SUS
            if (Constants.DEBUG) {
                Console.WriteLine("\tRidicat sus");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\msd\\ridicat sus.txt");
            fileSize = 14469;

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right  
                string[] words = strLine.Split(' ');
                Point3D P8 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 9:elbow right
                words = strLine.Split(' ');
                Point3D P9 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left                
                strLine = sr.ReadLine(); // 13:knee left
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.XOY);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.8.9.XoY", angle);
                
                angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.YOZ);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.8.9.YoZ", angle);
                
                angle = P8.getY() - P9.getY();
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("D.8y.9y", angle);
                
                example.setResult("ridicat sus");
                rightHandTS.Add(example);
            }     
            if (Constants.DEBUG) {
                Console.WriteLine("A.8.9.XOY:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.8.9.YOZ:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("D.8y.9y:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }
            
            // RIDICAT FRONTAL
            if (Constants.DEBUG) {
                Console.WriteLine("\tRidicat frontal");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\msd\\ridicat frontal.txt");
            fileSize = 21567;

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right  
                string[] words = strLine.Split(' ');
                Point3D P8 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 9:elbow right
                words = strLine.Split(' ');
                Point3D P9 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left                
                strLine = sr.ReadLine(); // 13:knee left
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.XOY);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.8.9.XoY", angle);
                
                angle = GeometryUtils.getAngle(P8,P9,Constants.planeType.YOZ);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.8.9.YoZ", angle);
                
                angle = P8.getY() - P9.getY();
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("D.8y.9y", angle);
                
                example.setResult("ridicat frontal");
                rightHandTS.Add(example);
            }       
            if (Constants.DEBUG) {
                Console.WriteLine("A.8.9.XOY:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.8.9.YOZ:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("D.8y.9y:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }
        }
        catch (Exception e) {Console.WriteLine(e);}
        
        return rightHandTS;
     }
Esempio n. 6
0
        public static List<Example> readRightLegTS() {
            if (Constants.DEBUG) {
                Console.WriteLine("\n=====\tPICIOR DREPT  =====");   
                // DREPT
                Console.WriteLine("\tDrept");
            }
            
            List<Example> rightLegTS = new List<Example>();
            StreamReader sr;
            String strLine;

            double maxim1 = 0.0;
            double minim1 = 180.0;
            double average1 = 0.0;

            double maxim2 = 0.0;
            double minim2 = 180.0;
            double average2 = 0.0;

            double maxim3 = 0.0;
            double minim3 = 180.0;
            double average3 = 0.0;

            double fileSize = 14133;
            try {
                sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mid\\drept.txt");

                for (int i=0; i<fileSize; i+=21) {  
                    strLine = sr.ReadLine(); // blank                
                    strLine = sr.ReadLine(); // 0:hipcenter   
                    strLine = sr.ReadLine(); // 1:spine
                    strLine = sr.ReadLine(); // 2:shoulder center
                    strLine = sr.ReadLine(); // 3:head                 
                    strLine = sr.ReadLine(); // 4:shoulder left                              
                    strLine = sr.ReadLine(); // 5:elbow left                
                    strLine = sr.ReadLine(); // 6:wrist left 
                    strLine = sr.ReadLine(); // 7:hand left
                    strLine = sr.ReadLine(); // 8:shoulder right               
                    strLine = sr.ReadLine(); // 9:elbow right
                    strLine = sr.ReadLine(); // 10:wrist right
                    strLine = sr.ReadLine(); // 11:hand right
                    strLine = sr.ReadLine(); // 12:hip left                
                    strLine = sr.ReadLine(); // 13:knee left
                    strLine = sr.ReadLine(); // 14:ankle left
                    strLine = sr.ReadLine(); // 15:foot left
                    strLine = sr.ReadLine(); // 16:hip right
                    string[] words = strLine.Split(' ');
                    Point3D P16 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 17:knee right   
                    words = strLine.Split(' ');
                    Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 18:ankle right
                    words = strLine.Split(' ');
                    Point3D P18 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 19:foot right

                    Example example = new Example();
                    
                    double angle = GeometryUtils.getAngle(P16,P17,P18);
                    if (maxim1 < angle)
                        maxim1 = angle;
                    if (minim1 > angle)
                        minim1 = angle;  
                    average1 += angle;  
                    example.add("A.16.17.18", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.XOY);
                    if (maxim2 < angle)
                        maxim2 = angle;
                    if (minim2 > angle)
                        minim2 = angle;  
                    average2 += angle;
                    example.add("A.17.18.XoY", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.YOZ);
                    if (maxim3 < angle)
                        maxim3 = angle;
                    if (minim3 > angle)
                        minim3 = angle;  
                    average3 += angle;
                    example.add("A.17.18.YoZ", angle);
                    
                    example.setResult("drept");
                    rightLegTS.Add(example);
                }   
                if (Constants.DEBUG) {
                    Console.WriteLine("A.16.17.18:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                    Console.WriteLine("A.17.18.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                    Console.WriteLine("A.17.18.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
                }
                
                // RIDICAT LATERAL
                if (Constants.DEBUG) {
                    Console.WriteLine("\tRidicat lateral");
                }
                sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mid\\ridicat lateral.txt");
                fileSize = 5859;

                maxim1 = 0.0;
                minim1 = 180.0;
                average1 = 0.0;

                maxim2 = 0.0;
                minim2 = 180.0;
                average2 = 0.0;

                maxim3 = 0.0;
                minim3 = 180.0;
                average3 = 0.0;

                for (int i=0; i<fileSize; i+=21) {  
                    strLine = sr.ReadLine(); // blank                
                    strLine = sr.ReadLine(); // 0:hipcenter   
                    strLine = sr.ReadLine(); // 1:spine
                    strLine = sr.ReadLine(); // 2:shoulder center
                    strLine = sr.ReadLine(); // 3:head                 
                    strLine = sr.ReadLine(); // 4:shoulder left                              
                    strLine = sr.ReadLine(); // 5:elbow left                
                    strLine = sr.ReadLine(); // 6:wrist left 
                    strLine = sr.ReadLine(); // 7:hand left
                    strLine = sr.ReadLine(); // 8:shoulder right               
                    strLine = sr.ReadLine(); // 9:elbow right
                    strLine = sr.ReadLine(); // 10:wrist right
                    strLine = sr.ReadLine(); // 11:hand right
                    strLine = sr.ReadLine(); // 12:hip left                
                    strLine = sr.ReadLine(); // 13:knee left
                    strLine = sr.ReadLine(); // 14:ankle left
                    strLine = sr.ReadLine(); // 15:foot left
                    strLine = sr.ReadLine(); // 16:hip right
                    string[] words = strLine.Split(' ');
                    Point3D P16 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 17:knee right   
                    words = strLine.Split(' ');
                    Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 18:ankle right
                    words = strLine.Split(' ');
                    Point3D P18 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 19:foot right

                    Example example = new Example();
                    
                    double angle = GeometryUtils.getAngle(P16,P17,P18);
                    if (maxim1 < angle)
                        maxim1 = angle;
                    if (minim1 > angle)
                        minim1 = angle;  
                    average1 += angle;  
                    example.add("A.16.17.18", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.XOY);
                    if (maxim2 < angle)
                        maxim2 = angle;
                    if (minim2 > angle)
                        minim2 = angle;  
                    average2 += angle;
                    example.add("A.17.18.XoY", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.YOZ);
                    if (maxim3 < angle)
                        maxim3 = angle;
                    if (minim3 > angle)
                        minim3 = angle;  
                    average3 += angle;
                    example.add("A.17.18.YoZ", angle);
                    
                    example.setResult("ridicat lateral");
                    rightLegTS.Add(example);
                }  
                if (Constants.DEBUG) {
                    Console.WriteLine("A.16.17.18:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                    Console.WriteLine("A.17.18.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                    Console.WriteLine("A.17.18.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
                }

                // RIDICAT FRONTAL
                if (Constants.DEBUG) {
                    Console.WriteLine("\tRidicat frontal");
                }
                sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mid\\ridicat frontal.txt");
                fileSize = 9870;

                maxim1 = 0.0;
                minim1 = 180.0;
                average1 = 0.0;

                maxim2 = 0.0;
                minim2 = 180.0;
                average2 = 0.0;

                maxim3 = 0.0;
                minim3 = 180.0;
                average3 = 0.0;

                for (int i=0; i<fileSize; i+=21) {  
                    strLine = sr.ReadLine(); // blank                
                    strLine = sr.ReadLine(); // 0:hipcenter   
                    strLine = sr.ReadLine(); // 1:spine
                    strLine = sr.ReadLine(); // 2:shoulder center
                    strLine = sr.ReadLine(); // 3:head                 
                    strLine = sr.ReadLine(); // 4:shoulder left                              
                    strLine = sr.ReadLine(); // 5:elbow left                
                    strLine = sr.ReadLine(); // 6:wrist left 
                    strLine = sr.ReadLine(); // 7:hand left
                    strLine = sr.ReadLine(); // 8:shoulder right               
                    strLine = sr.ReadLine(); // 9:elbow right
                    strLine = sr.ReadLine(); // 10:wrist right
                    strLine = sr.ReadLine(); // 11:hand right
                    strLine = sr.ReadLine(); // 12:hip left                
                    strLine = sr.ReadLine(); // 13:knee left
                    strLine = sr.ReadLine(); // 14:ankle left
                    strLine = sr.ReadLine(); // 15:foot left
                    strLine = sr.ReadLine(); // 16:hip right
                    string[] words = strLine.Split(' ');
                    Point3D P16 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 17:knee right   
                    words = strLine.Split(' ');
                    Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 18:ankle right
                    words = strLine.Split(' ');
                    Point3D P18 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 19:foot right

                    Example example = new Example();
                    
                    double angle = GeometryUtils.getAngle(P16,P17,P18);
                    if (maxim1 < angle)
                        maxim1 = angle;
                    if (minim1 > angle)
                        minim1 = angle;  
                    average1 += angle;  
                    example.add("A.16.17.18", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.XOY);
                    if (maxim2 < angle)
                        maxim2 = angle;
                    if (minim2 > angle)
                        minim2 = angle;  
                    average2 += angle;
                    example.add("A.17.18.XoY", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.YOZ);
                    if (maxim3 < angle)
                        maxim3 = angle;
                    if (minim3 > angle)
                        minim3 = angle;  
                    average3 += angle;
                    example.add("A.17.18.YoZ", angle);
                    
                    example.setResult("ridicat frontal");
                    rightLegTS.Add(example);
                }    
                if (Constants.DEBUG) {
                    Console.WriteLine("A.16.17.18:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                    Console.WriteLine("A.17.18.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                    Console.WriteLine("A.17.18.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
                }

                // INDOIT
                if (Constants.DEBUG) {
                    Console.WriteLine("\tIndoit");
                }
                sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mid\\indoit.txt");
                fileSize = 28791;

                maxim1 = 0.0;
                minim1 = 180.0;
                average1 = 0.0;

                maxim2 = 0.0;
                minim2 = 180.0;
                average2 = 0.0;

                maxim3 = 0.0;
                minim3 = 180.0;
                average3 = 0.0;

                for (int i=0; i<fileSize; i+=21) {  
                    strLine = sr.ReadLine(); // blank                
                    strLine = sr.ReadLine(); // 0:hipcenter   
                    strLine = sr.ReadLine(); // 1:spine
                    strLine = sr.ReadLine(); // 2:shoulder center
                    strLine = sr.ReadLine(); // 3:head                 
                    strLine = sr.ReadLine(); // 4:shoulder left                              
                    strLine = sr.ReadLine(); // 5:elbow left                
                    strLine = sr.ReadLine(); // 6:wrist left 
                    strLine = sr.ReadLine(); // 7:hand left
                    strLine = sr.ReadLine(); // 8:shoulder right               
                    strLine = sr.ReadLine(); // 9:elbow right
                    strLine = sr.ReadLine(); // 10:wrist right
                    strLine = sr.ReadLine(); // 11:hand right
                    strLine = sr.ReadLine(); // 12:hip left                
                    strLine = sr.ReadLine(); // 13:knee left
                    strLine = sr.ReadLine(); // 14:ankle left
                    strLine = sr.ReadLine(); // 15:foot left
                    strLine = sr.ReadLine(); // 16:hip right
                    string[] words = strLine.Split(' ');
                    Point3D P16 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 17:knee right   
                    words = strLine.Split(' ');
                    Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 18:ankle right
                    words = strLine.Split(' ');
                    Point3D P18 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                    strLine = sr.ReadLine(); // 19:foot right

                    Example example = new Example();
                    
                    double angle = GeometryUtils.getAngle(P16,P17,P18);
                    if (maxim1 < angle)
                        maxim1 = angle;
                    if (minim1 > angle)
                        minim1 = angle;  
                    average1 += angle;  
                    example.add("A.16.17.18", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.XOY);
                    if (maxim2 < angle)
                        maxim2 = angle;
                    if (minim2 > angle)
                        minim2 = angle;  
                    average2 += angle;
                    example.add("A.17.18.XoY", angle);
                    
                    angle = GeometryUtils.getAngle(P17,P18,Constants.planeType.YOZ);
                    if (maxim3 < angle)
                        maxim3 = angle;
                    if (minim3 > angle)
                        minim3 = angle;  
                    average3 += angle;
                    example.add("A.17.18.YoZ", angle);
                    
                    example.setResult("indoit");
                    rightLegTS.Add(example);
                }    
                if (Constants.DEBUG) {
                    Console.WriteLine("A.16.17.18:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                    Console.WriteLine("A.17.18.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                    Console.WriteLine("A.17.18.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
                }
        }
        catch (Exception e) {Console.WriteLine(e);}
            
        return rightLegTS;
     }
Esempio n. 7
0
        public static List<Example> readLeftLegTS() {
         // TRAIN LEFT LEG PART...
         if (Constants.DEBUG) {
            // Attributes: A.12.13.14, A.13.14.XOY, A.13.14.YOZ
            Console.WriteLine("\n=====\tPICIOR STANG  =====");
            Console.WriteLine("\tDrept");
         }

        StreamReader sr;
        String strLine;
        List<Example> leftLegTS = new List<Example>();

        double maxim1 = 0.0;
        double minim1 = 180.0;
        double average1 = 0.0;

        double maxim2 = 0.0;
        double minim2 = 180.0;
        double average2 = 0.0;

        double maxim3 = 0.0;
        double minim3 = 180.0;
        double average3 = 0.0;

        double fileSize = 25242;

        try {
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mis\\drept.txt");

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right               
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                string[] words = strLine.Split(' ');
                Point3D P12 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 13:knee left
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                words = strLine.Split(' ');
                Point3D P14 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();

                double angle = GeometryUtils.getAngle(P12,P13,P14);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.12.13.14", angle);
                
                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.XOY);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.13.14.XoY", angle);

                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.YOZ);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("A.13.14.YoZ", angle);

                example.setResult("drept");
                leftLegTS.Add(example);
            }   
            if (Constants.DEBUG) {
                Console.WriteLine("A.12.13.14:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.13.14.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("A.13.14.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }

            // RIDICAT LATERAL
            if (Constants.DEBUG) {
                Console.WriteLine("\tRidicat lateral");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mis\\ridicat lateral.txt");
            fileSize = 3444;

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right               
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                string[] words = strLine.Split(' ');
                Point3D P12 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 13:knee left
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                words = strLine.Split(' ');
                Point3D P14 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();

                double angle = GeometryUtils.getAngle(P12,P13,P14);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.12.13.14", angle);
                                
                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.XOY);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.13.14.XoY", angle);

                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.YOZ);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("A.13.14.YoZ", angle);

                example.setResult("ridicat lateral");
                leftLegTS.Add(example);
            }   
            if (Constants.DEBUG) {
                Console.WriteLine("A.12.13.14:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.13.14.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("A.13.14.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }

            // RIDICAT FRONTAL
            if (Constants.DEBUG) {
                Console.WriteLine("\tRidicat frontal");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mis\\ridicat frontal.txt");
            fileSize = 12432;

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right               
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                string[] words = strLine.Split(' ');
                Point3D P12 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 13:knee left
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                words = strLine.Split(' ');
                Point3D P14 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();

                double angle = GeometryUtils.getAngle(P12,P13,P14);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.12.13.14", angle);
                
                
                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.XOY);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.13.14.XoY", angle);

                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.YOZ);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("A.13.14.YoZ", angle);

                example.setResult("ridicat frontal");
                leftLegTS.Add(example);
            }   
            if (Constants.DEBUG) {
                Console.WriteLine("A.12.13.14:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.13.14.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("A.13.14.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }

            // INDOIT
            if (Constants.DEBUG) {
                Console.WriteLine("\tIndoit");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\mis\\indoit.txt");
            fileSize = 10584;

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            for (int i=0; i<fileSize; i+=21) {  
                strLine = sr.ReadLine(); // blank                
                strLine = sr.ReadLine(); // 0:hipcenter   
                strLine = sr.ReadLine(); // 1:spine
                strLine = sr.ReadLine(); // 2:shoulder center
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left                              
                strLine = sr.ReadLine(); // 5:elbow left                
                strLine = sr.ReadLine(); // 6:wrist left 
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right               
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                string[] words = strLine.Split(' ');
                Point3D P12 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 13:knee left
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                words = strLine.Split(' ');
                Point3D P14 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right       
                strLine = sr.ReadLine(); // 17:knee right                
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right

                Example example = new Example();

                double angle = GeometryUtils.getAngle(P12,P13,P14);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;  
                average1 += angle;  
                example.add("A.12.13.14", angle);
                
                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.XOY);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;  
                average2 += angle;
                example.add("A.13.14.XoY", angle);

                angle = GeometryUtils.getAngle(P13,P14,Constants.planeType.YOZ);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;  
                average3 += angle;
                example.add("A.13.14.YoZ", angle);

                example.setResult("indoit");
                leftLegTS.Add(example);
            }    
            if (Constants.DEBUG) {
                Console.WriteLine("A.12.13.14:\t(" + (int)minim1 + ", " + (int)maxim1 + "), " + ((int)average1/fileSize*21));
                Console.WriteLine("A.13.14.XOY:\t(" + (int)minim2 + ", " + (int)maxim2 + "), " + ((int)average2/fileSize*21));
                Console.WriteLine("A.13.14.YOZ:\t(" + (int)minim3 + ", " + (int)maxim3 + "), " + ((int)average3/fileSize*21));
            }
        }
        catch (Exception e) {Console.WriteLine(e);} 

        return leftLegTS;
     }
Esempio n. 8
0
        public static List<Example> readBodyTS() {
        // TRAIN BODY PART ...
        List<Example> bodyTS = new List<Example>();
        StreamReader sr;
        String strLine;
        
        if (Constants.DEBUG) {
            Console.WriteLine("\n=====\tTRUNCHI\t=====");
            // Attributes: A.2.1.13, A.2.1.17, A.1.2.XOY, A.1.2.YOZ
            Console.WriteLine("\tDrept");
        }
        double maxim1 = 0.0;
        double minim1 = 180.0;
        double average1 = 0.0;

        double maxim2 = 0.0;
        double minim2 = 180.0;
        double average2 = 0.0;

        double maxim3 = 0.0;
        double minim3 = 180.0;
        double average3 = 0.0;

        double maxim4 = 0.0;
        double minim4 = 180.0;
        double average4 = 0.0;

        double fileSize = 5838;
        
        try {
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\trunchi\\drept.txt");

            for (int i=0; i<fileSize; i+=21) {
                strLine = sr.ReadLine(); // blank
                strLine = sr.ReadLine(); // 0:hipcenter
                strLine = sr.ReadLine(); // 1:spine
                string[] words = strLine.Split(' ');
                Point3D P1 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 2:shoulder center
                words = strLine.Split(' ');
                Point3D P2 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left
                strLine = sr.ReadLine(); // 5:elbow left
                strLine = sr.ReadLine(); // 6:wrist left
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                strLine = sr.ReadLine(); // 13:knee left                
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right
                strLine = sr.ReadLine(); // 17:knee right
                words = strLine.Split(' ');
                Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right
                
                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P2,P1,P13);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;
                average1 += angle;
                example.add("A.2.1.13", angle);
                
                angle = GeometryUtils.getAngle(P2,P1,P17);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;
                average2 += angle;
                example.add("A.2.1.17", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.XOY);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;
                average3 += angle;
                example.add("A.1.2.XoY", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.YOZ);
                if (maxim4 < angle)
                    maxim4 = angle;
                if (minim4 > angle)
                    minim4 = angle;
                average4 += angle;
                example.add("A.1.2.YoZ", angle);
                
                example.setResult("drept");
                bodyTS.Add(example);
            }
            if (Constants.DEBUG) {
                Console.WriteLine("A.2.1.13:(" + (int)minim1 + ", " + (int)maxim1 + "), " + (int)(average1/fileSize*21));
                Console.WriteLine("A.2.1.17:(" + (int)minim2 + ", " + (int)maxim2 + "), " + (int)(average2/fileSize*21));
                Console.WriteLine("A.1.2.XOY:(" + (int)minim3 + ", " + (int)maxim3 + "), " + (int)(average3/fileSize*21));
                Console.WriteLine("A.1.2.YOZ:(" + (int)minim4 + ", " + (int)maxim4 + "), " + (int)(average4/fileSize*21));
            }
            
            
            if (Constants.DEBUG) {
                Console.WriteLine("\tAplecat frontal");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\trunchi\\aplecat frontal.txt");

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            maxim4 = 0.0;
            minim4 = 180.0;
            average4 = 0.0;

            fileSize = 10605;
            for (int i=0; i<fileSize; i+=21) {                   
                strLine = sr.ReadLine(); // blank
                strLine = sr.ReadLine(); // 0:hipcenter
                strLine = sr.ReadLine(); // 1:spine
                string[] words = strLine.Split(' ');
                Point3D P1 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 2:shoulder center
                words = strLine.Split(' ');
                Point3D P2 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left
                strLine = sr.ReadLine(); // 5:elbow left
                strLine = sr.ReadLine(); // 6:wrist left
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                strLine = sr.ReadLine(); // 13:knee left                
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right
                strLine = sr.ReadLine(); // 17:knee right
                words = strLine.Split(' ');
                Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right
                
                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P2,P1,P13);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;
                average1 += angle;
                example.add("A.2.1.13", angle);
                
                angle = GeometryUtils.getAngle(P2,P1,P17);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;
                average2 += angle;
                example.add("A.2.1.17", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.XOY);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;
                average3 += angle;
                example.add("A.1.2.XoY", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.YOZ);
                if (maxim4 < angle)
                    maxim4 = angle;
                if (minim4 > angle)
                    minim4 = angle;
                average4 += angle;
                example.add("A.1.2.YoZ", angle);
                
                example.setResult("aplecat frontal");
                bodyTS.Add(example);
            }
            if (Constants.DEBUG) {
                Console.WriteLine("A.2.1.13:(" + (int)minim1 + ", " + (int)maxim1 + "), " + (int)(average1/fileSize*21));
                Console.WriteLine("A.2.1.17:(" + (int)minim2 + ", " + (int)maxim2 + "), " + (int)(average2/fileSize*21));
                Console.WriteLine("A.1.2.XOY:(" + (int)minim3 + ", " + (int)maxim3 + "), " + (int)(average3/fileSize*21));
                Console.WriteLine("A.1.2.YOZ:(" + (int)minim4 + ", " + (int)maxim4 + "), " + (int)(average4/fileSize*21));
            }

            if (Constants.DEBUG) {
                Console.WriteLine("\tAplecat lateral");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\trunchi\\aplecat lateral.txt");

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            maxim4 = 0.0;
            minim4 = 180.0;
            average4 = 0.0;

            fileSize = 9786;
            
            for (int i=0; i<fileSize; i+=21) {
                strLine = sr.ReadLine(); // blank
                strLine = sr.ReadLine(); // 0:hipcenter
                strLine = sr.ReadLine(); // 1:spine
                string[] words = strLine.Split(' ');
                Point3D P1 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 2:shoulder center
                words = strLine.Split(' ');
                Point3D P2 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left
                strLine = sr.ReadLine(); // 5:elbow left
                strLine = sr.ReadLine(); // 6:wrist left
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                strLine = sr.ReadLine(); // 13:knee left                
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right
                strLine = sr.ReadLine(); // 17:knee right
                words = strLine.Split(' ');
                Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right
                
                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P2,P1,P13);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;
                average1 += angle;
                example.add("A.2.1.13", angle);
                
                angle = GeometryUtils.getAngle(P2,P1,P17);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;
                average2 += angle;
                example.add("A.2.1.17", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.XOY);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;
                average3 += angle;
                example.add("A.1.2.XoY", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.YOZ);
                if (maxim4 < angle)
                    maxim4 = angle;
                if (minim4 > angle)
                    minim4 = angle;
                average4 += angle;
                example.add("A.1.2.YoZ", angle);
                
                example.setResult("aplecat lateral");
                bodyTS.Add(example);
            }
            if (Constants.DEBUG) {
                Console.WriteLine("A.2.1.13:(" + (int)minim1 + ", " + (int)maxim1 + "), " + (int)(average1/fileSize*21));
                Console.WriteLine("A.2.1.17:(" + (int)minim2 + ", " + (int)maxim2 + "), " + (int)(average2/fileSize*21));
                Console.WriteLine("A.1.2.XOY:(" + (int)minim3 + ", " + (int)maxim3 + "), " + (int)(average3/fileSize*21));
                Console.WriteLine("A.1.2.YOZ:(" + (int)minim4 + ", " + (int)maxim4 + "), " + (int)(average4/fileSize*21));
            }

            if (Constants.DEBUG) {
                Console.WriteLine("\tAsezat");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\trunchi\\asezat.txt");

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            maxim4 = 0.0;
            minim4 = 180.0;
            average4 = 0.0;

            fileSize = 6237;
            
            for (int i=0; i<fileSize; i+=21) {                
                strLine = sr.ReadLine(); // blank
                strLine = sr.ReadLine(); // 0:hipcenter
                strLine = sr.ReadLine(); // 1:spine
                string[] words = strLine.Split(' ');
                Point3D P1 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 2:shoulder center
                words = strLine.Split(' ');
                Point3D P2 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left
                strLine = sr.ReadLine(); // 5:elbow left
                strLine = sr.ReadLine(); // 6:wrist left
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                strLine = sr.ReadLine(); // 13:knee left                
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right
                strLine = sr.ReadLine(); // 17:knee right
                words = strLine.Split(' ');
                Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right
                
                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P2,P1,P13);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;
                average1 += angle;
                example.add("A.2.1.13", angle);
                
                angle = GeometryUtils.getAngle(P2,P1,P17);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;
                average2 += angle;
                example.add("A.2.1.17", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.XOY);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;
                average3 += angle;
                example.add("A.1.2.XoY", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.YOZ);
                if (maxim4 < angle)
                    maxim4 = angle;
                if (minim4 > angle)
                    minim4 = angle;
                average4 += angle;
                example.add("A.1.2.YoZ", angle);
                
                example.setResult("asezat");
                bodyTS.Add(example);
            }
            if (Constants.DEBUG) {
                Console.WriteLine("A.2.1.13:(" + (int)minim1 + ", " + (int)maxim1 + "), " + (int)(average1/fileSize*21));
                Console.WriteLine("A.2.1.17:(" + (int)minim2 + ", " + (int)maxim2 + "), " + (int)(average2/fileSize*21));
                Console.WriteLine("A.1.2.XOY:(" + (int)minim3 + ", " + (int)maxim3 + "), " + (int)(average3/fileSize*21));
                Console.WriteLine("A.1.2.YOZ:(" + (int)minim4 + ", " + (int)maxim4 + "), " + (int)(average4/fileSize*21));
            }
            
            if (Constants.DEBUG) {
                Console.WriteLine("\tCulcat");
            }
            sr = new StreamReader("D:\\LICENTA\\Pose Recognition\\input_antrenare_3\\trunchi\\culcat.txt");

            maxim1 = 0.0;
            minim1 = 180.0;
            average1 = 0.0;

            maxim2 = 0.0;
            minim2 = 180.0;
            average2 = 0.0;

            maxim3 = 0.0;
            minim3 = 180.0;
            average3 = 0.0;

            maxim4 = 0.0;
            minim4 = 180.0;
            average4 = 0.0;
            
            fileSize = 2604;
            
            for (int i=0; i<fileSize; i+=21) {
                strLine = sr.ReadLine(); // blank
                strLine = sr.ReadLine(); // 0:hipcenter
                strLine = sr.ReadLine(); // 1:spine
                string[] words = strLine.Split(' ');
                Point3D P1 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 2:shoulder center
                words = strLine.Split(' ');
                Point3D P2 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 3:head                 
                strLine = sr.ReadLine(); // 4:shoulder left
                strLine = sr.ReadLine(); // 5:elbow left
                strLine = sr.ReadLine(); // 6:wrist left
                strLine = sr.ReadLine(); // 7:hand left
                strLine = sr.ReadLine(); // 8:shoulder right
                strLine = sr.ReadLine(); // 9:elbow right
                strLine = sr.ReadLine(); // 10:wrist right
                strLine = sr.ReadLine(); // 11:hand right
                strLine = sr.ReadLine(); // 12:hip left
                strLine = sr.ReadLine(); // 13:knee left                
                words = strLine.Split(' ');
                Point3D P13 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 14:ankle left
                strLine = sr.ReadLine(); // 15:foot left
                strLine = sr.ReadLine(); // 16:hip right
                strLine = sr.ReadLine(); // 17:knee right
                words = strLine.Split(' ');
                Point3D P17 = new Point3D(Double.Parse(words[0]), 
                        Double.Parse(words[1]), 
                        Double.Parse(words[2]));
                strLine = sr.ReadLine(); // 18:ankle right
                strLine = sr.ReadLine(); // 19:foot right
                
                Example example = new Example();
                
                double angle = GeometryUtils.getAngle(P2,P1,P13);
                if (maxim1 < angle)
                    maxim1 = angle;
                if (minim1 > angle)
                    minim1 = angle;
                average1 += angle;
                example.add("A.2.1.13", angle);
                
                angle = GeometryUtils.getAngle(P2,P1,P17);
                if (maxim2 < angle)
                    maxim2 = angle;
                if (minim2 > angle)
                    minim2 = angle;
                average2 += angle;
                example.add("A.2.1.17", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.XOY);
                if (maxim3 < angle)
                    maxim3 = angle;
                if (minim3 > angle)
                    minim3 = angle;
                average3 += angle;
                example.add("A.1.2.XoY", angle);
                
                angle = GeometryUtils.getAngle(P1,P2,Constants.planeType.YOZ);
                if (maxim4 < angle)
                    maxim4 = angle;
                if (minim4 > angle)
                    minim4 = angle;
                average4 += angle;
                example.add("A.1.2.YoZ", angle);
                
                example.setResult("culcat");
                bodyTS.Add(example);
            }
            if (Constants.DEBUG) {
                Console.WriteLine("A.2.1.13:(" + (int)minim1 + ", " + (int)maxim1 + "), " + (int)(average1/fileSize*21));
                Console.WriteLine("A.2.1.17:(" + (int)minim2 + ", " + (int)maxim2 + "), " + (int)(average2/fileSize*21));
                Console.WriteLine("A.1.2.XOY:(" + (int)minim3 + ", " + (int)maxim3 + "), " + (int)(average3/fileSize*21));
                Console.WriteLine("A.1.2.YOZ:(" + (int)minim4 + ", " + (int)maxim4 + "), " + (int)(average4/fileSize*21));
            }
          
        }
        catch (Exception e) {Console.WriteLine(e);}
        
        return bodyTS;
    }