コード例 #1
0
ファイル: ThePosExtract.cs プロジェクト: icelab-uki/uki
        //return key when Jump (highest point)
        public static List <int_double> calJump(List <UKI_DataMovement> list_movement)
        {
            List <int_double> list_key    = new List <int_double>();
            Boolean           duringJump  = false;
            UKI_DataMovement  highest_key = new UKI_DataMovement();

            foreach (UKI_DataMovement u in list_movement)
            {
                if (u.spine_Y > jump_threshold)
                {
                    if (u.spine_Y > highest_key.spine_Y)
                    {
                        highest_key = u;
                    }
                    duringJump = true;
                    if (highest_key.type_algo != 0)
                    {
                        highest_key.type_algo = 0.33;
                    }
                }
                else if (duringJump)
                {
                    highest_key.type_algo = 0.66;
                    int[] key = new int[] {};
                    list_key.Add(new int_double()
                    {
                        i = highest_key.id, v = highest_key.spine_Y
                    });
                    duringJump  = false;
                    highest_key = new UKI_DataMovement();
                }
            }
            return(list_key);
        }
コード例 #2
0
ファイル: UKI_Data.cs プロジェクト: icelab-uki/uki
        public void collectData_Movement()
        {
            UKI_DataMovement new_data = new UKI_DataMovement();

            new_data.id          = current_id;
            new_data.time        = current_time;
            new_data.spine_Y     = diff_sp_Y;
            new_data.ms_all_avg  = tool_posExtract.ms_all_avg;
            new_data.ms_hand_avg = tool_posExtract.ms_hand_avg;
            new_data.ms_leg_avg  = tool_posExtract.ms_leg_avg;
            new_data.ms_core_avg = tool_posExtract.ms_core_avg;
            new_data.ms_all      = tool_posExtract.ms_all;
            new_data.ms_hand     = tool_posExtract.ms_hand;
            new_data.ms_leg      = tool_posExtract.ms_leg;
            new_data.ms_core     = tool_posExtract.ms_core;
            data_movement.Add(new_data);
        }
コード例 #3
0
ファイル: ThePosExtract.cs プロジェクト: icelab-uki/uki
        public static List <int[]> calMinMaxMin(List <UKI_DataMovement> list_movement)
        {
            List <int[]> list_MMM = new List <int[]>();

            int[] MMM = new int[] { -1, -1, -1 };
            if (list_movement.Count > 0)
            {
                try
                {
                    //-- check Min Max value ----------------------------
                    double d     = 0; //current
                    double d_min = 0; //must be > 0 after process
                    double d_max = 0;
                    foreach (UKI_DataMovement u in list_movement)
                    {
                        d = u.ms_all_avg;
                        if (d > 0)
                        {
                            if (d_min == 0)
                            {
                                d_min = d;
                            }
                            else if (d < d_min)
                            {
                                d_min = d;
                            }
                            if (d > d_max)
                            {
                                d_max = d;
                            }
                        }
                    }
                    double d_range      = d_max - d_min;
                    double d_minmove    = Math.Abs(d_range * threshold_minmove);
                    double d_lowerBound = d_min + d_minmove; //at Percentile 20 from Global Min
                    double predictMin   = d_lowerBound;      //highest point that next minimum can be accepted
                    double predictMax   = d_lowerBound;      //lowest point that next maximum can be accepted
                    //-- fin Min Max location -------------- -------------
                    Boolean goUp_current  = true;            //current direction
                    Boolean goUp_last     = true;            //last scaned direction
                    double  value_last    = 0;               //last scaned unit
                    double  value_current = 0;               //current scaned unit
                    double  value_change  = 0;
                    //-----------------
                    UKI_DataMovement recentAccepted = list_movement.First(); //last accepted Minima / Maxima
                    UKI_DataMovement lastItem       = list_movement.First(); //last accepted Minima / Maxima
                    recentAccepted.type_algo = -1;
                    MMM[0] = recentAccepted.id;
                    //Start higher than threshold, use 0 as Min1
                    foreach (UKI_DataMovement u in list_movement.Skip(1))
                    {
                        u.type_algo   = 0;
                        value_current = u.ms_all_avg;
                        value_change  = value_current - value_last;
                        //---------------------------------
                        if (value_change >= 0)
                        {
                            goUp_current = true;
                        }
                        else
                        {
                            goUp_current = false;
                        }
                        //
                        if (predictMin == 0 || value_current < predictMin)
                        {
                            predictMax = Math.Max(Math.Min(value_current + d_minmove, predictMax), d_lowerBound);
                            predictMin = Math.Max(value_current, d_lowerBound);
                        }
                        if (value_current > predictMax)
                        {
                            predictMax = value_current;
                            predictMin = Math.Max(value_current - d_minmove, d_lowerBound);
                        }
                        //---------------------------------
                        //Min0 by Bound-Pass or LastAccept-Pass
                        if ((boundPass && value_last < d_lowerBound && value_current >= d_lowerBound)
                            ||
                            (!boundPass && value_last < recentAccepted.ms_all_avg && value_current >= recentAccepted.ms_all_avg))
                        {
                            if (list_MMM.Count == 0 || (list_MMM.Last()[2] != MMM[0]))
                            {
                                recentAccepted.type_algo = 0;
                            }
                            recentAccepted           = u;
                            recentAccepted.type_algo = -1;
                            MMM[0] = recentAccepted.id;
                        }
                        //Min2 by Bound
                        else if (value_last >= d_lowerBound && value_current < d_lowerBound)
                        {
                            if (MMM[1] >= 0 && MMM[2] < 0)
                            {
                                //found Min2 & Complete
                                recentAccepted           = u;
                                recentAccepted.type_algo = -1;
                                MMM[2] = recentAccepted.id; list_MMM.Add(MMM);
                                //
                                MMM    = new int[] { -1, -1, -1 };
                                MMM[0] = recentAccepted.id;//First of new set
                            }
                            else if (MMM[1] < 0 && list_MMM.Count > 0 && list_MMM.Last()[2] > d_lowerBound)
                            {
                                //adjust last End
                                recentAccepted.type_algo = 0;
                                recentAccepted           = u;
                                recentAccepted.type_algo = -1;
                            }
                        }
                        else if (goUp_current != goUp_last) //found change in Direction
                        {
                            //During finding Min2
                            if (MMM[1] >= 0 && MMM[2] < 0)
                            {
                                if (s_locate && goUp_current && value_last <= predictMin)
                                {
                                    //found Min2 & Complete
                                    if (MMM[2] >= 0)
                                    {
                                        recentAccepted.type_algo = 0;
                                    }
                                    recentAccepted     = lastItem;
                                    lastItem.type_algo = -1;
                                    MMM[2]             = recentAccepted.id; list_MMM.Add(MMM);
                                    //
                                    MMM    = new int[] { -1, -1, -1 };
                                    MMM[0] = recentAccepted.id;//First of new set
                                }
                                else if (!goUp_current && value_last > recentAccepted.ms_all_avg)
                                {
                                    //found higher Max1
                                    if (MMM[1] >= 0)
                                    {
                                        recentAccepted.type_algo = 0;
                                    }
                                    recentAccepted           = lastItem;
                                    recentAccepted.type_algo = 1;
                                    MMM[1] = recentAccepted.id;// -1 because we collect last data before change
                                    //
                                    predictMin = Math.Max(value_last - d_minmove, d_lowerBound);
                                }
                            }
                            //During finding Max1
                            else if (MMM[0] >= 0 && MMM[1] < 0)
                            {
                                if (!goUp_current && value_last >= predictMax)
                                {
                                    //found Max
                                    if (MMM[1] >= 0)
                                    {
                                        recentAccepted.type_algo = 0;
                                    }
                                    recentAccepted           = u;
                                    MMM[1]                   = recentAccepted.id;
                                    recentAccepted.type_algo = 1;
                                    //
                                    predictMin = Math.Max(value_current - d_minmove, d_lowerBound);
                                }
                                else if (value_last < recentAccepted.ms_all_avg && value_last > d_lowerBound)
                                {
                                    //found lower Min0
                                    recentAccepted.type_algo = 0;
                                    recentAccepted           = lastItem;
                                    MMM[0] = recentAccepted.id;
                                    recentAccepted.type_algo = -1;
                                    //
                                    if (list_MMM.Count > 0)
                                    {
                                        list_MMM.Last()[2] = recentAccepted.id;
                                    }
                                }
                            }
                        }
                        //-----------------------------------------
                        u.myalgo_bound_lowest       = d_lowerBound;
                        u.myalgo_bound_predictedMin = predictMin;
                        u.myalgo_bound_predictedMax = predictMax;
                        //----
                        goUp_last  = goUp_current;
                        value_last = value_current;
                        lastItem   = u;
                    }//for each
                     //if (MMM[2] >= 0) { list_MMM.Add(MMM); }//add last item
                     //else if (MMM[0] >= 0 && MMM[1] < 0) { recentAccepted.type_algo = 0; }//delete last item
                }
                catch (Exception ex) { TheSys.showError(ex); }
            }
            //------------------------------------
            return(list_MMM);
        }