Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }