Getting started with the Kinect for Windows SDK Development (iv) on depth data processing

Source: Internet
Author: User

One of the most important features of the Kinect sensor is the ability to generate three-dimensional data from which we can create cool apps. Before you can develop a Kinect application, it's a good idea to understand the Kinect hardware structure. The Kinect infrared sensor can detect human and non human objects such as chairs or coffee cups. Many business organizations and laboratories are studying the use of depth data to detect objects.

In this paper, the Kinect IR sensor, depth data format, depth image acquisition and display, depth image enhancement processing are introduced in detail.

1. Kinect sensor

Unlike many input devices, Kinect produces three-dimensional data, which has infrared transmitters and cameras. Unlike other Kinect SDKs such as Openni or Libfreenect, Microsoft's Kinect SDK does not provide a way to get the original IR data stream, instead, the Kinect SDK calculates the infrared data from the IR camera, Then the depth image data is generated. The depth image data is generated from the Depthimageframe, which is provided by the Depthimagestream object.

The use of Depthimagestream is similar to the use of colorimagestream. Depthimagestream and Colorimagestream both inherited from ImageStream. You can generate an image of depth as you would get data from Colorimagestream to generate images. Let's take a look at the steps needed to present the depth of the data. The following steps are similar to the color image data shown earlier:

1. Create a new WPF object.

2. Add a Microsoft.Kinect.dll object reference.

3. Add an image element to the UI and change the name to Depthimage.

4. Add the necessary code to discover and release the Kinectsensor object. You can refer to the previous article.

5. Modify the initialization of the Kinectsensor object code as follows:

private void Initializekinectsensor (Kinectsensor kinectsensor)
{
    if (kinectsensor!= null)
    {
        Depthimagestream depthstream = Kinectsensor.depthstream;
        Depthstream.enable ();
    
        Depthimagebitmap = new WriteableBitmap (Depthstream.framewidth, Depthstream.frameheight,  96, 96, PIXELFORMATS.GRAY16, null);
        Depthimagebitmaprect = new Int32Rect (0, 0, depthstream.framewidth, depthstream.frameheight);
        Depthimagestride = Depthstream.framewidth * Depthstream.framebytesperpixel;
    
        Depthimage.source = Depthimagebitmap;
        Kinectsensor.depthframeready + = Kinectsensor_depthframeready;
        Kinectsensor.start ();
    }

6. Modify the Depthframeready event with the following code:

void Kinectsensor_depthframeready (object sender, Depthimageframereadyeventargs e)
{
    using (depthimageframe Depthframe = E.opendepthimageframe ())
    {
        if (depthframe!= null)
        {
            short[] depthpixeldate = new short[ Depthframe.pixeldatalength];
            Depthframe.copypixeldatato (depthpixeldate);
            Depthimagebitmap.writepixels (Depthimagebitmaprect, depthpixeldate, depthimagestride, 0);}}

Run the program, you will see the following results, because the first need screenshots, the first need to stand in the Kinect front so the posture is not very right, a bit of a setback, but the silhouette of the figure is still displayed, in the depth of data, the more near the Kinect, the darker the farther, the lighter the

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.