亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Kinect SDK C++ - 2. Kinect Depth Data

系統 3059 0
Today we will learn how to get depth data from a kinect and what the format of the data is


kinect code


kinect Initialization


To get the depth data from the kinect, simply change the argument to NuiImageStreaOpen().


The First argument is now NUI_IMAGE_TYPE_DEPATH,telling the Kinect that wo now want depath images


instead of RGB iamges.(For clarity we also changed the name of the handle to reflect this)


We also should enable the Near Mode.let the kinect to be more sensitive to closer objects(say from 50cm to


200cm),otherwise,from 80 to 400cm.


To done that,passing flag NUI_IMAGE_FLAG_ENABLE_NEAR_MODE as the third argument

      <span style="font-size:12px;"><span style="font-size:10px;">// NEW VARIABLE
HANDLE depthStream;

bool initKinect() {
    // Get a working kinect sensor
    int numSensors;
    if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false;
    if (NuiCreateSensorByIndex(0, &sensor) < 0) return false;

    // Initialize sensor
    sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR);

        // --------------- START CHANGED CODE -----------------
    sensor->NuiImageStreamOpen(
        NUI_IMAGE_TYPE_DEPTH,                     // Depth camera or rgb camera?
      

NUI_IMAGE_RESOLUTION_640x480, // Image resolution NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE, // Image stream flags, e.g. near mode 2, // Number of frames to buffer NULL, // Event handle &depthStream); // --------------- END CHANGED CODE ----------------- return sensor; }</span></span>



For more information about the near mode,please prefer to offficial blog.




getting a depth frame from the kinect


the display of the dapth image from the kinect in grayscale.Each pixel will just be the pixel's distance


from the kinect(in millimeters)mod 256.


note the NuiDepthPixelToDepth fuction,calling this function returns the depth in millimeters at that pixel.


The depth data is 16 bits,so we use a USHORT to read it in.

      <span style="font-size:12px;"><span style="font-size:10px;">      const USHORT* curr = (const USHORT*) LockedRect.pBits;
        const USHORT* dataEnd = curr + (width*height);

        while (curr < dataEnd) {
            // Get depth in millimeters
            USHORT depth = NuiDepthPixelToDepth(*curr++);

            // Draw a grayscale image of the depth:
            // B,G,R are all set to depth%256, alpha set to 1.
            for (int i = 0; i < 3; ++i)
                *dest++ = (BYTE) depth%256;
            *dest++ = 0xff;
        }
</span></span>
    


that's all the Kinect code! The rest is just how to get it to display.

版權聲明:本文博客原創文章。博客,未經同意,不得轉載。

Kinect SDK C++ - 2. Kinect Depth Data


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 99热国产这里只有精品免费 | 99久久综合狠狠综合久久 | 91久久精品国产91性色tv | 手机在线国产精品 | 国产视频一二 | 成年女人免费看一级人体片 | 国产成人精品曰本亚洲77美色 | 久久国产免费一区二区三区 | 日韩女人毛片在线播放 | 成人亚洲欧美日韩中文字幕 | 国内精品自在自线香蕉 | 国产福利视频在线观看 | 天码毛片一区二区三区入口 | 久久久久久综合成人精品 | 国产伦乱| 热热涩热热狠狠色香蕉综合 | 四虎精品福利视频精品 | 欧美成人一级毛片 | 午夜小视频网站 | 日韩午夜网站 | 九九热在线精品 | 免费观看四虎精品国产永久 | 夜夜躁日日躁狠狠久久 | 免费视频一区 | 亚洲网站在线看 | 日韩中文字幕在线有码视频网 | 日本天天谢天天要天天爱 | 露脸真实国产精品自在 | 99成人国产精品视频 | 国产高清美女一级a毛片久久w | 久草在线看片 | 免费午夜在线视频 | 免费a级网站 | 免费日韩毛片 | 羞羞网站在线播放 | 久久久久免费精品国产 | 欧美日韩不卡在线 | 国产成人精品免费视频网页大全 | 日本永久视频 | 免费观看一级特黄三大片视频 | 精品免费久久久久国产一区 |