Altering Font Size Based on User Proximity Using Kinect

posted in: Kinect | 0

kinect-one

One of the things we discussed at our recent presentation covering Kinect was using is in the periphery as an aide rather than being the centre of attention.

The concept was simple- as the user moves closer or farther away to a screen, use the kinect depth sensor to detect this and some code to change the font size so it’s easier for the user to read.

The code to do this (in its most simple form) is also quiet straight forward.

code1

We start with a basic XMAL grid – I’ve gone with some simple Lorem  Ipsum text. Then we’re going to put a binding on the FontSize of the text. To get an idea on distance I’m going to display how far the user is from the screen in metres.

code2

In the codebehind we create variables to store our KinectSensor, our BodyFrameReader and an array of bodies.

image

In our MainWindow we then grab a reference to the Kinect Sensor, open the body frame reader and sensor.

image

In our MainWindow_Loaded event we hook to the bodyframeReader’s FrameArrived event (this is where the good stuff goes) and in our closing make sure we clean up our code.

image

In our reader’s frame arrived event we grab the body data. Then I grab the first tracked body (ie me).

There’s lots of options for which joint/s to use by I’m just going to grab the head and as long as it’s bring tracked I’m going to use it’s Z coordinate.

image

I set my property we bind on screen to display on screen to the current Z value and also refire logic to calculate what font size we should use.  I’ve just chosen to do a multiplication factor on the distance buy you could get a lot more fancy.