当前位置: 首页>>代码示例>>C#>>正文


C# Kinect.Joint类代码示例

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


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

示例1: actualizarPostura

 public void actualizarPostura(Skeleton esqueleto)
 {
     manoDerAct = esqueleto.Joints[JointType.WristRight];
     manoIzqAct = esqueleto.Joints[JointType.WristLeft];
     codoDerAct = esqueleto.Joints[JointType.ElbowRight];
     codoIzqAct = esqueleto.Joints[JointType.ElbowLeft];
 }
开发者ID:Gaedr,项目名称:practica1,代码行数:7,代码来源:moves.cs

示例2: DrawLineBetween

        /// <summary>
        /// Draw a line between two joints in a canvas
        /// </summary>
        /// <param name="canvas">the canvas</param>
        /// <param name="jstart">the joint where to start the line</param>
        /// <param name="jend">the joint where to end the line</param>
        /// <param name="vskeleton">the visual skeleton</param>
        private static void DrawLineBetween(Canvas canvas, Joint jstart, Joint jend, VisualSkeleton vskeleton)
        {
            if (vskeleton.positionMap.ContainsKey(jstart) && vskeleton.positionMap.ContainsKey(jend))
            {
                Line l = new Line();

                l.X1 = vskeleton.positionMap[jstart].X;
                l.Y1 = vskeleton.positionMap[jstart].Y;
                l.X2 = vskeleton.positionMap[jend].X;
                l.Y2 = vskeleton.positionMap[jend].Y;

                if (jstart.TrackingState == JointTrackingState.Inferred &&
                    jend.TrackingState == JointTrackingState.Inferred)
                {
                    l.Stroke = Brushes.Yellow;
                    l.StrokeThickness = 3;
                }
                else if (jstart.TrackingState == JointTrackingState.Tracked &&
                    jend.TrackingState == JointTrackingState.Tracked)
                {
                    l.Stroke = Brushes.Green;
                    l.StrokeThickness = 3;
                }
                else if (jstart.TrackingState == JointTrackingState.NotTracked ||
                    jend.TrackingState == JointTrackingState.NotTracked)
                {
                    l.Stroke = Brushes.Transparent;
                    l.StrokeThickness = 0;
                }

                canvas.Children.Add(l);
            }
        }
开发者ID:HaKDMoDz,项目名称:kinectQlikView,代码行数:40,代码来源:VisualSkeleton.cs

示例3: JointTrackingStateIsSerialised

        public void JointTrackingStateIsSerialised()
        {
            var j = new Joint {TrackingState = JointTrackingState.Tracked};

            var json = j.ToJson();
            Assert.IsTrue(json.Contains("Tracked"));
        }
开发者ID:merbla,项目名称:KinectUs,代码行数:7,代码来源:KinectEnumConvertFixture.cs

示例4: DrawBone

        private void DrawBone(Joint jointFrom, Joint jointTo, Pen aPen, DrawingContext aContext)
        {
            if (jointFrom.TrackingState == JointTrackingState.NotTracked ||
            jointTo.TrackingState == JointTrackingState.NotTracked)
            {
                return;
            }

            if (jointFrom.TrackingState == JointTrackingState.Inferred ||
            jointTo.TrackingState == JointTrackingState.Inferred)
            {
                ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30);
                ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30);
                //Thin line
                aPen.DashStyle = DashStyles.Dash;
                aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y));

            }
            if (jointFrom.TrackingState == JointTrackingState.Tracked ||
            jointTo.TrackingState == JointTrackingState.Tracked)
            {
                ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30);
                ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30);
                //Thick line
                aPen.DashStyle = DashStyles.Solid;
                aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y));
            }
        }
开发者ID:kinectNao,项目名称:bluenao,代码行数:28,代码来源:MainWindow.xaml.cs

