• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Windows.Kinect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Windows.Kinect的典型用法代码示例。如果您正苦于以下问题:C# Windows.Kinect类的具体用法?C# Windows.Kinect怎么用?C# Windows.Kinect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Windows.Kinect类属于命名空间,在下文中一共展示了Windows.Kinect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RotateAvatarJoints

 private void RotateAvatarJoints(Kinect.Body body, GameObject bodyObject)
 {
     RotateBone (bodyObject, Kinect.JointType.ShoulderRight, Kinect.JointType.ElbowRight);
     RotateBone (bodyObject, Kinect.JointType.ShoulderLeft, Kinect.JointType.ElbowLeft);
     RotateBone (bodyObject, Kinect.JointType.ElbowRight, Kinect.JointType.WristRight);
     RotateBone (bodyObject, Kinect.JointType.ElbowLeft, Kinect.JointType.WristLeft);
 }
开发者ID:sharifshahnewaz,项目名称:Balance-Game-Reference,代码行数:7,代码来源:BodySourceView.cs


示例2: RefreshBodyObject

    private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject)
    {
        filter.UpdateFilter (ref body);
        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.HandRight; jt++) {
            //Kinect.Joint sourceJoint = body.Joints [jt];
            GameObject avatarSpineBase = GameObject.FindGameObjectsWithTag (Kinect.JointType.SpineBase.ToString ()) [0];
            Transform jointObj = bodyObject.transform.FindChild (jt.ToString ());
            Kinect.CameraSpacePoint jointPosition = filter.FilteredJoints [jt].Position;
            jointPosition.Z = -jointPosition.Z;

            //jointDataRecorder.Append (string.Format ("{0},{1},{2},{3}", System.DateTime.Now, jointPosition.X, jointPosition.Y, jointPosition.Z));

            if (jt == Kinect.JointType.SpineBase) {
                transformDistance = new Vector3 (jointPosition.X - avatarSpineBase.transform.position.x,
                                                 jointPosition.Y - avatarSpineBase.transform.position.y,
                                                 jointPosition.Z - avatarSpineBase.transform.position.z);

            }

            jointObj.position = new Vector3 ((jointPosition.X - transformDistance.x),
                                             (jointPosition.Y - transformDistance.y),
                                             (jointPosition.Z - transformDistance.z));
            if (jt <= Kinect.JointType.ShoulderLeft || jt == Kinect.JointType.ShoulderRight) {
                GameObject avatarJoint = GameObject.FindGameObjectsWithTag (jt.ToString ()) [0];
                avatarJoint.transform.position = jointObj.transform.position;
            }

        }
        //jointDataRecorder.Append ("\n");
    }
开发者ID:sharifshahnewaz,项目名称:Balance-Game-Reference,代码行数:30,代码来源:BodySourceView.cs


示例3: GetVector3FromJoint

 private static Vector3 GetVector3FromJoint(Kinect.Joint joint)
 {
     int scaleFactor = 1000;
     int zScaleFactor = -scaleFactor;
     int zShiftFactor = 1100;
     return new Vector3(joint.Position.X * scaleFactor,
                        joint.Position.Y * scaleFactor,
                        joint.Position.Z * zScaleFactor + zShiftFactor);
 }
开发者ID:sandybisaria,项目名称:Jarvis,代码行数:9,代码来源:BodyManagerSpawner.cs


示例4: RefreshBodyObject

 private void RefreshBodyObject(Kinect.Body body)
 {
     for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) {
         Kinect.Joint sourceJoint = body.Joints[jt];
         Transform jointObj = bodyView.transform.FindChild(jt.ToString());
         if (jointObj == null) continue;
         jointObj.localPosition = GetVector3FromJoint(sourceJoint);
     }
 }
开发者ID:pecheny,项目名称:KinectVRExample,代码行数:9,代码来源:PassBonePositions.cs


示例5: RotateBone

    private void RotateBone(GameObject bodyObject, Kinect.JointType startBone, Kinect.JointType endBone)
    {
        GameObject avatarJoint = GameObject.FindGameObjectsWithTag (startBone.ToString ()) [0];
        Transform jointObj = bodyObject.transform.FindChild (startBone.ToString ());
        Transform targetJointObj = bodyObject.transform.FindChild (endBone.ToString ());

        Quaternion avatarRotaion = Quaternion.LookRotation ((targetJointObj.transform.position - jointObj.transform.position).normalized);
        avatarJoint.transform.rotation = Quaternion.Slerp (avatarJoint.transform.rotation, avatarRotaion, Time.deltaTime * 2000);
        avatarJoint.transform.Rotate (new Vector3 (90, 0, 0));
    }
开发者ID:sharifshahnewaz,项目名称:Balance-Game-Reference,代码行数:10,代码来源:BodySourceView.cs


示例6: IsInRange

    private bool IsInRange(WindowsKinect.Body skeleton)
    {
        const float ftToMeter = 0.3048f;
        const float minDistance = 4.5f * ftToMeter;
        const float maxDistance = 6.5f * ftToMeter;

        Vector3 spineBasePosition = skeleton.GetPosition(WindowsKinect.JointType.SpineBase);
        return spineBasePosition.z >= minDistance &&
            spineBasePosition.z <= maxDistance &&
            Mathf.Abs(spineBasePosition.x) < 1.5f;
    }
开发者ID:mmnaviwala,项目名称:cosc-4372-6370-kinect-medical-imaging,代码行数:11,代码来源:KinectController.cs


示例7: createJoint

    public Vector3 createJoint(MySkeleton skel, int firstJoint, int secondJoint, Kinect.JointType jointToMove, int index)
    {
        float Xtrans = translateX(skel, firstJoint, secondJoint, index);
        float Ytrans = translateY(skel, firstJoint, secondJoint, index);
        float Ztrans = translateZ(skel, firstJoint, secondJoint, index);
        //		Debug.Log ("x transition: " + Xtrans+" ytansitiion: "+ Ytrans+" z transition: "+Ztrans);

        Vector3 Position = new Vector3 ((float)(skel.Position[(int)jointToMove].x - Xtrans), (float)(skel.Position[(int)jointToMove].y - Ytrans),
                                        (float)(skel.Position[(int)jointToMove].z - Ztrans));
        return Position;
    }
开发者ID:puzpuz,项目名称:LocomotionTest,代码行数:11,代码来源:SkeletonResizer.cs


示例8: GetColorForState

    private static Color GetColorForState(Kinect.TrackingState state)
    {
        switch (state) {
        case Kinect.TrackingState.Tracked:
            return Color.green;

        case Kinect.TrackingState.Inferred:
            return Color.red;

        default:
            return Color.black;
        }
    }
开发者ID:sandybisaria,项目名称:Jarvis,代码行数:13,代码来源:BodyManagerSpawner.cs


示例9: GetColorForState

    private static Color GetColorForState(Kinect.TrackingState state)
    {
        //switch (state)
        //{
        //case Kinect.TrackingState.Tracked:
        //    return Color.green;

        //case Kinect.TrackingState.Inferred:
            return Color.red;

        //default:
        //    return Color.black;
        //}
    }
开发者ID:kevinzhang96,项目名称:kinect-hand-bpm,代码行数:14,代码来源:BodySourceView.cs


示例10: addBone

 private GameObject addBone(string name, float radius, GameObject prefab, Transform body, Kinect.JointType joint1, Kinect.JointType? joint2 = null)
 {
     GameObject bone = (GameObject) Instantiate(prefab, Vector3.zero, Quaternion.identity);
     bone.name = name; bone.transform.parent = body;
     BoneScript script = bone.GetComponent("BoneScript") as BoneScript;
     script.radius = radius;
     script.joint1 = body.FindChild (joint1.ToString ()).gameObject;
     if (joint2 != null)
         script.joint2 = body.FindChild (((Kinect.JointType) joint2).ToString ()).gameObject;
     else if (_BoneMap.ContainsKey (joint1))
         script.joint2 = body.FindChild (_BoneMap [joint1].ToString ()).gameObject;
     else
         Debug.LogError ("BAD JOINT: " + joint1);
     return bone;
 }
