0

Kinectを使用してcurserを1つにまとめて動作させることができるようにしたいと思います。kinect SDKをユニティへのプラグインとして使用し、openniを使用しないことでこれを行うことが不可欠です。iveはそれを半分機能させることができましたが、実際には完璧ではありませんでした。現時点では、iveはx軸に沿って機能していますが、画面全体をカバーしていません。画面の中央からカーソルを開始し、それに応じて移動するのがより理想的です。画面の右側に向かってさらに移動すると、半分しか移動しません。浮動小数点数をハードコーディングするのではなく、画面に従って計算します。団結して世界にスケールできる機能がありました

void Update () {


    if (sw.pollSkeleton())
    {
        distance.x=sw.bonePos[0,2].x - sw.bonePos[0,7].x;//bonpos 0,2 is the spine 0,7 is the left hand

        //spine position will usually be around (0.1,1.2,0.3)
        /*
        Debug.Log("the distance is"+distance.x);

        */
        /*
         * (-0.2,1.4,0.7) hand over head on left side// essentially by this trime
         * (-0.3,1.0,0.6) hand near shoulders resonably high (-0.4,1.0,0.7) shoulders meaning anything 1.0 region
         * (-0.2,0.6,0.7) hand lower torso level curser should then be alive
         * (-)
         * (-0.1,0.7,0.3)hand at the side shouldnt record curser (-0.1,0.5,0.3) 0.0 -0.1
         * 
         */

        /*
         * (0.3,1.3,0.8)left hand over head on right side
         * (0.2,1.0,0.8) hand higher up on the other side right shoulder (0.4,1.0,0.7) further right
         * (0.3,0.9,0.7) hand lower then shoullder but pointing towards the right
         * (0.3,0.7,0.6) hand lower right below waist
         * (0.2,0.7,0.5) hand close to groin and spine
         */



        //if the left hands x axis is less than that of the spine
        //
        if(sw.bonePos[0,7].x<sw.bonePos[0,2].x)
        {
            //distance being 0.2053766 * -0.5f
             difference = -0.5f*distance.x;
            //difference being -0.1026883
            Debug.Log("hand is over by the left");

        }
        if(sw.bonePos[0,7].x>=sw.bonePos[0,2].x)
        {
             difference = -0.8f*distance.x;
            Debug.Log("hand is over by the right");

        }

        Debug.Log("Dist: " + distance.x + ", Diff: " + difference);


        Debug.Log("The spine is positioned at :" +sw.bonePos[0,2]+"The left hand is at :" +sw.bonePos[0,7]+" the position of the cursor"+transform.position);
    }


}

void OnGUI() {
    //left top width height
    Rect r = new Rect(Screen.width * (difference + 0.3f),0.5f*Screen.height,100,100);
    /*screen.width 480 * 0.1973117,0.5f*1280,100,100
     * 
     * 
     */
    GUI.Label(r,cursor);
    //GUI.DrawTexture();
}
}
4

2 に答える 2

0

私はUnityを扱ったことがないので、残念ながらUnityのコードに直接話すことはできませんが、KinectSDKのコードを以前に投稿しました。この質問への回答に、画面を表すバウンディングボックスをプレーヤーの周囲に作成するソースコードを含めました。

骨格関節を使用して境界を使用してカーソルとして機能する方法(ジェスチャなし)

上記の投稿のコードは、プレーヤーの体の周りの次のポイントで囲まれたボックスを作成します。

  • 肩=画面の上部
  • ヒップ=画面の下部
  • 左肩=画面の一番左

画面の右端の位置を取得するには、左肩と右肩の間の距離を取り、それを右肩の位置に追加します。

これにより、プレーヤーが画面上でカーソルを移動できる快適な領域が提供されます。また、さまざまなサイズのさまざまなプレーヤーに簡単にスケーリングでき、プレーヤーがKinectのFOV内のどこに立っていても機能します。

コンセプトはUnityコードに適応できる必要があります。

于 2013-03-21T15:34:35.410 に答える
0

誰かがこの問題に遭遇した場合に備えて、私はこのサイトで見つけたその人が遊ぶことができる回避策を見つけました 値の範囲を別の値にマッピングする

float translate(float value, float leftMin, float leftMax, float rightMin,float rightMax)
{
    float leftSpan = leftMax - leftMin;
    float rightSpan= rightMax - rightMin;

    float valueScaled = (float)(value-leftMin)/(float)(leftSpan);
    return rightMin+(valueScaled * rightSpan);
}

私の更新方法では、これを行います

differnetx=translate(distance.x,.6f,0,0,1);
differencey=translate(distance.y,.5f,0,0,1);

これにより、手の最も遠い部分から脊椎までの長方形が作成され、画面にマッピングされます。手が体を横切るときにkinectが混乱することがあるので、代わりに脊椎を横切ることから離れてすべてのナビゲーションを行う方がよいと思いました

于 2013-03-27T22:08:54.270 に答える