我有一个问题,“Evil Closet Monkey”回答了关于 Kinect 鼠标项目的问题,我将代码从 C# 转换为 VB.Net。代码如下:
Private Sub TrackHandMovement(skeleton As Skeleton)
Dim leftHand As Joint = skeleton.Joints(JointType.HandLeft)
Dim rightHand As Joint = skeleton.Joints(JointType.HandRight)
Dim leftShoulder As Joint = skeleton.Joints(JointType.ShoulderLeft)
Dim rightShoulder As Joint = skeleton.Joints(JointType.ShoulderRight)
Dim rightHip As Joint = skeleton.Joints(JointType.HipRight)
' the right hand joint is being tracked
If rightHand.TrackingState = JointTrackingState.Tracked Then
' the hand is sufficiently in front of the shoulder
If rightShoulder.Position.Z - rightHand.Position.Z > 0.4 Then
Dim xScaled As Double = (rightHand.Position.X - leftShoulder.Position.X) / ((rightShoulder.Position.X - leftShoulder.Position.X) * 2) * SystemParameters.PrimaryScreenWidth
Dim yScaled As Double = (rightHand.Position.Y - rightShoulder.Position.Y) / (rightHip.Position.Y - rightShoulder.Position.Y) * SystemParameters.PrimaryScreenHeight
' the hand has moved enough to update screen position (jitter control / smoothing)
If Math.Abs(rightHand.Position.X - xPrevious) > MoveThreshold OrElse Math.Abs(rightHand.Position.Y - yPrevious) > MoveThreshold Then
RightHandX = xScaled
RightHandY = yScaled
xPrevious = rightHand.Position.X
yPrevious = rightHand.Position.Y
' reset the tracking timer
trackingTimerCounter = 10
End If
End If
End If
End Sub
我已经导入了 Microsoft.Kinect
现在我有这些错误显示:
'xPrevious' 未声明。由于其保护级别,它可能无法访问。未声明“MoveThreshold”。由于其保护级别,它可能无法访问。'yPrevious' 未声明。由于其保护级别,它可能无法访问。未声明“MoveThreshold”。由于其保护级别,它可能无法访问。未声明“RightHandX”。由于其保护级别,它可能无法访问。未声明“RightHandY”。由于其保护级别,它可能无法访问。'xPrevious' 未声明。由于其保护级别,它可能无法访问。'yPrevious' 未声明。由于其保护级别,它可能无法访问。未声明“trackingTimerCounter”。由于其保护级别,它可能无法访问。
我知道他们没有被宣布,真的不知道该怎么做,有人可以帮我解决这个问题吗?
对不起我的无知