private void SetHandPosition(Hand hand, PXCMHandData.IHand handInfo) { var imagePosition = ToPoint3D(handInfo.QueryMassCenterImage()); var worldPosition = ToPoint3D(handInfo.QueryMassCenterWorld()); hand.Position = CreatePosition(imagePosition, worldPosition); }
private void SetHandPosition(Hand hand, PXCMHandData.IHand handInfo) { var world = handInfo.QueryMassCenterWorld(); if (_smoothers.ContainsKey(hand)) { world = _smoothers[hand].SmoothValue(world); } var imagePosition = ToPoint3D(handInfo.QueryMassCenterImage()); var worldPosition = ToPoint3D(world); hand.Position = CreatePosition(imagePosition, worldPosition); }
/// <summary> 指のデータを取得する </summary> private void GetFingerData(PXCMHandData.IHand hand, PXCMHandData.JointType jointType) { PXCMHandData.JointData jointData; var sts = hand.QueryTrackedJoint(jointType, out jointData); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { return; } // Depth座標系をカラー座標系に変換する var depthPoint = new PXCMPoint3DF32[1]; var colorPoint = new PXCMPointF32[1]; depthPoint[0].x = jointData.positionImage.x; depthPoint[0].y = jointData.positionImage.y; depthPoint[0].z = jointData.positionWorld.z * 1000; projection.MapDepthToColor(depthPoint, colorPoint); var masp = hand.QueryMassCenterImage(); var mdp = new PXCMPoint3DF32[1]; var mcp = new PXCMPointF32[1]; mdp[0].x = masp.x; mdp[0].y = masp.y; mdp[0].z = hand.QueryMassCenterWorld().z * 1000; projection.MapDepthToColor(mdp, mcp); //Console.WriteLine(mcp[0].x); AddEllipse(new Point(mcp[0].x, mcp[0].y), 10, Brushes.Red, 1); colorPoint = mcp; //AddEllipse(new Point(colorPoint[0].x, colorPoint[0].y), 5, Brushes.White, 1); if (ensembleTimer.IsEnabled) { DetectTap(hand, mcp[0]); } //if (ensembleTimer.IsEnabled) RecogMove(hand,mcp[0]); //RecogMove(hand,mcp[0]); }
/// <summary> 指のデータを取得する </summary> private bool GetFingerData(PXCMHandData.IHand hand, PXCMHandData.JointType jointType) { PXCMHandData.JointData jointData; var sts = hand.QueryTrackedJoint(jointType, out jointData); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { return(false); } // Depth座標系をカラー座標系に変換する var depthPoint = new PXCMPoint3DF32[1]; var colorPoint = new PXCMPointF32[1]; depthPoint[0].x = jointData.positionImage.x; depthPoint[0].y = jointData.positionImage.y; depthPoint[0].z = jointData.positionWorld.z * 1000; projection.MapDepthToColor(depthPoint, colorPoint); var masp = hand.QueryMassCenterImage(); var mdp = new PXCMPoint3DF32[1]; var mcp = new PXCMPointF32[1]; mdp[0].x = masp.x; mdp[0].y = masp.y; mdp[0].z = hand.QueryMassCenterWorld().z * 1000; projection.MapDepthToColor(mdp, mcp); //Console.WriteLine(mcp[0].x); AddEllipse(new Point(mcp[0].x, mcp[0].y), 10, Brushes.Red, 1); colorPoint = mcp; //ユーザの右手に対して演奏領域の当たり判定確認 if (hand.QueryBodySide() == PXCMHandData.BodySideType.BODY_SIDE_LEFT) { for (int i = 0; i < 5; i++) { if ((imageColor.Height / 5) * i <= colorPoint[0].y && colorPoint[0].y < (imageColor.Height / 5) * (i + 1)) { if (16 - i != NowRange) { NowRange = 16 - i; PivotList.Dispatcher.BeginInvoke( new Action(() => { PivotList.SelectedItem = NowRange; } )); } } } } //ユーザの左手に対してアイコンの当たり判定の確認 if (hand.QueryBodySide() == PXCMHandData.BodySideType.BODY_SIDE_RIGHT) { IconHitCheck(colorPoint[0]); } AddEllipse(new Point(colorPoint[0].x, colorPoint[0].y), 5, Brushes.White, 1); return(true); }