示例5: DrawJointLine

        /// <summary>
        /// ジョイント間の線を引く
        /// </summary>
        /// <param name="skeleton"></param>
        /// <param name="joint"></param>
        /// <returns></returns>
        private void DrawJointLine( Skeleton skeleton, Joint joint )
        {
            // ジョイントと関連づいている一方のジョイントを取得する
            var start = skeleton.BoneOrientations[joint.JointType].StartJoint;
            var end = skeleton.BoneOrientations[joint.JointType].EndJoint;
            var startJoint = skeleton.Joints[start];
            var endJoint = skeleton.Joints[end];

            // どちらかが追跡状態でない場合には描画しない
            if ( (startJoint.TrackingState == JointTrackingState.NotTracked) || 
                 (endJoint.TrackingState == JointTrackingState.NotTracked) ) {
                return;
            }

            // 3次元座標を距離カメラの2次元座標に変換する
            var startPoint = SkeletonToPiont( skeleton.Joints[start].Position );
            var endPoint = SkeletonToPiont( skeleton.Joints[end].Position );
            if ( !IsDrawablePoint( startPoint ) || !IsDrawablePoint( endPoint ) ) {
                return;
            }


            // ジョイント間の線を引く
            canvas.Children.Add( new Line()
            {
                X1 = startPoint.X,
                Y1 = startPoint.Y,
                X2 = endPoint.X,
                Y2 = endPoint.Y,
                Stroke = new SolidColorBrush( Colors.Red ),
            } );
        }
开发者ID:NaturalSoftwareJP,项目名称:NaturalSoftware.Kinect.CSharp,代码行数:38,代码来源:KinectSkeletonDrawer.cs

示例6: GetJointDistance

 /// <summary>
 /// Gets the joint distance.
 /// </summary>
 /// <param name="firstJoint">The first joint.</param>
 /// <param name="secondJoint">The second joint.</param>
 /// <returns>retunr the distance</returns>
 public static float GetJointDistance(Joint firstJoint, Joint secondJoint)
 {
     float distanceX = firstJoint.Position.X - secondJoint.Position.X;
     float distanceY = firstJoint.Position.Y - secondJoint.Position.Y;
     float distanceZ = firstJoint.Position.Z - secondJoint.Position.Z;
     return (float)Math.Sqrt(Math.Pow(distanceX, 2) + Math.Pow(distanceY, 2) + Math.Pow(distanceZ, 2));
 }
开发者ID:h3nj3,项目名称:Kinect-Gesture-Recognizer,代码行数:13,代码来源:GestureHelper.cs

示例7: SetPosition

        public void SetPosition(Joint joint)
        {
            if (!menuOpened)
            {
                if (Global.initPos)
                {

                    //in Global check if z moving forward by some amount then increase 0.3 and 0.4 so hand moves less
                    Joint scaledJoint = joint.ScaleTo((int)Global.windowWidth, (int)Global.windowHeight, (float)0.25, (float)0.25);
                    cursorX = cursorX + 519;
                    cursorX = (double)Math.Max(0, Math.Min(scaledJoint.Position.X, Global.windowWidth - hand.Width));
                    cursorY = (double)Math.Max(0, Math.Min(scaledJoint.Position.Y, Global.windowHeight - hand.Height));
                    Canvas.SetLeft(this, cursorX);
                    Canvas.SetTop(this, cursorY);
                }
                else
                {

                    Canvas.SetLeft(this, Global.windowWidth - hand.Width);
                    Canvas.SetTop(this, Global.windowHeight - hand.Height);
                }
            }
            else
            {
                radialMenu.setCursorPosition(this, joint);
                Canvas.SetLeft(this, cursorX);
                Canvas.SetTop(this, cursorY);
            }
        }
开发者ID:kennydo,项目名称:Choreoh,代码行数:29,代码来源:HandCursor.xaml.cs

示例8: CalculateAngle2D

        double CalculateAngle2D(Joint shoulder, Joint hip, Joint knee)
        {
            double angle = 0;
            double value = CalcDiff();
            value = 0.3 * value;
            double shrhY = shoulder.Position.Y - (hip.Position.Y-value);
            double shrhZ = shoulder.Position.Z - hip.Position.Z;
            double hsl = vectorNorm( shrhY, shrhZ);
            double unrhY = knee.Position.Y - (hip.Position.Y-value);
            double unrhZ = knee.Position.Z - hip.Position.Z;
            double hul = vectorNorm( unrhY, unrhZ);
            double mhshu = shrhY * unrhY + shrhZ * unrhZ;

            double x = mhshu / (hul * hsl);
            if (x != Double.NaN)
            {
                if (-1 <= x && x <= 1)
                {
                    double angleRad = Math.Acos(x);
                    angle = angleRad * (180.0 / 3.1416);
                }
                else
                    angle = 0;
            }
            else
                angle = 0;

            return angle;
        }
