我有一個問題在這裏回答了「Evil Closet Monkey」關於Kinect鼠標項目,我將代碼從C#轉換爲VB.Net。代碼如下:VB.Net Kinect鼠標
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'未被聲明。由於其保護級別,它可能無法訪問。
我知道他們沒有申報,真的不知道該怎麼辦,有誰能幫我解決這個問題嗎?
對不起,我的無知
你能鏈接到你從這段代碼得到的文章嗎?我可能會返回並對該代碼進行一些更正。 :) –