开发者ID:rgerd,项目名称:TunnelVision,代码行数:15,代码来源:SkeletonRender.cs


示例11: RefreshBodyObject

    private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject)
    {
        // kinect is active
        kinectActive = true;

        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
        {
            Kinect.Joint sourceJoint = body.Joints[jt];
            Kinect.Joint? targetJoint = null;

            if (_BoneMap.ContainsKey(jt))
            {
                targetJoint = body.Joints[_BoneMap[jt]];
            }

            Transform jointObj = bodyObject.transform.FindChild(jt.ToString());
            jointObj.localPosition = GetVector3FromJoint(sourceJoint);
        }
    }
开发者ID:jessefulton,项目名称:INSTINT_WIN,代码行数:19,代码来源:BodySourceView.cs


示例12: GetVector3FromJoint

 public static Vector3 GetVector3FromJoint(Kinect.Joint joint)
 {
     // variations added by GesTherapy to contract/lift skeleton on unity screen
     if (Application.loadedLevelName == "Calibration" || Application.loadedLevelName == "Visualizer")
     {
         return new Vector3(joint.Position.X * 5.5f, (joint.Position.Y * 5.5f) + 1.5f, joint.Position.Z * 5.5f);
     }
     else
     {
         // if upper half of body
         if ( (joint.JointType >= Kinect.JointType.SpineMid && joint.JointType <= Kinect.JointType.HandRight)
             || (joint.JointType >= Kinect.JointType.SpineShoulder && joint.JointType <= Kinect.JointType.ThumbRight) )
             return new Vector3(joint.Position.X * 5.5f, (joint.Position.Y * 5.5f) + 1.5f + Calibration.upperShift, joint.Position.Z * 5.5f);
         // else if lower half of body
         else if ( (joint.JointType >= Kinect.JointType.KneeLeft && joint.JointType <= Kinect.JointType.FootLeft)
                  || (joint.JointType >= Kinect.JointType.KneeRight && joint.JointType <= Kinect.JointType.FootRight) )
             return new Vector3(joint.Position.X * 5.5f, (joint.Position.Y * 5.5f) + 1.5f + Calibration.lowerShift, joint.Position.Z * 5.5f);
         // else hips or spine base
         else
             return new Vector3(joint.Position.X * 5.5f, (joint.Position.Y * 5.5f) + 1.5f, joint.Position.Z * 5.5f);
     }
 }
开发者ID:owaisnm,项目名称:GesBalance,代码行数:22,代码来源:BodySourceView.cs


示例13: RefreshBodyObject

    private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject)
    {
        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) {
            Kinect.Joint sourceJoint = body.Joints[jt];
            Kinect.Joint? targetJoint = null;

            if (_BoneMap.ContainsKey(jt)) {
                targetJoint = body.Joints[_BoneMap[jt]];
            }

            Transform jointObj = bodyObject.transform.FindChild(jt.ToString());
            jointObj.localPosition = GetVector3FromJoint(sourceJoint);

            LineRenderer lr = jointObj.GetComponent<LineRenderer>();
            if (targetJoint.HasValue) {
                lr.SetPosition(0, jointObj.localPosition);
                lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
                lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
            } else {
                lr.enabled = false;
            }
        }
    }
开发者ID:pecheny,项目名称:KinectVRExample,代码行数:23,代码来源:BodySourceView.cs


