Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Kinect v2 | mouse-control | WinRT

$
0
0

@Epiphany99 wrote:

Hi all!

Currently I´m working on a mouse-control with the Microsoft Kinect, oF and WinRT. I´ve implemented a color-stream include hand-tracking, that works perfect.

Now I want to control the mouse with my hand, and here is my problem. I´m using WinRT, so i can´t use the SetCursorPos()-function.

After searching in the inet, I found out, that I must deactivate the original mousecursor, and implement a relative one, but I have no idea how that works, because I have no experience in WinRT-programming... :frowning:

void ofApp::UpdateBodyFrameColor()
{
	BodyFrame^ bdyFrame = bodyReader->AcquireLatestFrame();
	if (nullptr != bdyFrame)
	{
		bdyFrame->GetAndRefreshBodyData(bdyArray);
		for each (Body^ body in bdyArray)
		{
			if (body->IsTracked)
			{
				WFC::IMapView<JointType, Joint>^ joints = body->Joints;
				for each(auto joint in joints)
				{
					if (joint->Key == JointType::HandLeft)
					{
						CameraSpacePoint position = joint->Value.Position;
						ColorSpacePoint colorSpacePoint = coordMapper->MapCameraPointToColorSpace(position);
						lhx = colorSpacePoint.X;
						lhy = colorSpacePoint.Y;
					}'
					if (body->HandLeftConfidence == TrackingConfidence::High)
					{
						switch (body->HandLeftState)
						{

						case HandState::Open:
							colorLeftHand = ofColor::green;
							// !!!! here should be the mouse control !!!!
							break;

						case HandState::Closed:
							colorLeftHand = ofColor::red;
							// !!!!! here should be done a left click !!!!
							break;

						default:
							colorLeftHand = ofColor::white;
						}
					}
				}
			}
		}
	}
}

Thx and BG Epi

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles