Kinect for Windows SDK v2.0 Development Notes (iii) depth frame and IR frame acquisition

Source: Internet
Author: User

(reprint please indicate the source)

Using the SDK: Kinect for Windows SDK v2.0 Public Preview

I'll tell you this. Acquisition of depth frame and infrared frame acquisition


The Kinect's infrared laser device is able to capture the depth and infrared image of the space, because the last example will be very simple.


The depth value, Kinect uses a 16-bit unsigned integer to represent the depth frame with a "deep element" (depth elements, extended by the image element), in millimeters.

The current effective distance is (500, 4500) that is half a meter to four meters and a half. So how to visualize it, there are many algorithms for depth value visualization on the Web,

Here, let's just think of a simple one:




Distance 0: Distance 0 represents invalid depth value, we paint it red.


Distance [1, 500), the distance is unreliable, we follow the distance, besmear different shades of green.

It is roughly 1 coated with RGB (0,129, 0), 2 coated (0, 130, 0), coated (0, 255, 0), and then back to the starting point (0, 128, 0) ... Repeated

Pseudo code is roughly:

RGB (0, (get_depth () mod 128) +128, 0)

Of course, the theory of bit arithmetic is faster, so it can be changed to

RGB (0, (Get_depth () & 0x7F) +128, 0)


Distance [4500, +∞), according to the above algorithm, coated [128, 255] of the blue, namely:

RGB (0, 0, (get_depth () mod 128) +128)


The distance [500, 4500), according to the above algorithm, coated [0, 255] of the gray, that is:

RGB (Get_depth () & 0xFF, Get_depth () & 0xFF, Get_depth () & 0xFF)


That's pretty much it:

        Auto Prgbxbuffer = M_imagarenderer.getbuffer (); Processing algorithm//0 red (0, min) 128~255 Progressive Green is greater than Max's 128~255 blue between the 0~255 grey//depth gradient for (UINT i = 0; I & Lt Nbuffersize;
                ++i) {if (!pbuffer[i]) {prgbxbuffer[i].rgbred = 0xFF;
                Prgbxbuffer[i].rgbgreen = 0;
                Prgbxbuffer[i].rgbblue = 0;
            prgbxbuffer[i].rgbreserved = 0xFF;
                else if (Pbuffer[i] < depth_min_reliable_distance) {prgbxbuffer[i].rgbred = 0;
                Prgbxbuffer[i].rgbgreen = Pbuffer[i] & 0x7F + 0x80;
                Prgbxbuffer[i].rgbblue = 0;
            prgbxbuffer[i].rgbreserved = 0xFF; else if (Pbuffer[i] > depth_max_reliable_distance) {prgbxbuffer[i].rgbblue = Pbuffer[i] & Amp
                0x7F + 0x80;
                Prgbxbuffer[i].rgbgreen = 0;
                prgbxbuffer[i].rgbred = 0; prgbxbuffer[i].rgbreserved = 0xFF;
                } else{Prgbxbuffer[i].rgbblue = pbuffer[i] & 0xFF;
                Prgbxbuffer[i].rgbgreen = Prgbxbuffer[i].rgbblue;
                prgbxbuffer[i].rgbred = Prgbxbuffer[i].rgbblue;
            prgbxbuffer[i].rgbreserved = 0xFF; }
        }

As to how to get the depth of the code to write. In fact.... You can replace all the "Colorframe" in the previous section with "Depthframe",

There are some subtle differences (such as to obtain effective distance ah, etc., are based on gourd painting), Microsoft lazy, we also lazy


We can combine examples to see

Effect:


"Little hero. I see you yintang black, it seems to have the disaster of blood light ah. "

"Nonsense, did not see my side a red." "


See from the image, incredibly does not have the green, Microsoft is lazy.

There's no blue. Micro... Well, this is my dorm room is too small.

Also noteworthy is the red around the object, indicating that the laser incident angle is too large,

Almost no light ever bounces back, so it's ineffective.


Download Address: Click here



The second part, the acquisition of infrared data.

The infrared IR data obtained from Kinect is also a 16-bit unsigned integer that directly represents the gray value of the point.

If the same as the generation, the 16-bit only high 10-bit is valid, 10-bit grayscale, only the advanced display to display,

Our general display can only show 256 levels, 8-bit grayscale, so we should discard 2 of them.

Would you like to abandon 2 or lower 2? Please think about it.





Nature is high 2 bits ... Can't give up, after all, compared to throw away 10,000 pieces, I still willing to throw away 1 dollars.

Well, ditto, Microsoft has the interface design similar, the above project code "Depthframe" changed to "Infraredframe" estimate almost,

Please see the attached example, let's see the effect:


Example Download Address: Click here

From the above, because the distance is far (2 meters away), cause I can hardly see. To cope with this situation, Microsoft has provided a set of

To ilongexposureinfrared the beginning of the object, interested friends can go to see, here is not much to say.

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.