开发者ID:kvermun,项目名称:IEEEApp,代码行数:29,代码来源:MainWindow.xaml.cs

示例9: CalculateAngleYZ

        /// <summary>
        /// Calculates the angle between the provided joints in the YZ plane.
        /// </summary>
        /// <param name="joint1">The first joint.</param>
        /// <param name="joint2">The second joint.</param>
        /// <returns>The angle (in degrees) between the joints.</returns>
        public static double CalculateAngleYZ(Joint joint1, Joint joint2)
        {
            double deltaY = joint2.Position.Y - joint1.Position.Y;
            double deltaZ = joint2.Position.Z - joint1.Position.Z;

            return Units.RadiansToDegrees(Math.Atan2(deltaZ, deltaY));
        }
开发者ID:shanet,项目名称:Asimov,代码行数:13,代码来源:SkeletonHelper.cs

示例10: alignJoints

        public static Joint alignJoints(Joint aligningJoint, Joint startingJoint, Joint endingJoint)
        {
            Vector3 pointToBeTranslated = new Vector3(startingJoint.Position.X, startingJoint.Position.Y, startingJoint.Position.Z);
            Vector3 origin = new Vector3(aligningJoint.Position.X, aligningJoint.Position.Y, aligningJoint.Position.Z);

            Vector3 differentialVector = pointToBeTranslated - origin;

            //get the distance between the alingning joint and starting joint. We need to maintain this distance when we rotate the joint
            double distance = Math.Sqrt(startingJoint.Position.X * aligningJoint.Position.X + startingJoint.Position.Y * aligningJoint.Position.Y + startingJoint.Position.Z * aligningJoint.Position.Z);
            //get current vectors
            Vector3 startingVector = new Vector3(startingJoint.Position.X - aligningJoint.Position.X, startingJoint.Position.Y - aligningJoint.Position.Y, startingJoint.Position.Z - aligningJoint.Position.Z);
            Vector3 expectedVector = new Vector3(endingJoint.Position.X - aligningJoint.Position.X, endingJoint.Position.Y - aligningJoint.Position.Y, endingJoint.Position.Z - aligningJoint.Position.Z);

            // Normalize vectors so we can use Dot product correctly
            startingVector.Normalize();
            expectedVector.Normalize();
            float dotAngle = (float)Math.Acos(Vector3.Dot(startingVector, expectedVector));

            if (float.IsNaN(dotAngle))
            {
                dotAngle = 0;
            }

            Vector3 rotatedVect = Vector3.Transform(differentialVector, Matrix.CreateFromAxisAngle(startingVector, dotAngle));

            rotatedVect += origin;

            SkeletonPoint newSkeletonPoint = new SkeletonPoint();
            newSkeletonPoint.X = rotatedVect.X;
            newSkeletonPoint.Y = rotatedVect.Y;
            newSkeletonPoint.Z = rotatedVect.Z;
            startingJoint.Position = newSkeletonPoint;
            return startingJoint;
        }
开发者ID:slowbump,项目名称:KinectTherapyTest,代码行数:34,代码来源:JointAnalyzer.cs

示例11: SetPosition

        public void SetPosition(Joint joint)
        {
            Joint scaledJoint = joint.ScaleTo(1270 - 88, 750 - 38, 0.5f, 0.5f);

            Canvas.SetLeft(this, scaledJoint.Position.X);
            Canvas.SetTop(this, scaledJoint.Position.Y);
        }
开发者ID:papannetier,项目名称:Projet_Kinect_City_Map,代码行数:7,代码来源:HandCursor.xaml.cs

示例12: Distance

 /// <summary>
 /// Returns the length of the segment defined by the specified joints.
 /// </summary>
 /// <param name="p1">The first joint (start of the segment).</param>
 /// <param name="p2">The second joint (end of the segment).</param>
 /// <returns>The length of the segment in meters.</returns>
 public static double Distance(Joint p1, Joint p2)
 {
     return Math.Sqrt(
         Math.Pow(p1.Position.X - p2.Position.X, 2) +
         Math.Pow(p1.Position.Y - p2.Position.Y, 2) +
         Math.Pow(p1.Position.Z - p2.Position.Z, 2));
 }
开发者ID:nerndt,项目名称:iRobotKinect,代码行数:13,代码来源:SkeletonExtensions.cs

示例13: ConverterCoordenadasArticulacao

 private ColorImagePoint ConverterCoordenadasArticulacao(Joint articulacao, double larguraCanvas, double alturaCanvas)
 {
     ColorImagePoint posicaoArticulacao = Kinect.CoordinateMapper.MapSkeletonPointToColorPoint(articulacao.Position, Kinect.ColorStream.Format);
     posicaoArticulacao.X = (int)(posicaoArticulacao.X * larguraCanvas) / Kinect.ColorStream.FrameWidth;
     posicaoArticulacao.Y = (int)(posicaoArticulacao.Y * alturaCanvas) / Kinect.ColorStream.FrameHeight;
     return posicaoArticulacao;
 }
开发者ID:jorgeLuizChaves,项目名称:MSKinect,代码行数:7,代码来源:EsqueletoUsuarioAuxiliar.cs

示例14: findAngle

        double findAngle(Joint hombroIzquierdo, Joint hombroDerecho)
        {
            if (hombroDerecho.TrackingState == JointTrackingState.NotTracked && hombroIzquierdo.TrackingState == JointTrackingState.NotTracked)
            {
                return 0;
            }

            if (hombroDerecho.TrackingState == JointTrackingState.NotTracked ||
                hombroDerecho.TrackingState == JointTrackingState.Inferred)
            {
                return 90;
            }

            else if (hombroIzquierdo.TrackingState == JointTrackingState.NotTracked ||
                hombroIzquierdo.TrackingState == JointTrackingState.Inferred)
            {
                return -90;
            }
            else
            {
                return Math.Atan2(
                    hombroDerecho.Position.Z - hombroIzquierdo.Position.Z,
                    hombroDerecho.Position.X - hombroIzquierdo.Position.X) * 180.0 / Math.PI;
            }
        }
开发者ID:raerpo,项目名称:FocoDeAtencionVisual,代码行数:25,代码来源:MainWindow.xaml.cs

示例15: drawBone

        /// <summary>
        /// Draws the bone.
        /// </summary>
        /// <param name="trackedJoint1">The tracked joint1.</param>
        /// <param name="trackedJoint2">The tracked joint2.</param>
        /// 
        void drawBone(Joint trackedJoint1, Joint trackedJoint2)
        {
            Line bone = new Line();
            bone.Stroke = Brushes.Red;
            bone.StrokeThickness = 3;
            Point joint1 = this.ScalePosition(trackedJoint1.Position);
            bone.X1 = joint1.X;
            bone.Y1 = joint1.Y;

            Point mappedPoint1 = this.ScalePosition(trackedJoint1.Position);
            Rectangle r = new Rectangle(); r.Height = 10; r.Width = 10;
            r.Fill = Brushes.Red;
            Canvas.SetLeft(r, mappedPoint1.X - 2);
            Canvas.SetTop(r, mappedPoint1.Y - 2);
            this.caller.myCanvas.Children.Add(r);

            Point joint2 = this.ScalePosition(trackedJoint2.Position);
            bone.X2 = joint2.X;
            bone.Y2 = joint2.Y;

            Point mappedPoint2 = this.ScalePosition(trackedJoint2.Position);

            if (LeafJoint(trackedJoint2))
            {
                Rectangle r1 = new Rectangle(); r1.Height = 10; r1.Width = 10;
                r1.Fill = Brushes.Red;
                Canvas.SetLeft(r1, mappedPoint2.X - 2);
                Canvas.SetTop(r1, mappedPoint2.Y - 2);
                this.caller.myCanvas.Children.Add(r1);
                Point mappedPoint = this.ScalePosition(trackedJoint2.Position);

            }

            this.caller.myCanvas.Children.Add(bone);
        }
开发者ID:kandran,项目名称:musee-interactif,代码行数:41,代码来源:GestionSensorsSkeleton+-+Copier.cs


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