コード例 #1
0
    public void showRandHand()
    {
        AngleBasedHandModel result = createRandom();

        output.visualizeHand(result);
        Debug.Log("Comfort+Discomfort: " + (Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result)));
    }
コード例 #2
0
 void saveData()
 {
     UserStudyData.instance.targetHand = targethand;
     UserStudyData.instance.angleDis   = Comfort.getRRPComponent(targethand);
     UserStudyData.instance.hyperDis   = Discomfort.getHyperExtensionComponent(targethand);
     UserStudyData.instance.yaxisDis   = Discomfort.getAbductionComponent(targethand);
     UserStudyData.instance.interDis   = Discomfort.getInterFingerComponent(targethand);
     UserStudyData.instance.discomfort = Discomfort.getDiscomfortAngled(targethand);
     UserStudyData.instance.palmangle  = targethand.getAvgMCPAngle() * 0;
     Debug.Log(targethand.getAvgMCPAngle() * 0);
 }
コード例 #3
0
    public AngleBasedHandModel createRandom(float disc_min, float disc_max)
    {
        AngleBasedHandModel result;

        do
        {
            result = createRandom();
        }while (Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result) < disc_min || Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result) > disc_max);
        Debug.Log("Discomfort: " + Discomfort.getDiscomfortAngled(result) + ", Comfort: " + Comfort.getRRPComponent(result));
        return(result);
    }
コード例 #4
0
    void saveResults()
    {
        File.AppendAllText(
            fileName,

            UserStudyData.instance.Name + endl +
            slider.value + endl +
            Discomfort.getDiscomfortAngled(targethand) + endl +
            Comfort.getRRPComponent(targethand) + endl +
            Discomfort.getInterFingerComponent(targethand) + endl +
            Discomfort.getAbductionComponent(targethand) + endl +
            Discomfort.getHyperExtensionComponent(targethand) + endl +
            Discomfort.getInterFingerCSV(targethand, endl) +
            Discomfort.getAbductionCSV(targethand, endl) +
            Discomfort.getHyperExtensionCSV(targethand, endl) +
            Comfort.getRRPCSV(targethand, endl) +
            targethand.ToCSVString(endl) + Environment.NewLine
            );
    }
コード例 #5
0
    void saveResults()
    {
        File.AppendAllText(
            fileNameEnd,

            UserStudyData.instance.Name + endl +
            UserStudyData.instance.ComfortEvaluation + endl +
            timer + endl +
            timerTracking + endl +
            Discomfort.getDiscomfortAngled(UserStudyData.instance.targetHand) + endl +
            Comfort.getRRPComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getInterFingerComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getAbductionComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getHyperExtensionComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getInterFingerCSV(UserStudyData.instance.targetHand, endl) +
            Discomfort.getAbductionCSV(UserStudyData.instance.targetHand, endl) +
            Discomfort.getHyperExtensionCSV(UserStudyData.instance.targetHand, endl) +
            Comfort.getRRPCSV(UserStudyData.instance.targetHand, endl) +
            UserStudyData.instance.targetHand.ToCSVString(endl) + Environment.NewLine
            );
    }
コード例 #6
0
    IEnumerator getNewRandomHand()
    {
        generating = true;
        int counter = 0;

        Debug.Log(targetdiscomfort);
        do
        {
            uncomfortable = randHand.createRandom();
            yield return(new WaitForEndOfFrame());

            counter++;
            if (counter > 200)
            {
                counter           = 0;
                targetdiscomfort -= 25;
                Debug.Log(targetdiscomfort);
            }
        }while (Discomfort.getDiscomfortAngled(uncomfortable) + Comfort.getRRPComponent(uncomfortable) < targetdiscomfort || Discomfort.getDiscomfortAngled(uncomfortable) + Comfort.getRRPComponent(uncomfortable) > targetdiscomfort + 100);
        generating = false;
    }
