Question

I (literally) want to catch a framework element using NUI of Kinect. Assuming that I have an ellipse on my Grid (or Canvas), I should be able to pick an ellipse using my program.

In order to do this, I thought that I have to determine the exact position of the element, like Transform.Position in Unity, but I couldn't find such a thing in WPF.

Here is my XAML code,

<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
    <my:KinectSensorChooser HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="kinectSensorChooser1" />
    <my:KinectColorViewer Stretch="Fill" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Name="kinectColorViewer1" Kinect="{Binding Path=Kinect, ElementName=kinectSensorChooser1}" />
    <Ellipse Height="114"  Name="ellipse1" Stroke="Black" Fill="Black" VerticalAlignment="Top" Width="120" />
</Grid>

So my question is about finding the that element on the Grid. Having a Cursor or any element that represents the user's hand is not a problem. But after that, I'll have to detect the collision between my cursor and these elements and that the part that troubles me. An event like ElementHover or ElementPicked would also help but i guess i'm gonna have to write something like that myself.

By the way, it's about an "Engineering Education Software" project that aims to develop virtual environments for engineering exercises like expensive or dangerous experiments.

Was it helpful?

Solution

Several examples from Microsoft, provided in the SDK v1.6 Toolkit, give examples of how to determine the location of objects on the screen and interact with them with a custom cursor that represents the player's hand.

I would suggest checking out several of the examples provided in order to get a clear picture of how interactions can work. The toolkit is found in the same location as the office Kinect for Windows SDK.

http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx

ShapeGame

This example generates random shapes (some of them ellipses) which fall from the top of the window. Those shapes interact with the skeleton produced by the Kinect. You'll see how to get the position of elements in the window, and in relation to the skeleton.

BasicInteractions

This examples does several things that are of use. It shows how to produce a custom cursors based on the hand position. It also creates a ContentControl that can be hooked up to Kinect events (such as a hand enter, hover and exit event). It is built in such a way, because it is a ContentControl that anything can be put inside -- be it a single ellipse, or a complex layout.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top