Esempio n. 1
0
        // i start at 0
        public void collectData_Raw()
        {
            UKI_DataRaw new_data = new UKI_DataRaw();

            new_data.id   = current_id;
            new_data.time = current_time;
            rawData_getJointData(ref new_data.Head, JointType.Head);
            rawData_getJointData(ref new_data.ShoulderCenter, JointType.ShoulderCenter);
            rawData_getJointData(ref new_data.ShoulderLeft, JointType.ShoulderLeft);
            rawData_getJointData(ref new_data.ShoulderRight, JointType.ShoulderRight);
            rawData_getJointData(ref new_data.ElbowLeft, JointType.ElbowLeft);
            rawData_getJointData(ref new_data.ElbowRight, JointType.ElbowRight);
            rawData_getJointData(ref new_data.WristLeft, JointType.WristLeft);
            rawData_getJointData(ref new_data.WristRight, JointType.WristRight);
            rawData_getJointData(ref new_data.HandLeft, JointType.HandLeft);
            rawData_getJointData(ref new_data.HandRight, JointType.HandRight);
            //-------------------
            rawData_getJointData(ref new_data.Spine, JointType.Spine);
            rawData_getJointData(ref new_data.HipCenter, JointType.HipCenter);
            rawData_getJointData(ref new_data.HipLeft, JointType.HipLeft);
            rawData_getJointData(ref new_data.HipRight, JointType.HipRight);
            rawData_getJointData(ref new_data.KneeLeft, JointType.KneeLeft);
            rawData_getJointData(ref new_data.KneeRight, JointType.KneeRight);
            rawData_getJointData(ref new_data.AnkleLeft, JointType.AnkleLeft);
            rawData_getJointData(ref new_data.AnkleRight, JointType.AnkleRight);
            rawData_getJointData(ref new_data.FootLeft, JointType.FootLeft);
            rawData_getJointData(ref new_data.FootRight, JointType.FootRight);
            //===============
            data_raw.Add(new_data);
        }
Esempio n. 2
0
 //use first row
 public void recog_InitialPosture(UKI_DataRaw bp)
 {
     TheInitialPosture.data_raw = bp;
     data.initial_y             = bp.Spine[1];
     data.initial_knee_y        = (bp.KneeLeft[1] + bp.KneeRight[1]) / 2;
     data.initial_bend_ang      = ThePostureCal.calAngle_3D(bp.Head, bp.Spine, 2);
 }
Esempio n. 3
0
        /* This function give ids to Joints */

        private static Dictionary <int, double[]> FillSkeletonJointDictionary(UKI_DataRaw JointData)
        {
            var JointNumberDictionary = new Dictionary <int, double[]>();

            /* Center Body Parts from up to down*/
            JointNumberDictionary.Add(20, JointData.Head);
            JointNumberDictionary.Add(3, JointData.ShoulderCenter);
            JointNumberDictionary.Add(4, JointData.Spine);
            JointNumberDictionary.Add(7, JointData.HipCenter);

            /* Left Body Parts from up to down */
            JointNumberDictionary.Add(2, JointData.ShoulderLeft);
            JointNumberDictionary.Add(9, JointData.ElbowLeft);
            JointNumberDictionary.Add(11, JointData.WristLeft);
            JointNumberDictionary.Add(13, JointData.HandLeft);

            JointNumberDictionary.Add(6, JointData.HipLeft);
            JointNumberDictionary.Add(15, JointData.KneeLeft);
            JointNumberDictionary.Add(17, JointData.AnkleLeft);
            JointNumberDictionary.Add(19, JointData.FootLeft);

            /* Right Body Parts from up to down */
            JointNumberDictionary.Add(1, JointData.ShoulderRight);
            JointNumberDictionary.Add(8, JointData.ElbowRight);
            JointNumberDictionary.Add(10, JointData.WristRight);
            JointNumberDictionary.Add(12, JointData.HandRight);

            JointNumberDictionary.Add(5, JointData.HipRight);
            JointNumberDictionary.Add(14, JointData.KneeRight);
            JointNumberDictionary.Add(16, JointData.AnkleRight);
            JointNumberDictionary.Add(18, JointData.FootRight);

            return(JointNumberDictionary);
        }
Esempio n. 4
0
 public static void MocapNode_loadXYZ(ref UKI_DataRaw raw, MocapNode[] node_set)
 {
     MocapNode_loadXYZ_sub(ref raw.HipCenter, ref node_set[0]);
     MocapNode_loadXYZ_sub(ref raw.HipLeft, ref node_set[2]);
     MocapNode_loadXYZ_sub(ref raw.KneeLeft, ref node_set[3]);
     MocapNode_loadXYZ_sub(ref raw.AnkleLeft, ref node_set[4]);
     MocapNode_loadXYZ_sub(ref raw.FootLeft, ref node_set[5]);
     MocapNode_loadXYZ_sub(ref raw.HipRight, ref node_set[8]);
     MocapNode_loadXYZ_sub(ref raw.KneeRight, ref node_set[9]);
     MocapNode_loadXYZ_sub(ref raw.AnkleRight, ref node_set[10]);
     MocapNode_loadXYZ_sub(ref raw.FootRight, ref node_set[11]);
     //
     MocapNode_loadXYZ_sub(ref raw.Spine, ref node_set[14]);
     MocapNode_loadXYZ_sub(ref raw.ShoulderCenter, ref node_set[17]);
     MocapNode_loadXYZ_sub(ref raw.Head, ref node_set[19]);
     //
     MocapNode_loadXYZ_sub(ref raw.ShoulderLeft, ref node_set[21]);
     MocapNode_loadXYZ_sub(ref raw.ElbowLeft, ref node_set[22]);
     MocapNode_loadXYZ_sub(ref raw.WristLeft, ref node_set[23]);
     MocapNode_loadXYZ_sub(ref raw.HandLeft, ref node_set[26]);
     MocapNode_loadXYZ_sub(ref raw.ShoulderRight, ref node_set[30]);
     MocapNode_loadXYZ_sub(ref raw.ElbowRight, ref node_set[31]);
     MocapNode_loadXYZ_sub(ref raw.WristRight, ref node_set[32]);
     MocapNode_loadXYZ_sub(ref raw.HandRight, ref node_set[35]);
 }
Esempio n. 5
0
        /* This function return the JointToJoint geodesic distance of the given axis */

        private static double JointToJointPath(UKI_DataRaw joint_data, int axis)
        {
            Dictionary <int, double[]> joint_ids = FillSkeletonJointDictionary(joint_data);
            double path_value;

            path_value = (joint_ids[(int)JointValues.Head][axis] - joint_ids[(int)JointValues.ShoulderCenter][axis])
                         + (joint_ids[(int)JointValues.ShoulderCenter][axis] - joint_ids[(int)JointValues.ShoulderLeft][axis])
                         + (joint_ids[(int)JointValues.ShoulderLeft][axis] - joint_ids[(int)JointValues.ElbowLeft][axis])
                         + (joint_ids[(int)JointValues.ElbowLeft][axis] - joint_ids[(int)JointValues.WristLeft][axis])
                         + (joint_ids[(int)JointValues.WristLeft][axis] - joint_ids[(int)JointValues.HandLeft][axis])
                         + (joint_ids[(int)JointValues.ShoulderCenter][axis] - joint_ids[(int)JointValues.ShoulderRight][axis])
                         + (joint_ids[(int)JointValues.ShoulderRight][axis] - joint_ids[(int)JointValues.ElbowRight][axis])
                         + (joint_ids[(int)JointValues.ElbowRight][axis] - joint_ids[(int)JointValues.WristRight][axis])
                         + (joint_ids[(int)JointValues.WristRight][axis] - joint_ids[(int)JointValues.HandRight][axis])
                         + (joint_ids[(int)JointValues.ShoulderCenter][axis] - joint_ids[(int)JointValues.Spine][axis])
                         + (joint_ids[(int)JointValues.Spine][axis] - joint_ids[(int)JointValues.HipCenter][axis])
                         + (joint_ids[(int)JointValues.HipCenter][axis] - joint_ids[(int)JointValues.HipLeft][axis])
                         + (joint_ids[(int)JointValues.HipLeft][axis] - joint_ids[(int)JointValues.KneeLeft][axis])
                         + (joint_ids[(int)JointValues.KneeLeft][axis] - joint_ids[(int)JointValues.AnkleLeft][axis])
                         + (joint_ids[(int)JointValues.AnkleLeft][axis] - joint_ids[(int)JointValues.FootLeft][axis])
                         + (joint_ids[(int)JointValues.HipCenter][axis] - joint_ids[(int)JointValues.HipRight][axis])
                         + (joint_ids[(int)JointValues.HipRight][axis] - joint_ids[(int)JointValues.KneeRight][axis])
                         + (joint_ids[(int)JointValues.KneeRight][axis] - joint_ids[(int)JointValues.AnkleRight][axis])
                         + (joint_ids[(int)JointValues.AnkleRight][axis] - joint_ids[(int)JointValues.FootRight][axis]);


            return(path_value);
        }
