Skeletal "Fingerprints" with the Kinect v2
Mike Taulty, Coding4Fun Friend, has written up a great development post on the Kinect for Windows v2...
This post is just to share some code that I wrote quite a while ago for fun.
At Microsoft’s UK campus there are some corridors that have gates which allow people to freely walk in one direction but which only allow people with the right ID cards to go in the other.
This set me wondering whether it might be possible to develop code with the Kinect for Windows V2 which monitored people walking towards the camera and;
- Took skeletal measurements as they approached the camera to build up average ‘limb lengths’ based on some set of limbs and measurement counts that can be configured.
- Grabbed a head and shoulders photo of each person based on knowledge of where their head and shoulders are within the camera’s view.
- Stored both of (1) and (2) in the cloud using some configurable table and blob storage.
- Scanned previously stored measurements in the cloud to determine whether a person of very similar ‘shape and size’ has been previously seen based on some configurable tolerance value.
- Ultimately, opened the door based on recognising the user’s skeleton.
Now, in truth, I’ve never really got this to work I’m not sure whether the idea of a ‘skeletal fingerprint’ is a flawed idea in the first place but I got way too many false positives to consider asking Microsoft to use my new system for their security but I had some fun in putting it together.
However, this was prior to the arrival of Microsoft’s Cognitive Services and I may revisit the code in coming weeks/months to see if I can make a better attempt at it in the light of those new services coming along as perhaps I can combine my not so successful idea of ‘skeletal fingerprint’ with an additional call to Cognitive Services to do facial identification and produce a better result than I previously did.
What’s with the Weird Code Structure?
The structure of this code is a bit unusual in that I wanted to be able to build out both a WPF application and a Windows application from the same code. The Windows application is a Windows 8.1 app rather than a UWP app because there isn’t a Kinect for Windows V2 SDK for UWP and so this code targets Windows 8.1 but will, naturally, run on Windows 10.
The Kinect for Windows V2 SDK is structured such that, with one or two conditional compilation statements around namespaces, it’s possible to write the same code for WinRT and WPF and so that’s what I set out to do although it does mean that I haven’t (e.g.) used something like Win2D for some drawing because Win2D only exists in WinRT, not in WPF.
How Is It Configured?
There are elements of configuration needed here whether running the WinRT app or the WPF app. The default configuration lives in 2 files;
What Does Running the App Do?
I can run either the WPF application or the WinRT application and (as long as I’ve got my Kinect for Windows V2 camera plugged in) I’ll get a video (or IR) display like the one below.
I’ve had this code for a long time but have never written it up so I found a few spare cycles today to do that.
It was built 100% ‘just for fun’ but I thought I’d share in case anyone else was interested or wanted to take pieces of it and improve it
What I’d perhaps like to do next is to extend this by adding in some use of facial identification via Cognitive Services to see if I could build a system that worked a little better by using a combination of skeletal measurements with facial identity such that both mechanisms were used to determine identify. ...
Project Source URL: https://github.com/mtaulty/KinectBodyMeasurement