예제 #1
0
    //KNN 코루틴 호성이 시작
    IEnumerator GetLastKnnEvaluation()
    {
        Knn_Calculate knn_instance = new Knn_Calculate();

        knn_instance.Init();
        Knn_Results result = knn_instance.Knn_Execute();

        this.dataManager.AddKnnResults(result);
        yield return(null);
    }
예제 #2
0
    public Knn_Results Knn_Execute()
    {
        UnityEngine.Debug.LogError("knn진입");
        double        E_HEAD    = ErrorTimes[Convert.ToInt32(AnimationParts.Head)];
        double        E_LH      = ErrorTimes[Convert.ToInt32(AnimationParts.LH)];
        double        E_RH      = ErrorTimes[Convert.ToInt32(AnimationParts.RH)];
        double        E_LF      = ErrorTimes[Convert.ToInt32(AnimationParts.LF)];
        double        E_RF      = ErrorTimes[Convert.ToInt32(AnimationParts.RF)];
        List <double> sort_list = new List <double>();

        sort_list.Add(E_HEAD);
        sort_list.Add(E_LH);
        sort_list.Add(E_RH);
        sort_list.Add(E_LF);
        sort_list.Add(E_RF);
        sort_list.Sort();
        //KNN 알고리즘 - 파이썬
        string num1      = this.totalTime.ToString();                             //전체 실행시간
        string num2      = ((E_HEAD + E_LH + E_RH + E_LF + E_RF) / 5).ToString(); //오류시간 평균
        string num3      = ((sort_list[0] + sort_list[4]) / 2).ToString();        //오류시간 중앙값
        string file_name = PoseName + ".txt";
        string Path      = "Knn_code\\" + file_name;
        var    psi       = new ProcessStartInfo();

        UnityEngine.Debug.Log("file_name=" + file_name);
        UnityEngine.Debug.Log("num1=" + num1);
        UnityEngine.Debug.Log("num2=" + num2);
        UnityEngine.Debug.Log("num3=" + num3);
        psi.FileName = @"python.exe";
        //파이썬 코드 경로
        psi.Arguments              = "Knn_code\\knn.py ";
        psi.Arguments             += Path + " " + num1 + " " + num2 + " " + num3;
        psi.UseShellExecute        = false;
        psi.CreateNoWindow         = true;
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardError  = true;

        var errors  = "";
        var results = "";

        using (var process = Process.Start(psi))
        {
            errors  = process.StandardError.ReadToEnd();
            results = process.StandardOutput.ReadToEnd();
        }
        results = results.Replace("Very well", "완벽함").Replace("Well", "잘함").Replace("Normal", "보통").Replace("Bad", "못함").Replace("Very bad", "망함");
        //
        string minErrorTimeName = GetMinErrortime(E_HEAD, E_LH, E_RH, E_LF, E_RF, sort_list[0]);
        string maxErrorTimeName = GetMaxErrortime(E_HEAD, E_LH, E_RH, E_LF, E_RF, sort_list[4]);
        //
        Knn_Results result = new Knn_Results(PoseName, results, this.totalTime, sort_list[0], minErrorTimeName, sort_list[4], maxErrorTimeName);


        return(result);
    }
예제 #3
0
 public void AddKnnResults(Knn_Results knn_result)
 {
     Debug.LogError("all에 result 추가");
     this.all_knn_results.Add_Result(knn_result);
 }
예제 #4
0
 public void Add_Result(Knn_Results result)
 {
     this.knn_result_list.Add(result);
     this.Avg_Calculate();
 }