Esempio n. 6
0
        /* This function summarize only head and spines Joint Vector from a given Joint Data Set.
         * jointData is the joints data set.
         */

        private static double[] SummarizeJointsVectorFromHeadAndTorso(UKI_DataRaw joint_data)
        {
            Type joint_data_type = joint_data.GetType();

            double[] result = new double[3] {
                0f, 0f, 0f
            };
            string[] field_names = new string[] { "ShoulderCenter", "Spine", "HipCenter", "Head" };

            // To loop through the members
            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                // Console.WriteLine(info.Name);
                for (int i = 0; i < field_names.Length; i++)
                {
                    if (info.Name == field_names[i])
                    {
                        double[] vector_infos = new double[] { 0, 0, 0 };

                        vector_infos = info.GetValue(joint_data) as double[];
                        result[0]   += vector_infos[0];
                        result[1]   += vector_infos[1];
                        result[2]   += vector_infos[2];
                    }
                }
            }

            return(result);
        }
Esempio n. 7
0
        /* This function create a RawData object from a string format as a CSV File using coma delimiter */

        public static UKI_DataRaw CreateSkeletonRawDataFromString(string data)
        {
            var normalized_skeleton_data = new UKI_DataRaw();

            double[] tmp_condition_type = new double[] { 0, 0, 0 };
            int      i = 1;

            string[] xyz_vector_data = data.Split(',');

            normalized_skeleton_data.time = "";
            normalized_skeleton_data.id   = 0;

            Type joint_data_type = normalized_skeleton_data.GetType();

            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                if (info.FieldType == tmp_condition_type.GetType())
                {
                    double[] xyz_joint_vector = new double[] { 0, 0, 0 };
                    xyz_joint_vector[0] = double.Parse(xyz_vector_data[i]);
                    xyz_joint_vector[1] = double.Parse(xyz_vector_data[i + 1]);
                    xyz_joint_vector[2] = double.Parse(xyz_vector_data[i + 2]);
                    i += 3;
                    info.SetValue(normalized_skeleton_data, xyz_joint_vector);
                }
            }

            return(normalized_skeleton_data);
        }
Esempio n. 8
0
        // "saveFolder" end with \
        public static void calSparse(List <UKI_DataRaw> list_extractPose, string saveFolder, string filename)
        {
            try
            {
                List <String> list_data_n1 = new List <String> {
                };
                List <String> list_data_n2 = new List <String> {
                };
                List <String> list_data_n3 = new List <String> {
                };

                UKI_DataRaw pose_canonical = null;
                UKI_DataRaw pose_current   = null;

                list_data_n1.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType()));
                list_data_n2.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType()));
                list_data_n3.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType()));

                int index_canonical = 0; int index_current = 0; String row_name;
                foreach (UKI_DataRaw r in list_extractPose)
                {
                    pose_current = r; index_current = r.id;
                    //----------------------------------------------------
                    String data = "";
                    if (pose_canonical != null)
                    {
                        row_name = index_canonical + " to " + index_current + ",";
                        double   duration_frame_inverse = 1.0f / (pose_current.id - pose_canonical.id);
                        double[] joint_sum = SummarizeJointsVector(pose_current);
                        data = row_name + DisplayJointsVectorToCentroid(pose_current, joint_sum, duration_frame_inverse, pose_canonical);
                        list_data_n1.Add(data);

                        UKI_DataRaw joint_vector_s_1 = CreateSkeletonRawDataFromString(data);

                        double[] xyz_size_vector_current_pose   = JointToJointSize(joint_vector_s_1);
                        double[] xyz_size_vector_canonical_pose = JointToJointSize(pose_canonical);

                        data = row_name + DisplayJointsVectorRescalling(joint_vector_s_1, xyz_size_vector_canonical_pose, xyz_size_vector_current_pose);
                        list_data_n2.Add(data);

                        UKI_DataRaw joint_vector_s_2 = CreateSkeletonRawDataFromString(data);

                        double[] joint_sum_canonical_ht = SummarizeJointsVectorFromHeadAndTorso(pose_canonical);
                        double[] joint_sum_current_ht   = SummarizeJointsVectorFromHeadAndTorso(joint_vector_s_2);

                        data = row_name + DisplayJointsVectorHeadAndTorsoToCentroid(joint_vector_s_2, joint_sum_canonical_ht, joint_sum_current_ht, duration_frame_inverse);
                        list_data_n3.Add(data);
                    }
                    //----------------------------------------------------
                    pose_canonical = r; index_canonical = r.id;
                }
                TheTool.exportCSV_orTXT(saveFolder + "N1_" + filename + ".csv", list_data_n1, false);
                TheTool.exportCSV_orTXT(saveFolder + "N2_" + filename + ".csv", list_data_n2, false);
                TheTool.exportCSV_orTXT(saveFolder + "N3_" + filename + ".csv", list_data_n3, false);
            }
            catch (Exception ex) { TheSys.showError(ex); }
        }
Esempio n. 9
0
        void drawSkel(Image img, UKI_DataRaw skel)
        {
            DrawingImage imageSource;
            DrawingGroup drawingGroup;

            drawingGroup = new DrawingGroup();
            imageSource  = new DrawingImage(drawingGroup);
            using (DrawingContext dc = drawingGroup.Open())
            {
                checkRange(skel);
                dc.DrawRectangle(Brushes.Black, null, new Rect(-ScreenWidthHalf, 0, ScreenWidth, ScreenHeight));
                // Render Bones
                drawBone(dc, skel.Head, skel.ShoulderCenter);
                drawBone(dc, skel.ShoulderCenter, skel.Spine);
                drawBone(dc, skel.ShoulderCenter, skel.ShoulderLeft);
                drawBone(dc, skel.ShoulderCenter, skel.ShoulderRight);
                drawBone(dc, skel.ShoulderLeft, skel.ElbowLeft);
                drawBone(dc, skel.ElbowLeft, skel.WristLeft);
                drawBone(dc, skel.WristLeft, skel.HandLeft);
                drawBone(dc, skel.ShoulderRight, skel.ElbowRight);
                drawBone(dc, skel.ElbowRight, skel.WristRight);
                drawBone(dc, skel.WristRight, skel.HandRight);
                drawBone(dc, skel.Spine, skel.HipCenter);
                drawBone(dc, skel.HipCenter, skel.HipLeft);
                drawBone(dc, skel.HipCenter, skel.HipRight);
                drawBone(dc, skel.HipLeft, skel.KneeLeft);
                drawBone(dc, skel.KneeLeft, skel.AnkleLeft);
                drawBone(dc, skel.AnkleLeft, skel.FootLeft);
                drawBone(dc, skel.HipRight, skel.KneeRight);
                drawBone(dc, skel.KneeRight, skel.AnkleRight);
                drawBone(dc, skel.AnkleRight, skel.FootRight);
                //-------------------
                // Render Joints
                drawJoint(dc, skel.Head);
                drawJoint(dc, skel.ShoulderCenter);
                drawJoint(dc, skel.ShoulderLeft);
                drawJoint(dc, skel.ElbowLeft);
                drawJoint(dc, skel.WristLeft);
                drawJoint(dc, skel.HandLeft);
                drawJoint(dc, skel.ShoulderRight);
                drawJoint(dc, skel.ElbowRight);
                drawJoint(dc, skel.WristRight);
                drawJoint(dc, skel.HandRight);
                drawJoint(dc, skel.Spine);
                drawJoint(dc, skel.HipCenter);
                drawJoint(dc, skel.HipLeft);
                drawJoint(dc, skel.KneeLeft);
                drawJoint(dc, skel.AnkleLeft);
                drawJoint(dc, skel.FootLeft);
                drawJoint(dc, skel.HipRight);
                drawJoint(dc, skel.KneeRight);
                drawJoint(dc, skel.AnkleRight);
                drawJoint(dc, skel.FootRight);
            }
            img.Source = imageSource;
        }
Esempio n. 10
0
 public void offline_process(UKI_Offline mr)
 {
     offline_skel_current = mr.current_data;
     offline_updateSkel(offline_skel_current);
     //if (ready)
     //{
     offline_calMove();
     calSum();
     calSumAvg();
     //}
 }
Esempio n. 11
0
 private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     try
     {
         skel               = data_skel[(int)slider.Value];
         skel_centered      = TheUKI.UKI_DataRaw_centerize(skel, 3);
         txtCurrent.Content = skel.id;
         update();
     }
     catch { }
 }
Esempio n. 12
0
 public void offline_updateSkel(UKI_DataRaw s)
 {
     offline_skel_list.Add(offline_skel_current);
     if (offline_skel_list.Count > move_size - 1)
     {
         //ready = true;
         offline_skel_last = offline_skel_list.First(); offline_skel_list.RemoveAt(0);
     }
     else
     {
         offline_skel_last = offline_skel_list.First();
     }
     //else { ready = false; }
 }
Esempio n. 13
0
        /* This function add column infos on the CSV file */

        private static string DisplayColumnInfo(UKI_DataRaw jointData, Type type_of_members)
        {
            string infos           = "    ,";
            Type   joint_data_type = jointData.GetType();

            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                if (info.FieldType == type_of_members)
                {
                    infos += info.Name + "_x," + info.Name + "_y," + info.Name + "_z,";
                }
            }
            return(infos);
        }
Esempio n. 14
0
 void checkRange(UKI_DataRaw skel)
 {
     range_jointNearest  = skel.Head[2];
     range_jointNearest  = Math.Min(range_jointNearest, skel.ShoulderCenter[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.ShoulderLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.ElbowLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.WristLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.HandLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.ShoulderRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.ElbowRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.WristRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.HandRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.Spine[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.HipCenter[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.HipLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.KneeLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.AnkleLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.FootLeft[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.HipRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.KneeRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.AnkleRight[2]);
     range_jointNearest  = Math.Min(range_jointNearest, skel.FootRight[2]);
     range_jointFarthest = skel.Head[2];
     range_jointFarthest = Math.Max(range_jointNearest, skel.ShoulderCenter[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.ShoulderLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.ElbowLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.WristLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.HandLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.ShoulderRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.ElbowRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.WristRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.HandRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.Spine[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.HipCenter[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.HipLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.KneeLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.AnkleLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.FootLeft[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.HipRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.KneeRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.AnkleRight[2]);
     range_jointFarthest = Math.Max(range_jointNearest, skel.FootRight[2]);
     if (range_jointFarthest == range_jointNearest)
     {
         range_jointFarthest += 1;
     }
 }
Esempio n. 15
0
 void update()
 {
     if (data_skel.Count > 0)
     {
         int         angle       = (int)sliderRotate.Value;
         int         tilt        = (int)sliderTilt.Value;
         UKI_DataRaw skel_rotate = TheTool.rotateSkel(skel, angle, false);
         this.skel_visual = TheTool.rotateSkel(skel_rotate, tilt, true);
         zoomRange        = -150;
         noSlide          = true;
         drawSkel(image2, TheTool.rotateSkel(skel_centered, 90, false));
         drawSkel(image3, TheTool.rotateSkel(skel_centered, -90, false));
         noSlide   = false;
         zoomRange = sliderZoom.Value;
         drawSkel(image1, this.skel_visual);
         txtRange.Content = "Range: " + (Math.Round(skel.Spine[2], 2) * 100) + " cm";
     }
 }
Esempio n. 16
0
        /* This function return the XYZ_Vector of the total size of the given skeleton */

        private static double[] JointToJointSize(UKI_DataRaw joint_data)
        {
            double size_x;
            double size_y;
            double size_z;

            double[] xyz_size_vector = new double[] { 0, 0, 0 };

            size_x = JointToJointPath(joint_data, 0);
            size_y = JointToJointPath(joint_data, 1);
            size_z = JointToJointPath(joint_data, 2);

            xyz_size_vector[0] = size_x;
            xyz_size_vector[1] = size_y;
            xyz_size_vector[2] = size_z;

            return(xyz_size_vector);
        }
Esempio n. 17
0
        /* This function add result of final centroid caculation in the CSV file */

        private static string DisplayJointsVectorHeadAndTorsoToCentroid(UKI_DataRaw joint_data, double[] joint_sum_canonical, double[] joint_sum_current, double duration_frame_inverse)
        {
            string infos           = "";
            Type   joint_data_type = joint_data.GetType();

            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                if (info.FieldType == joint_sum_canonical.GetType())
                {
                    double[] xyz_joint_vector = info.GetValue(joint_data) as double[];
                    double   normalized_x     = SpineCentroidCalculation(xyz_joint_vector[0], joint_sum_canonical[0], joint_sum_current[0], duration_frame_inverse);
                    double   normalized_y     = SpineCentroidCalculation(xyz_joint_vector[1], joint_sum_canonical[1], joint_sum_current[1], duration_frame_inverse);
                    double   normalized_z     = SpineCentroidCalculation(xyz_joint_vector[2], joint_sum_canonical[2], joint_sum_current[2], duration_frame_inverse);

                    infos += normalized_x + "," + normalized_y + "," + normalized_z + ",";
                }
            }
            return(infos);
        }
Esempio n. 18
0
 //compare to UKI.doTrack()
 public void simulateRunning()
 {
     foreach (UKI_DataRaw d in data.data_raw)
     {
         current_data = d;
         data.process01_calVariable_ver1_mandatory(current_data);
         if (run_type != -1)
         {
             data.process01_calVariable_ver1_optional(current_data);
             data.process02_BasicPostureDetection();
         }
         if (run_type == 1)
         {
             data.process04_specialPose();
         }
         collectData();
         current_time++;
     }
 }
Esempio n. 19
0
        /* This function shifts joint such that the centroid is at the origin*/

        private static string DisplayJointsVectorToCentroid(UKI_DataRaw jointData, double[] joint_sum, double duration_frame_inverse,
                                                            UKI_DataRaw canonicalJointData)
        {
            string infos           = "";
            Type   joint_data_type = jointData.GetType();

            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                if (info.FieldType == joint_sum.GetType())
                {
                    double[] xyz_joint_vector = info.GetValue(jointData) as double[];
                    double   normalized_x     = ShiftJointVectorToCentroid(xyz_joint_vector[0], joint_sum[0], duration_frame_inverse);
                    double   normalized_y     = ShiftJointVectorToCentroid(xyz_joint_vector[1], joint_sum[1], duration_frame_inverse);;
                    double   normalized_z     = ShiftJointVectorToCentroid(xyz_joint_vector[2], joint_sum[2], duration_frame_inverse);;

                    infos += normalized_x + "," + normalized_y + "," + normalized_z + ",";
                }
            }
            return(infos);
        }
Esempio n. 20
0
        /* This function add result of rescalling in the CSV file */

        private static string DisplayJointsVectorRescalling(UKI_DataRaw joint_data, double[] canonical_pose_vector, double[] current_pose_vector)
        {
            string infos = "";

            Type joint_data_type = joint_data.GetType();

            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                if (info.FieldType == canonical_pose_vector.GetType())
                {
                    double[] xyz_joint_vector = info.GetValue(joint_data) as double[];
                    double   normalized_x     = RescaleJointsVector(xyz_joint_vector[0], canonical_pose_vector[0], current_pose_vector[0]);
                    double   normalized_y     = RescaleJointsVector(xyz_joint_vector[1], canonical_pose_vector[1], current_pose_vector[1]);
                    double   normalized_z     = RescaleJointsVector(xyz_joint_vector[2], canonical_pose_vector[2], current_pose_vector[2]);

                    infos += normalized_x + "," + normalized_y + "," + normalized_z + ",";
                }
            }
            return(infos);
        }
Esempio n. 21
0
 public void process01_calVariable_ver1_optional(UKI_DataRaw current_data)
 {
     cur_bendAngle   = ThePostureCal.calAngle_3D(current_data.Head, current_data.Spine, 2);
     facing_Angle    = ThePostureCal.calAngle_3D(current_data.ShoulderLeft, current_data.ShoulderRight, 2);
     diff_bend_Angle = cur_bendAngle - initial_bend_ang;
     diff_kneeL_Y    = current_data.KneeLeft[1] - initial_knee_y;
     diff_kneeR_Y    = current_data.KneeRight[1] - initial_knee_y;
     //
     diff_hL_sC_X = current_data.HandLeft[0] - current_data.ShoulderCenter[0];
     diff_hL_sC_Y = current_data.HandLeft[1] - current_data.ShoulderCenter[1];
     diff_hL_sC_Z = current_data.HandLeft[2] - current_data.ShoulderCenter[2];
     diff_hR_sC_X = current_data.HandRight[0] - current_data.ShoulderCenter[0];
     diff_hR_sC_Y = current_data.HandRight[1] - current_data.ShoulderCenter[1];
     diff_hR_sC_Z = current_data.HandRight[2] - current_data.ShoulderCenter[2];
     //Additional
     diff_fL_kL_Z = current_data.FootLeft[2] - current_data.KneeLeft[2];
     diff_fR_kR_Z = current_data.FootRight[2] - current_data.KneeRight[2];
     //
     diff_handLR_eu = TheUKI.getDist(current_data.HandLeft, current_data.HandRight);
     diff_footLR_Z  = current_data.FootLeft[2] - current_data.FootRight[2];
 }
Esempio n. 22
0
 //row_bvh : 9.3722 17.8693 -17.3198 0 0 0 ...
 public static void BVH_readRow(ref List <UKI_DataRaw> list_raw, ref List <MocapNode[]> list_nodeSet, int row_i, string row_bvh)
 {
     if (row_bvh != "")
     {
         UKI_DataRaw raw     = new UKI_DataRaw();
         MocapNode[] nodeSet = TheBVH.getInitialNode();
         string[]    column  = TheTool.splitText(row_bvh, " ");
         raw.id = row_i;
         int i = 0;
         for (int countnode = 0; countnode < nodeSet.Count(); countnode++)
         {
             if (countnode == 0) //root
             {
                 nodeSet[countnode].setTranslate(column[i], column[i + 1], column[i + 2]);
                 nodeSet[countnode].setRotation(column[i + 5], column[i + 4], column[i + 3]);
                 nodeSet[countnode].createRotationMatrix();
                 i += 6;
             }
             else if (nodeSet[countnode].isEndsite)
             {
                 nodeSet[countnode].setRotation(0, 0, 0);
                 nodeSet[countnode].createRotationMatrix();
             }
             else
             {
                 nodeSet[countnode].setRotation(column[i + 2], column[i + 1], column[i]);
                 nodeSet[countnode].createRotationMatrix();
                 i += 3;
             }
             nodeSet[countnode].tranformRotate();
         }
         TheBVH.MocapNode_loadXYZ(ref raw, nodeSet);
         list_nodeSet.Add(nodeSet);
         list_raw.Add(raw);
     }
 }
Esempio n. 23
0
        /* This function summarize all Joint Vector from a given Joint Data Set.
         * jointData is the joints data set.
         */

        private static double[] SummarizeJointsVector(UKI_DataRaw jointData)
        {
            Type joint_data_type = jointData.GetType();

            double[] result = new double[3] {
                0f, 0f, 0f
            };

            // To loop through the members
            foreach (System.Reflection.FieldInfo info in joint_data_type.GetFields())
            {
                if (info.FieldType == result.GetType())
                {
                    double[] vector_infos = new double[] { 0, 0, 0 };

                    vector_infos = info.GetValue(jointData) as double[];
                    result[0]   += vector_infos[0];
                    result[1]   += vector_infos[1];
                    result[2]   += vector_infos[2];
                }
            }

            return(result);
        }
Esempio n. 24
0
 void hotKey(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (e.Key == Key.F1)
     {
         quickMark();
         return;
     }
     else if (e.Key == Key.F2)
     {
         slider.Value       = slider.Maximum;
         txtCurrent.Content = data_skel.Last().id;
         skel = data_skel.Last();
         update();
         //
         quickMark();
         export();
         return;
     }
     else if (e.Key == Key.Space)
     {
         playPause();
         return;
     }
 }
Esempio n. 25
0
 public void process01_calVariable_ver1_mandatory(UKI_DataRaw current_data)
 {
     diff_sp_Y = current_data.Spine[1] - initial_y;
 }
Esempio n. 26
0
        public static List <UKI_DataRaw> MSRAction_convert(String path_origin)
        {
            List <UKI_DataRaw> list_raw = new List <UKI_DataRaw>();

            try
            {
                int         id       = 0;
                UKI_DataRaw data_raw = new UKI_DataRaw();
                data_raw.id = id;
                List <string> data_origin = TheTool.read_File_getListString(path_origin);
                int           row_i       = 1;
                foreach (string row in data_origin)
                {
                    int j_id = row_i % 20;
                    if (j_id == 1)
                    {
                        MSRAction_convert(ref data_raw.ShoulderRight, row);
                    }
                    else if (j_id == 2)
                    {
                        MSRAction_convert(ref data_raw.ShoulderLeft, row);
                    }
                    else if (j_id == 3)
                    {
                        MSRAction_convert(ref data_raw.ShoulderCenter, row);
                    }
                    else if (j_id == 4)
                    {
                        MSRAction_convert(ref data_raw.Spine, row);
                    }
                    else if (j_id == 5)
                    {
                        MSRAction_convert(ref data_raw.HipRight, row);
                    }
                    else if (j_id == 6)
                    {
                        MSRAction_convert(ref data_raw.HipLeft, row);
                    }
                    else if (j_id == 7)
                    {
                        MSRAction_convert(ref data_raw.HipCenter, row);
                    }
                    else if (j_id == 8)
                    {
                        MSRAction_convert(ref data_raw.ElbowRight, row);
                    }
                    else if (j_id == 9)
                    {
                        MSRAction_convert(ref data_raw.ElbowLeft, row);
                    }
                    else if (j_id == 10)
                    {
                        MSRAction_convert(ref data_raw.WristRight, row);
                    }
                    else if (j_id == 11)
                    {
                        MSRAction_convert(ref data_raw.WristLeft, row);
                    }
                    else if (j_id == 12)
                    {
                        MSRAction_convert(ref data_raw.HandRight, row);
                    }
                    else if (j_id == 13)
                    {
                        MSRAction_convert(ref data_raw.HandLeft, row);
                    }
                    else if (j_id == 14)
                    {
                        MSRAction_convert(ref data_raw.KneeRight, row);
                    }
                    else if (j_id == 15)
                    {
                        MSRAction_convert(ref data_raw.KneeLeft, row);
                    }
                    else if (j_id == 16)
                    {
                        MSRAction_convert(ref data_raw.AnkleRight, row);
                    }
                    else if (j_id == 17)
                    {
                        MSRAction_convert(ref data_raw.AnkleLeft, row);
                    }
                    else if (j_id == 18)
                    {
                        MSRAction_convert(ref data_raw.FootRight, row);
                    }
                    else if (j_id == 19)
                    {
                        MSRAction_convert(ref data_raw.FootLeft, row);
                    }
                    else if (j_id == 0)
                    {
                        MSRAction_convert(ref data_raw.Head, row);
                        list_raw.Add(data_raw);
                        data_raw = new UKI_DataRaw();
                        id++;
                    }
                    row_i++;
                }
            }
            catch (Exception ex) { TheSys.showError(ex); }
            return(list_raw);
        }
Esempio n. 27
0
        //public static double getJointAxis_ChangeFromInitial(UKI_DataRaw data, String jointName, String axis)
        //{
        //    double v1 = getJointAxis(data, jointName, axis);
        //    double v2 = getJointAxis(TheInitialPosture.data_raw, jointName, axis);
        //    return v1 - v2;
        //}

        public static double getJointAxis(UKI_DataRaw data, String jointName, String axis)
        {
            double output  = 0;
            int    axis_id = 0;

            if (axis == "Y")
            {
                axis_id = 1;
            }
            else if (axis == "Z")
            {
                axis_id = 2;
            }
            //
            if (jointName == "AnkleL")
            {
                output = data.AnkleLeft[axis_id];
            }
            else if (jointName == "AnkleR")
            {
                output = data.AnkleRight[axis_id];
            }
            else if (jointName == "ElbowL")
            {
                output = data.ElbowLeft[axis_id];
            }
            else if (jointName == "ElbowR")
            {
                output = data.ElbowRight[axis_id];
            }
            else if (jointName == "FootL")
            {
                output = data.FootLeft[axis_id];
            }
            else if (jointName == "FootR")
            {
                output = data.FootRight[axis_id];
            }
            else if (jointName == "HandL")
            {
                output = data.HandLeft[axis_id];
            }
            else if (jointName == "HandR")
            {
                output = data.HandRight[axis_id];
            }
            else if (jointName == "Head")
            {
                output = data.Head[axis_id];
            }
            else if (jointName == "HipC")
            {
                output = data.HipCenter[axis_id];
            }
            else if (jointName == "HipL")
            {
                output = data.HipLeft[axis_id];
            }
            else if (jointName == "HipR")
            {
                output = data.HipRight[axis_id];
            }
            else if (jointName == "KneeL")
            {
                output = data.KneeLeft[axis_id];
            }
            else if (jointName == "KneeR")
            {
                output = data.KneeRight[axis_id];
            }
            else if (jointName == "ShoulderC")
            {
                output = data.ShoulderCenter[axis_id];
            }
            else if (jointName == "ShoulderL")
            {
                output = data.ShoulderLeft[axis_id];
            }
            else if (jointName == "ShoulderR")
            {
                output = data.ShoulderRight[axis_id];
            }
            else if (jointName == "Spine")
            {
                output = data.Spine[axis_id];
            }
            else if (jointName == "WristL")
            {
                output = data.WristLeft[axis_id];
            }
            else if (jointName == "WristR")
            {
                output = data.WristRight[axis_id];
            }
            return(output);
        }
Esempio n. 28
0
 public static double[] getJoint(UKI_DataRaw data, String jointName)
 {
     double[] output = new double[3];
     if (jointName == "AnkleL")
     {
         output = data.AnkleLeft;
     }
     else if (jointName == "AnkleR")
     {
         output = data.AnkleRight;
     }
     else if (jointName == "ElbowL")
     {
         output = data.ElbowLeft;
     }
     else if (jointName == "ElbowR")
     {
         output = data.ElbowRight;
     }
     else if (jointName == "FootL")
     {
         output = data.FootLeft;
     }
     else if (jointName == "FootR")
     {
         output = data.FootRight;
     }
     else if (jointName == "HandL")
     {
         output = data.HandLeft;
     }
     else if (jointName == "HandR")
     {
         output = data.HandRight;
     }
     else if (jointName == "Head")
     {
         output = data.Head;
     }
     else if (jointName == "HipC")
     {
         output = data.HipCenter;
     }
     else if (jointName == "HipL")
     {
         output = data.HipLeft;
     }
     else if (jointName == "HipR")
     {
         output = data.HipRight;
     }
     else if (jointName == "KneeL")
     {
         output = data.KneeLeft;
     }
     else if (jointName == "KneeR")
     {
         output = data.KneeRight;
     }
     else if (jointName == "ShoulderC")
     {
         output = data.ShoulderCenter;
     }
     else if (jointName == "ShoulderL")
     {
         output = data.ShoulderLeft;
     }
     else if (jointName == "ShoulderR")
     {
         output = data.ShoulderRight;
     }
     else if (jointName == "Spine")
     {
         output = data.Spine;
     }
     else if (jointName == "WristL")
     {
         output = data.WristLeft;
     }
     else if (jointName == "WristR")
     {
         output = data.WristRight;
     }
     return(output);
 }