コード例 #7
0
    IEnumerator getNewRandomHand()
    {
        generating       = true;
        targetdiscomfort = UnityEngine.Random.Range(50, 1000);
        int counter = 0;

        Debug.Log(targetdiscomfort);
        do
        {
            targethand = randHand.createRandom();
            outputHand.visualizeHand(targethand);
            yield return(new WaitForEndOfFrame());

            counter++;
            if (counter > 200)
            {
                counter          = 0;
                targetdiscomfort = UnityEngine.Random.Range(50, 1000);
                Debug.Log(targetdiscomfort);
            }
        }while (Discomfort.getDiscomfortAngled(targethand) + Comfort.getRRPComponent(targethand) < targetdiscomfort || Discomfort.getDiscomfortAngled(targethand) + Comfort.getRRPComponent(targethand) > targetdiscomfort + 100);
        generating = false;
    }
コード例 #8
0
ファイル: Record.cs プロジェクト: mayerjRRR/HandPoseDetection
 // Update is called once per frame
 void Update()
 {
     text.text = "RRP-Component: " + Mathf.Max(0.0f, Comfort.getRRPComponent(hand.hand) - 20);
 }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        //TODO: this seems to not be correct; position values are funny
        hand.rotation = root.rotation;
        hand.position = root.position;

        sQuaternion temp = Quaternion.Inverse(root.rotation) * thumb1.rotation;

        if (rightHanded)
        {
            temp.mirrorX();
        }
        hand.thumb.tmc = temp;
        hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.TMC_X] = ((Quaternion)temp).eulerAngles.x;
        hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.TMC_Y] = ((Quaternion)temp).eulerAngles.y;
        hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.TMC_Z] = ((Quaternion)temp).eulerAngles.z;
        hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.MP]    = Vector3.Angle(thumb1.forward, thumb2.forward);
        hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.IP]    = Vector3.Angle(thumb3.forward, thumb2.forward);

        temp = Quaternion.Inverse(root.rotation) * index1.rotation;
        if (rightHanded)
        {
            temp.mirrorX();
        }
        hand.fingers [(int)AngleBasedHandModel.FingerName.index].mcp = temp;
        hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y;
        hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP]   = ((Quaternion)temp).eulerAngles.x;
        hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP]      = Vector3.Angle(index1.forward, index2.forward);
        hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP]      = Vector3.Angle(index2.forward, index3.forward);

        temp = Quaternion.Inverse(root.rotation) * middle1.rotation;
        if (rightHanded)
        {
            temp.mirrorX();
        }
        hand.fingers [(int)AngleBasedHandModel.FingerName.middle].mcp = temp;
        hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y;
        hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP]   = ((Quaternion)temp).eulerAngles.x;
        hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP]      = Vector3.Angle(middle1.forward, middle2.forward);
        hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP]      = Vector3.Angle(middle2.forward, middle3.forward);

        temp = Quaternion.Inverse(root.rotation) * ring1.rotation;
        if (rightHanded)
        {
            temp.mirrorX();
        }
        hand.fingers [(int)AngleBasedHandModel.FingerName.ring].mcp = temp;
        hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y;
        hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP]   = ((Quaternion)temp).eulerAngles.x;
        hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP]      = Vector3.Angle(ring1.forward, ring2.forward);
        hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP]      = Vector3.Angle(ring2.forward, ring3.forward);

        temp = Quaternion.Inverse(root.rotation) * pinky1.rotation;
        if (rightHanded)
        {
            temp.mirrorX();
        }
        hand.fingers [(int)AngleBasedHandModel.FingerName.pinky].mcp = temp;
        hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y;
        hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP]   = ((Quaternion)temp).eulerAngles.x;
        hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP]      = Vector3.Angle(pinky1.forward, pinky2.forward);
        hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP]      = Vector3.Angle(pinky2.forward, pinky3.forward);

        if (isDetecting)
        {
            if (Input.GetKeyDown("k"))
            {
                saveCurrentAs(trainingPosture);
            }
            else if (Input.GetKeyDown("s"))
            {
                PostureDataHandler.instance.saveData();
            }
            else
            {
                currentPosture = knn.detectPosture(hand);
                if (poseText)
                {
                    poseText.text = "Posture: " + currentPosture + "; Discomfort: " + getDiscomfort() + "; Comfort: " + Comfort.getRRPComponent(hand);
                }
            }
        }
    }