Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

78
Skeltrack - Open Source Skeleton Tracking Joaquim Rocha, Igalia LinuxTag 2012 - Wunderbare Berlin

description

By Joaquim Rocha. With the release of the Kinect device, there was finally an affordable camera capable of giving depth information. This, together with the Kinect's open USB connection, led to a lot of innovative projects. Still, the Kinect just gives raw signals and the only way to obtain more complex information, such as skeleton tracking was to use either the Microsoft SDK or the OpenNI framework. Both of these solutions are closed, proprietary and, in the case of Microsoft's, only for non-commercial work. To solve the issue above, Igalia developed Skeltrack, a Free and Open Source library published under LGPL that performs human skeleton tracking and identifies a number of skeleton joints. It is a more atomic solution than the other commercial counterparts because it does not connect directly to the Kinect nor to any other depth camera, instead it expects to be given the buffer corresponding to the depth buffer. In this talk I will present how Skeltrack was developed and show a demo of it working.

Transcript of Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Page 1: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Skeltrack - Open Source Skeleton Tracking

Joaquim Rocha, IgaliaLinuxTag 2012 - Wunderbare Berlin

Page 2: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Guten Tag!

✩ I am a developer at Igalia✩ I like doing innovative stuff like OCRFeeder and SeriesFinale✩ and today I am presenting my latest project: Skeltrack

Page 3: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

The Kinect

Page 4: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Microsoft's Kinect was the first camerawith a price affordable to the public

Page 5: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

The USB connection is open and thus hackable

Page 6: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

This originated Open Source projects like the libfreenect,a library to control the Kinect device and get its information

Page 7: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

We created a GLib wrapper for libfreenect called GFreenect

Page 8: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

GFreenect offers asynchronous functions (and some synchronous aswell) and makes it easy to use with other GNOME technologies

Page 9: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

GObject Introspection = free bindings (Python, Javascript, Vala)

Page 10: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Kinect has a structured light camera which gives depth information

Page 11: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

But that's raw information... values from 0-2048

Page 12: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

libfreenect/GFreenect can give those values in mm

Page 13: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)
Page 14: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Still...

Page 15: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

It does NOT tell you there is a person in the picture

Page 16: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Or a cow

Page 17: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Or an ampelmann

Page 18: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Let alone a skeleton and where its joints are

Page 19: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

For this you need a skeleton tracking solution

Page 20: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Three proprietary/closed solutions exist:

Page 21: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Microsoft Kinect SDK: non-commercial only

Page 22: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

OpenNI: commercial compatible

Page 23: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Kinect for Windows: commercial use allowedbut incompatible with the XBox's Kinect

Page 24: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)
Page 25: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Conclusion: There were no Free solutions toperform skeleton tracking... :(

Page 26: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

So Igalia built one!

Page 27: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Enter Skeltrack

Page 28: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

What we wanted:✩ A shared library, no fancy SDK✩ Device independent✩ No pattern matching, no databases✩ Easy to use (everybody wants that!)

Page 29: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Not as easy as it sounds!

Page 30: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

After some investigation we found Andreas Baak'spaper "A Data-Driven Approach for Real-Time FullBody Pose Reconstruction from a Depth Camera"

Page 31: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

However this paper uses a database ofposes to get what the user is doing

Page 32: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

So we based only part of our work on it

Page 33: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

How does it work?

Page 34: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

First we need to find the extremas

Page 35: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Make a graph whose nodes are the depth pixels

Page 36: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Connect two nodes if the distance is less than acertain value

Page 37: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Connect the different graph's components by usingconnected-component labeling

Page 38: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Choose a starting point and calculate Dijkstra toeach point of the graph; choose the furthest point.There you got your extrema!

Page 39: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Then create an edge between the starting pointand the current extrema point with 0 cost andrepeat the same process now using the currentextrema as a starting point.

Page 40: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

This comes from Baak's paper and the differencestarts here: choosing the starting point

Page 41: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Baak chooses a centroid as the starting point

We choose the bottom-most point starting from thecentroid (this showed better results for the upperbody extremas)

Page 42: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

So we got ourselves some extremas!What to do with them?

Page 43: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

What extrema is a hand, a head, a shoulder?

Page 44: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

For that we use educated guesses...

Page 45: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

We calculate 3 extremas

Page 46: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Then we check each of them hoping they are the head

Page 47: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

How?

Page 48: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

For each extrema we look for the points in placeswhere the shoulders should be, checking their distancesbetween the extrema and between each other.

Page 49: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

If they obey those rules then we assume they arethe head'n'shoulders (tm)

Page 50: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

With the remaining 2 extremas, we will try to see ifthey are elbows or hands

Page 51: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

How to do it?

Page 52: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Calculate Dijkstra from the shoulders to each extrema

Page 53: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

The closest extrema to any of the shoulders is either ahand of an elbow of that shoulder

Page 54: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

How to check if it's a hand or an elbow?

Page 55: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

If the distance between the extrema and the shoulder isless than a predefined value, then it is an elbow. Otherwiseit is a hand.

Page 56: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

If it is a hand, we find the elbow by choosing the first point(in the path we created with Dijkstra before) whose distanceexceeds the elbow distance mentioned before

Page 57: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)
Page 58: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

There is still some things missing...

Page 59: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Future work

Page 60: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Hands from elbows: If one of the extremas is an elbow, weneed to infer where the hand is

Page 61: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Smoothing: Smooth the jittering of the joints

Page 62: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Robustness: Use restrictions to ignore objects that are notthe user

Page 63: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Multi-user: Track more than one person at a time

Page 64: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

And of course, get the rest of the joints: hips, knees, etc.

Page 65: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

How to use it?

Page 66: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Asynchronous API

Page 67: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

SkeltrackSkeleton *skeleton = SKELTRACK_SKELETON (skeltrack_skeleton_new ());skeltrack_skeleton_track_joints (skeleton, depth_buffer, buffer_width, buffer_height, NULL, on_track_joints, NULL);

Page 68: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)
Page 69: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Synchronous API

Page 70: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

SkeltrackJointList list;list = skeltrack_skeleton_track_joints_sync (skeleton, depth_buffer, buffer_width, buffer_height, NULL, NULL);

Page 71: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Skeleton Joint:

ID: HEAD, LEFT_ELBOW, RIGHT_HAND, ...x: X coordinate in real world (in mm)y: Y coordinate in real world (in mm)screen_x: X coordinate in the screen (in pixels)screen_y: Y coordinate in the screen (in pixels)

Page 72: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Code/Bugs: https://github.com/joaquimrocha/Skeltrack

Page 73: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Nifty Tools for Development:

GFreenect: https://github.com/elima/GFreenect

GFreenect Utils: https://github.com/joaquimrocha/gfreenect-utils

Page 74: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

GFreenect Python Example

Page 75: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Tool: record-depth-file

Page 76: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Tool: depth-file-viewer

Page 77: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Questions?

Page 78: Skeltrack: A Free Software library for skeleton tracking (LinuxTag 2012)

Creative Commons pictures from flickr:Kinect: Auxo.co.krAmpelmann: echiner1Kid Playing: Rob WelshSkeleton: Dark Botxy