Kinect defined Natural User Interaction. HTML5 redefined the Web. Currenty, there are various tutorials describing how to interact with a Kinect sensor using Windows Forms or WPF for the user interface. But what about using a web interface for handling Kinect data? Trying to combine those two hot, cutting-edge technologies, I came up with a pretty and open-source solution, which I am going to describe in this blog post.
I am going to use the official Kinect SDK for my demo, but same principles apply to OpenNI SDK, too.
The project consists of two sub-projects: A server-side application which uses Kinect SDK and a client-side web page displaying the skeleton joints on an HTML5 canvas.
Client application:
Server application:
Here is, step by step, a way to achieve the above functionality:
The server application's job is straightforward: Detect the users' joints, pack the data and send them to the clients using web sockets.
In order to detect the joints' coordinates, we need to add a reference to our prefered Kinect SDK and handle the skeleton events. I recommend Microsoft SDK over OpenNI because it's far less complicated:
static void Nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { List users = new List(); foreach (var user in e.SkeletonFrame.Skeletons) { if (user.TrackingState == SkeletonTrackingState.Tracked) { users.Add(user); } } if (users.Count > 0) { string json = users.Serialize(); foreach (var socket in _sockets) { socket.Send(json); } } }
In order to send the data to the subscribed clients, we need to "pack" the joints' coordinates in a way that the clients will be able to understand and process. I decided to encode the coordinates in JSON format, as JSON is a lightweight and easy-to-understand way of transmitting data throught the web. You can find the JSON-encoder class in the source code files.
Considering the data transmission, I highly recommend the use of Fleck. Fleck, based on Nugget, is a C# web socket library that does what it says with minimum configuration effort: It broadcasts the desired data to the subscribed clients using lightweight web sockets. Here is how you can initialize a web socket server:
_sockets = new List(); var server = new WebSocketServer("ws://localhost:8181"); server.Start(socket => { socket.OnOpen = () => { Console.WriteLine("Connected to " + socket.ConnectionInfo.ClientIpAddress); _sockets.Add(socket); }; socket.OnClose = () => { Console.WriteLine("Disconnected from " + socket.ConnectionInfo.ClientIpAddress); _sockets.Remove(socket); }; socket.OnMessage = message => { Console.WriteLine(message); }; });
After collecting, packing and transmitting the data, clients can now consume and process them accordingly.
Time for HTML5 bits! We have the server set up, so let's add the web page clients. HTML5 spec recommends web socket support, currently implemented by Internet Explorer 10, Google Chrome and Mozilla Firefox. Web sockets are great for direct message communication between server and clients.
All we need is some JavaScript for receiving the server data and a canvas for drawing the points. Here is the JavaScript event handler for getting the data and drawing the joints to a <canvas> element:
socket.onmessage = function (evt) { status.innerHTML = "Kinect data received."; // Get the data in JSON format. var jsonObject = eval('(' + evt.data + ')'); context.clearRect(0, 0, canvas.width, canvas.height); context.fillStyle = "#FF0000"; context.beginPath(); // Display the skeleton joints. for (var i = 0; i < jsonObject.skeletons.length; i++) { for (var j = 0; j < jsonObject.skeletons[ i ].joints.length; j++) { var joint = jsonObject.skeletons[ i ].joints[ j ]; // Draw!!! context.arc(parseFloat(joint.x), parseFloat(joint.y), 10, 0, Math.PI * 2, true); } } context.closePath(); context.fill(); };
Now run the server application and then open the HTML file in Internet Explorer 10 or Google Chrome. Stand in front of a Kinect sensor and may the force be with you.
You will definitely need to download source code and binaries in order to develop your own HTML5 Kinect applications. Enjoy!
CodeProject
Hi, i am making a kinect monitor like this one www.bradygaster.com/the-kinectonitor can i even pass images in HTML5 and make it look like a streaming video from my house
@Anunay
I am working on that and will present my results by updating this blog post.
The Windows Client Developer Roundup aggregates information of interest to Windows Client Developers
1) Buy a Kinect, the world’s fastest selling and most awesome electronic device. 2) Download the Kinect
@Vangos
Could you update the files because the Kinect.Server app is no longer working. Kinect SDK is now officially 1.0, and is no longer a Microsoft Research Project. www.microsoft.com/.../kinectforwindows Thanks.
@Anon
I am working on that and post an update soon!
nice post ,Thanks for sharing
Thank you for the thoughtful review. The main advantage of <a href="seotoolster.com/.../html5-video-player-audio-player "> html5 music player</a>seems to be for embedding rich media such as audio and video in modern browsers. Although, the structure elements seem to be useful. CSS3 seems to be headed in the right direction, leaving many possibilities for implementation and creativity,
www.storeblackhawks.com/31-martin-havlat-jersey Martin Havlat Jersey
www.storeblackhawks.com/32-marty-turco-jersey Marty Turco Jersey
www.storeblackhawks.com/34-nick-leddy-jersey Nick Leddy Jersey
www.storeblackhawks.com/5-adam-burish-jersey Adam Burish Jersey
www.storeblackhawks.com/14-brian-campbell-jersey Brian Campbell Jersey
www.storeblackhawks.com/16-cristobal-huet-jersey Cristobal Huet Jersey
www.storeblackhawks.com/24-jeremy-morin-jersey Jeremy Morin Jersey
www.storeblackhawks.com/8-ben-eager-jersey Ben Eager Jersey
www.storeblackhawks.com/6-andrew-ladd-jersey Andrew Ladd Jersey
www.storeblackhawks.com/13-brent-sopel-jersey Brent Sopel Jersey
www.storeblackhawks.com/23-glean-hall-jersey Glean Hall Jersey
www.storeblackhawks.com/15-corey-crawford-jersey Corey Crawford Jersey
www.storeblackhawks.com/17-dan-carcillo-jersey Dan Carcillo Jersey
www.storeblackhawks.com Blackhawks Jersey
www.storeblackhawks.com Chicago Blackhawks Jersey
www.storeblackhawks.com/36-patrick-kane-jersey Patrick Kane Jersey
www.storeblackhawks.com/11-bobby-orr-jersey Bobby Orr Jersey
www.storeblackhawks.com/30-marian-hossa-jersey Marian Hossa Jersey
www.storeblackhawks.com/33-michael-jordan-jersey Michael Jordan Jersey
www.storeblackhawks.com/27-jonathan-toews-jersey Jonathan Toews Jersey
www.storeblackhawks.com/20-duncan-keith-jersey Duncan Keith Jersey
www.storeblackhawks.com/37-patrick-sharp-jersey Patrick Sharp Jersey
www.storeblackhawks.com/25-jeremy-roenick-jersey Jeremy Roenick Jersey
www.storeblackhawks.com/10-bobby-hull-jersey Bobby Hull Jersey
www.storeblackhawks.com/12-brent-seabrook-jersey Brent Seabrook Jersey
www.storeblackhawks.com/38-stan-mikita-jersey Stan Mikita Jersey
www.storeblackhawks.com/7-antti-niemi-jersey Antti Niemi Jersey
www.storeblackhawks.com/22-ed-belfour-jersey ED Belfour Jersey
www.storeblackhawks.com/28-keith-magnuson-jersey Keith Magnuson Jersey
www.storeblackhawks.com/19-denis-savard-jersey Denis Savard Jersey
www.storeblackhawks.com/35-niklas-hjalmarsson-jersey Niklas Hjalmarsson Jersey
www.storeblackhawks.com/39-steve-larmer-jersey Steve Larmer Jersey
www.storeblackhawks.com/18-dave-bolland-jersey Dave Bolland Jersey
www.storeblackhawks.com/21-dustin-byfuglien-jersey Dustin Byfuglien Jersey
www.storeblackhawks.com/40-tomas-kopecky-jersey Tomas Kopecky Jersey
www.storeblackhawks.com/41-tony-esposito-jersey Tony Esposito Jersey
www.storeblackhawks.com/29-kris-versteeg-jersey Kris Versteeg Jersey
www.storeblackhawks.com/42-troy-brouwer-jersey Troy Brouwer Jersey
Great Post!. For those waiting for an update, you can go back to the Beta version of the SDK too.
Thank you for the thoughtful review. The main advantage of <a href="http://html5socket.com">html5 player</a> seems to be for embedding rich media such as audio and video in modern browsers. Although, the structure elements seem to be useful. CSS3 seems to be headed in the right direction, leaving many possibilities for implementation and creativity,
I am exicited about HTML5 but Flash can do all these things <a href="html5socket.com/.../a> can do in a better way.Creating slideshow in HTML5! wow! what, flash did that 10 years ago! It is very easy to create a flash animation, for example a ball bouncing in flash professional in less than am minute. Javascript is a mess when compared to AS3.
http://www.flyersfanshop.com/
www.flyersfanshop.com/13-claude-giroux-jersey
www.flyersfanshop.com/28-scott-hartnell-jersey
www.flyersfanshop.com/31-van-riemsdyk-jersey
www.flyersfanshop.com/18-james-van-riemsdyk-jersey
www.flyersfanshop.com/21-kimmo-timonen-jersey
www.flyersfanshop.com/15-danny-briere-jersey
www.flyersfanshop.com/29-sergei-bobrovsky-jersey
www.flyersfanshop.com/12-chris-pronger-jersey
www.flyersfanshop.com/8-bernie-parent-jersey
www.flyersfanshop.com/14-daniel-carcillo-jersey
www.flyersfanshop.com/11-bobby-clarke-jersey
www.flyersfanshop.com/19-jaromir-jagr-jersey
www.flyersfanshop.com/17-ilya-bryzgalov-jersey
www.flyersfanshop.com/16-dave-schultz-jersey
www.flyersfanshop.com/25-mike-richards-jersey
www.flyersfanshop.com/20-jeff-carter-jersey
www.flyersfanshop.com/22-kris-versteeg-jersey
www.flyersfanshop.com/32-wayne-simmonds-jersey
www.flyersfanshop.com/10-flyers-practice-jersey
www.flyersfanshop.com/9-bill-barber-jersey
www.flyersfanshop.com/30-simon-gagne-jersey-
www.flyersfanshop.com/27-riley-cote-jersey
www.flyersfanshop.com/24-michael-leighton-jersey
www.flyersfanshop.com/23-maxime-talbot-jersey
www.flyersfanshop.com/26-ray-emery-jersey
<a href="www.supratksocietyoutlet.com/blue-crackle-justin-bieber-supra-tk-society-tuf-shoes-p-3.html ">Blue Crackle Justin Bieber Supra TK Society TUF Shoes</a> ,<a href="www.supratksocietyoutlet.com ">Outlet Supra Shoes</a>,<a href="www.supratksocietyoutlet.com/supra-skytop-womens-shoes-c-13.html ">Supra Skytop Womens Shoes </a> ,<a href="www.supratksocietyoutlet.com/purple-justin-bieber-supra-tk-society-leather-shoes-p-10.html ">Justin Bieber Supra</a>,<a href="www.supratksocietyoutlet.com/2012-supra-skytop-grey-blue-skateboarding-shoes-for-sale-p-72.html ">Supra Skytop </a>,