示例14: FindClosestBody

    /// <summary>
    /// Finds the closest body from the sensor if any
    /// </summary>
    /// <param name="bodyFrame">A body frame</param>
    /// <returns>Closest body, null of none</returns>
    private static Kinect.Body FindClosestBody(Kinect.Body[] bodies)
    {
        Kinect.Body result = null;
        double closestBodyDistance = double.MaxValue;

        foreach (var body in bodies)
        {
            if (body.IsTracked)
            {
                var currentLocation = body.Joints[Kinect.JointType.SpineBase].Position;

                var currentDistance = VectorLength(currentLocation);

                if (result == null || currentDistance < closestBodyDistance)
                {
                    result = body;
                    closestBodyDistance = currentDistance;
                }
            }
        }

        return result;
    }
开发者ID:ahsquared,项目名称:BigEyesInstallation,代码行数:28,代码来源:BodySourceView.cs


示例15: RefreshBodyObject

    private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject)
    {
        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
        {
            Kinect.Joint sourceJoint = body.Joints[jt];
            Kinect.Joint? targetJoint = null;

            if (_BoneMap.ContainsKey(jt))
            {
                targetJoint = body.Joints[_BoneMap[jt]];
            }

            Transform jointObj = bodyObject.transform.FindChild(jt.ToString());
            jointObj.localPosition = GetVector3FromJoint(sourceJoint);

            // reference left hand position
            if (jt == joint)
            {
                hand = jointObj.position;
                handState = body.HandLeftState;
            }
        }
    }
开发者ID:jessefulton,项目名称:INSTINT_WIN,代码行数:23,代码来源:BodySourceView.cs


示例16: GetRemoveBackground

 void GetRemoveBackground(KinectOneLabelMap labelmap, KinectOneImage image, Kinect.ColorSpacePoint[] colorSpaces)
 {
     byte[] data = labelmap.GetData();
     Color32[] _image = image.GetColorTexture().GetPixels32();
     int imageWidth = image.Sensor.ColorFrameSource.FrameDescription.Width;
     for (int i = 0; i < outputPixels.Length; i++)
     {
         byte indexValue = data[i];
         if (IsValidFloatValue(colorSpaces[i].X) || IsValidFloatValue(colorSpaces[i].Y) || indexValue == 255)
         {
             outputPixels[i] = new Color32(0, 0, 0, 0);
         }
         else
         {
             float x=colorSpaces[i].X, y=colorSpaces[i].Y;
             int colorIndex = (int)y * imageWidth + (int)x;
             outputPixels[i] = (indexValue > 0) ? ((indexValue <= labelToColor.Length) ? labelToColor[indexValue - 1] : defaultColor) : bgColor;
             if (indexValue == m_engageuser.engagedTrackedUser.Id && colorIndex < _image.Length && colorIndex > 0)
             {
                 outputPixels[i] = _image[colorIndex];
             }
         }
     }
 }
开发者ID:josephMG,项目名称:KinectOneForZigFu,代码行数:24,代码来源:KinectOneViewer.cs


示例17: GetKinect2JointData

	// TODO: Add method that return joints by ID, assign proper jointID in the first line: ... = new JointData(Joint.None);
	public JointData GetKinect2JointData(Kinect.Joint jointPosition, Kinect.JointOrientation jointRotation) 
	{
		JointData jointData = new JointData(Joint.None); // Temporary variable used to pass values, jointID can be none
		jointData.rotation = new Quaternion(jointRotation.Orientation.X,jointRotation.Orientation.Y,jointRotation.Orientation.Z,jointRotation.Orientation.W);
		jointData.position = new Vector3(jointPosition.Position.X, jointPosition.Position.Y, jointPosition.Position.Z);

		if(jointPosition.TrackingState == Kinect.TrackingState.Tracked)  {
			jointData.positionConfidence = 1.0f;
			jointData.rotationConfidence = 1.0f;
		}
		else if(jointPosition.TrackingState == Kinect.TrackingState.Inferred)  {
			jointData.positionConfidence = 0.5f;
			jointData.rotationConfidence = 0.5f;
		}
		else if(jointPosition.TrackingState == Kinect.TrackingState.NotTracked)  {
			jointData.positionConfidence = 0.0f;
			jointData.rotationConfidence = 0.0f;
		}
		else {
			jointData.positionConfidence = 0.0f;
			jointData.rotationConfidence = 0.0f;
		}
		jointData.TrackingState = jointPosition.TrackingState;

		return jointData;
	}
开发者ID:avax94,项目名称:RUISHarryPotter,代码行数:27,代码来源:RUISSkeletonManager.cs


示例18: RefreshBodyObject

    private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject)
    {
        string[] save = new string[25];
        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) {
            Kinect.Joint sourceJoint = body.Joints[jt];
            Transform jointObj = bodyObject.transform.FindChild(jt.ToString());
            jointObj.localPosition = GetVector3FromJoint(sourceJoint);
            if (jt == Kinect.JointType.Head)
            {
                Camera.main.transform.localRotation = Quaternion.identity;
                Camera.main.transform.Rotate(new Vector3(0, 180, 0));
                Camera.main.transform.position = (Vector3)jointObj.transform.position;
            }

            float xval = (int) ((jointObj.position.x)* 10000)/10000f;
            float yval = (int) ((jointObj.position.y) * 10000)/10000f;
            float zval = (int) ((jointObj.position.z) * 10000)/10000f;
            save[(int) jt] += xval.ToString() + " " + yval.ToString() + " " + zval.ToString() + " ";
        }
        message = save [3] + save [20] + save [8] + save [4]  + save [9] + save [5] +
            save [0] + save [10] + save [6] + save [16] + save [12] + save [17] + save [13] +
                save [18] + save [14] + body.HandLeftState.ToString () + " " + body.HandRightState.ToString ();
    }
开发者ID:rgerd,项目名称:TunnelVision,代码行数:23,代码来源:SkeletonRender.cs


示例19: Skeleton

    public Skeleton(Kinect.Body body)
    {
        _start();
        Message = ""
            + BodyPropertiesTypes.UID.ToString() + MessageSeparators.SET + body.TrackingId
            + MessageSeparators.L2 + BodyPropertiesTypes.Confidence.ToString() + MessageSeparators.SET + BodyConfidence(body)
            + MessageSeparators.L2 + BodyPropertiesTypes.HandLeftState.ToString() + MessageSeparators.SET + body.HandLeftState
            + MessageSeparators.L2 + BodyPropertiesTypes.HandLeftConfidence.ToString() + MessageSeparators.SET + body.HandLeftConfidence
            + MessageSeparators.L2 + BodyPropertiesTypes.HandRightState.ToString() + MessageSeparators.SET + body.HandRightState
            + MessageSeparators.L2 + BodyPropertiesTypes.HandRightConfidence.ToString() + MessageSeparators.SET + body.HandRightConfidence;

        foreach (Kinect.JointType j in Enum.GetValues(typeof(Kinect.JointType)))
        {
            Message += "" + MessageSeparators.L2 + j.ToString() + MessageSeparators.SET + CommonUtils.convertVectorToStringRPC(body.Joints[j].Position);
        }
    }
开发者ID:mauriciosousa,项目名称:creepytracker,代码行数:16,代码来源:BodiesMessage.cs


示例20: updatePalm

 private void updatePalm(Transform jointTransform, Transform thumbTransform, Kinect.HandState handState)
 {
     jointTransform.LookAt(thumbTransform);
     GameObject jointObj = jointTransform.gameObject;
     HandPalmAttribute hpa = jointObj.GetComponent<HandPalmAttribute>();
     hpa.UpdateState(handState);
     jointObj.GetComponent<Renderer>().material.color = hpa.GetStateColor();
 }
开发者ID:sandybisaria,项目名称:Jarvis,代码行数:8,代码来源:BodyManagerSpawner.cs



注:本文中的Windows.Kinect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Popups.MessageDialog类代码示例发布时间:2022-05-24
下一篇:
C# Resources.ResourceLoader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap