一名热爱体感技术的
业余专业开发人员

KINECT for Windows v2 SDK Deep dive

转载自zubair网站。当初这个老兄获得KinectV2申请时发了博客,我搜到了和他聊过一二句话。如今又看到他的文章被微软网站分享,世界真小~我估计等四五个月买个新的笔记本再开展KinectV2研究了,现在只能分享文章或者找同学电脑玩下KinectV2.

Few weeks ago I received my Kinect for Windows version 2 and private SDK so I finally got to try it out, the new Kinect ships with many improvements from v1 such as an Full HD Camera, thumb and hand open/close detection, better microphone, improved infrared and several applications can use the sensor at the same time.

KinectOne

Deep dive

In this blog post I will show how to read Body source and draw Bones, Hands and Joints over the Color source received from the Kinect Sensor.

KinectOnev2Experiment

“This is preliminary software and/or hardware and APIs are preliminary and subject to change.”

In the constructor of our WPF app the code reads two important sources, Body frame, Color frame and Width and Height from the Depth Sensor. It then opens both readers to start receiving frames.

The MainWindow.xaml contains a Grid with two Image elements for Color and Body data.

We subscribe to FrameArrived events of both readers in the Loaded event of our app

The color frame arrived event handler acquires a frame and validates it before converting it to Byte Array and writes to WriteableBitmap which is used by Image element in our Xaml to display color stream.

The reader frame arrived event handler is the most interesting one, the code uses a DrawingContext to draw a rectangle, our Body frame data will be written within this rectangle. We then get the Body data from the Kinect sensor. Because the Kinect can detect up to 6 bodies at the same time, the code loops through each body object to check if it can read body joints information from the sensor before it can do something useful with it.

If the Kinect is able to track a body it loops through each Joint and uses a CoordinateMapper to give us X and Y coordinates for each joint which it then uses to draw Body and Hand joints. Note that I cheat a little bit on line 36 to fix the vertical position of my drawing by subtracting 80px from the Height.

Notice that for both hands Kinect sensor SDK gives us a state that the code uses to draw a Red/Green ellipses

That’s all I had to do to draw body joints over a camera stream from the Kinect sensor.

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址