# Fill the Shape using Kinect

• ### General discussion

• I want to make a game using KinectSDK and XNA that player has to fill the shape using kinect depth view which is shown below:

http://i.stack.imgur.com/GD6VV.jpg

as you see in the image, I just want to try to using per pixel collision method, which I have to draw a rectangle around player and Stencil, then I will detect them using this function :

```static bool InsersectsPixel(Rectangle rect1, Color[] data1,
Rectangle rect2, Color[] data2)
{
int top = Math.Max(rect1.Top, rect2.Top);
int bottom = Math.Min(rect1.Bottom, rect2.Bottom);
int left = Math.Max(rect1.Left, rect2.Left);
int right = Math.Min(rect1.Right, rect2.Right);

for (int y = top; y < bottom; y++)
for (int x = left; x < right; x++)
{
Color colour1 = data1[(x - rect1.Left) +
(y - rect1.Top) * rect1.Width];

Color colour2 = data2[(x - rect2.Left) +
(y - rect2.Top) * rect2.Width];

if(colour1.A != 0 && colour2.A != 0)
{
return true;
}
}

return false;
}```

I will calculate data1 and data2 from height and weight of the rectangle.

I just wanna ask about do you know any better solution to avoid using skeleton ? because I have to use skeleton to draw that rectangle (I have to use skeleton to find a distance between up to down, and left to right for height and width of the rectangle for player) around the player and I'm looking for a method to just use a depth view, not the Skeleton Data

Thanks

Tuesday, December 16, 2014 3:28 PM

### All replies

• Since depth and color are planar objects, I don't think there would be a disadvantage of using a rectangular region? If you are looking for speed, you can divide the area into regions and do the calculations in parallel.

Carmine Sirignano - MSFT

Tuesday, December 16, 2014 7:54 PM
• actually I have to use skeleton joints to find height and width of the player using distances from up to down, and left to right of the player. do you know any method to find height and width from depth view (without using joints) ?
Wednesday, December 17, 2014 6:34 AM
• Ask the user to stand infront of the sensor. Once you detect the user, go through the depth/player index and take the average of the top points of the mask(head) and average out the bottom(pixel depths). Map those to skeleton/world space should give you the point in space and determine the height from that.

Carmine Sirignano - MSFT

Wednesday, December 17, 2014 7:53 PM