99国产欧美另娄久久久精品_国内自拍农村少妇在线观看_久久亚洲道色宗和久久_日本aⅴ大伊香蕉精品视频_亚洲国产欧美日韩欧美特级_日本视频免费在线观看

  • realsense顯示限定范圍內(nèi)的圖像物體

    2019/11/11??????點(diǎn)擊:

    REALSENSE不同于普通RGB相機(jī)的是,普通相機(jī)只可以獲得圖像的RGB顏色信息,REALSENSE可以獲得像素的深度信息。RGB相機(jī)只能通過幀間差分、特定顏色提取、基于混合高斯模型去除背景等方法,做到前景背景分離,而通過REALSENSE可以根據(jù)像素的深度信息我們可以很方便實(shí)現(xiàn)畫面摳圖,即設(shè)置一定的深度范圍, 只顯示在此深度范圍內(nèi)的像素,那我們就可以通過Z方向的距離來剔除背景了。以下是實(shí)現(xiàn)摳圖功能的代碼:

    // License: Apache 2.0. See LICENSE file in root directory.
    // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
     
    #include 
    #include "../example.hpp"
    #include 
    #include "imgui_impl_glfw.h"
     
    #include#include#include#include#includevoid render_slider(rect location, float& clipping_dist);
    void remove_background(rs2::video_frame& other, const rs2::depth_frame& depth_frame, float depth_scale, float clipping_dist);
    float get_depth_scale(rs2::device dev);
    rs2_stream find_stream_to_align(const std::vector& streams);
    bool profile_changed(const std::vector& current, const std::vector& prev);
     
    int main(int argc, char * argv[]) try
    {
        // Create and initialize GUI related objects
        window app(1280, 720, "CPP - Align Example"); // Simple window handling
        ImGui_ImplGlfw_Init(app, false);      // ImGui library intializition
        rs2::colorizer c;                          // Helper to colorize depth images
        texture renderer;                     // Helper for renderig images
     
        // Create a pipeline to easily configure and start the camera
        rs2::pipeline pipe;
        //Calling pipeline's start() without any additional parameters will start the first device
        // with its default streams.
        //The start function returns the pipeline profile which the pipeline used to start the device
        rs2::pipeline_profile profile = pipe.start();
     
        // Each depth camera might have different units for depth pixels, so we get it here
        // Using the pipeline's profile, we can retrieve the device that the pipeline uses
        float depth_scale = get_depth_scale(profile.get_device());
     
        //Pipeline could choose a device that does not have a color stream
        //If there is no color stream, choose to align depth to another stream
        rs2_stream align_to = find_stream_to_align(profile.get_streams());
     
        // Create a rs2::align object.
        // rs2::align allows us to perform alignment of depth frames to others frames
        //The "align_to" is the stream type to which we plan to align depth frames.
        rs2::align align(align_to);
     
        // Define a variable for controlling the distance to clip
        float depth_clipping_distance = 1.f;
     
        while (app) // Application still alive?
        {
            // Using the align object, we block the application until a frameset is available
            rs2::frameset frameset = pipe.wait_for_frames();
     
            // rs2::pipeline::wait_for_frames() can replace the device it uses in case of device error or disconnection.
            // Since rs2::align is aligning depth to some other stream, we need to make sure that the stream was not changed
            //  after the call to wait_for_frames();
            if (profile_changed(pipe.get_active_profile().get_streams(), profile.get_streams()))
            {
                //If the profile was changed, update the align object, and also get the new device's depth scale
                profile = pipe.get_active_profile();
                align_to = find_stream_to_align(profile.get_streams());
                align = rs2::align(align_to);
                depth_scale = get_depth_scale(profile.get_device());
            }
     
            //Get processed aligned frame
            auto processed = align.process(frameset);
     
            // Trying to get both other and aligned depth frames
            rs2::video_frame other_frame = processed.first(align_to);
            rs2::depth_frame aligned_depth_frame = processed.get_depth_frame();
     
            //If one of them is unavailable, continue iteration
            if (!aligned_depth_frame || !other_frame)
            {
                continue;
            }
            // Passing both frames to remove_background so it will "strip" the background
            // NOTE: in this example, we alter the buffer of the other frame, instead of copying it and altering the copy
            //       This behavior is not recommended in real application since the other frame could be used elsewhere
            remove_background(other_frame, aligned_depth_frame, depth_scale, depth_clipping_distance);
     
            // Taking dimensions of the window for rendering purposes
            float w = static_cast(app.width());
            float h = static_cast(app.height());
     
            // At this point, "other_frame" is an altered frame, stripped form its background
            // Calculating the position to place the frame in the window
            rect altered_other_frame_rect{ 0, 0, w, h };
            altered_other_frame_rect = altered_other_frame_rect.adjust_ratio({ static_cast(other_frame.get_width()),static_cast(other_frame.get_height()) });
     
            // Render aligned image
            renderer.render(other_frame, altered_other_frame_rect);
     
            // The example also renders the depth frame, as a picture-in-picture
            // Calculating the position to place the depth frame in the window
            rect pip_stream{ 0, 0, w / 5, h / 5 };
            pip_stream = pip_stream.adjust_ratio({ static_cast(aligned_depth_frame.get_width()),static_cast(aligned_depth_frame.get_height()) });
            pip_stream.x = altered_other_frame_rect.x + altered_other_frame_rect.w - pip_stream.w - (std::max(w, h) / 25);
            pip_stream.y = altered_other_frame_rect.y + altered_other_frame_rect.h - pip_stream.h - (std::max(w, h) / 25);
     
            // Render depth (as picture in pipcture)
            renderer.upload(c.process(aligned_depth_frame));
            renderer.show(pip_stream);
     
            // Using ImGui library to provide a slide controller to select the depth clipping distance
            ImGui_ImplGlfw_NewFrame(1);
            render_slider({ 5.f, 0, w, h }, depth_clipping_distance);
            ImGui::Render();
     
        }
        return EXIT_SUCCESS;
    }
    catch (const rs2::error & e)
    {
        std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n    " << e.what() << std::endl;
        return EXIT_FAILURE;
    }
    catch (const std::exception & e)
    {
        std::cerr << e.what() << std::endl;
        return EXIT_FAILURE;
    }
     
    float get_depth_scale(rs2::device dev)
    {
        // Go over the device's sensors
        for (rs2::sensor& sensor : dev.query_sensors())
        {
            // Check if the sensor if a depth sensor
            if (rs2::depth_sensor dpt = sensor.as())
            {
                return dpt.get_depth_scale();
            }
        }
        throw std::runtime_error("Device does not have a depth sensor");
    }
     
    void render_slider(rect location, float& clipping_dist)
    {
        // Some trickery to display the control nicely
        static const int flags = ImGuiWindowFlags_NoCollapse
            | ImGuiWindowFlags_NoScrollbar
            | ImGuiWindowFlags_NoSavedSettings
            | ImGuiWindowFlags_NoTitleBar
            | ImGuiWindowFlags_NoResize
            | ImGuiWindowFlags_NoMove;
        const int pixels_to_buttom_of_stream_text = 25;
        const float slider_window_width = 30;
     
        ImGui::SetNextWindowPos({ location.x, location.y + pixels_to_buttom_of_stream_text });
        ImGui::SetNextWindowSize({ slider_window_width + 20, location.h - (pixels_to_buttom_of_stream_text * 2) });
     
        //Render the vertical slider
        ImGui::Begin("slider", nullptr, flags);
        ImGui::PushStyleColor(ImGuiCol_FrameBg, ImColor(215.f / 255, 215.0f / 255, 215.0f / 255));
        ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImColor(215.f / 255, 215.0f / 255, 215.0f / 255));
        ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImColor(215.f / 255, 215.0f / 255, 215.0f / 255));
        auto slider_size = ImVec2(slider_window_width / 2, location.h - (pixels_to_buttom_of_stream_text * 2) - 20);
        ImGui::VSliderFloat("", slider_size, &clipping_dist, 0.0f, 6.0f, "", 1.0f, true);
        if (ImGui::IsItemHovered())
            ImGui::SetTooltip("Depth Clipping Distance: %.3f", clipping_dist);
        ImGui::PopStyleColor(3);
     
        //Display bars next to slider
        float bars_dist = (slider_size.y / 6.0f);
        for (int i = 0; i <= 6; i++)
        {
            ImGui::SetCursorPos({ slider_size.x, i * bars_dist });
            std::string bar_text = "- " + std::to_string(6-i) + "m";
            ImGui::Text("%s", bar_text.c_str());
        }
        ImGui::End();
    }
     
    void remove_background(rs2::video_frame& other_frame, const rs2::depth_frame& depth_frame, float depth_scale, float clipping_dist)
    {
        const uint16_t* p_depth_frame = reinterpret_cast(depth_frame.get_data());
        uint8_t* p_other_frame = reinterpret_cast(const_cast(other_frame.get_data()));
     
        int width = other_frame.get_width();
        int height = other_frame.get_height();
        int other_bpp = other_frame.get_bytes_per_pixel();
     
        #pragma omp parallel for schedule(dynamic) //Using OpenMP to try to parallelise the loop
        for (int y = 0; y < height; y++)
        {
            auto depth_pixel_index = y * width;
            for (int x = 0; x < width; x++, ++depth_pixel_index)
            {
                // Get the depth value of the current pixel
                auto pixels_distance = depth_scale * p_depth_frame[depth_pixel_index];
     
                // Check if the depth value is invalid (<=0) or greater than the threashold
                if (pixels_distance <= 0.f || pixels_distance > clipping_dist)
                {
                    // Calculate the offset in other frame's buffer to current pixel
                    auto offset = depth_pixel_index * other_bpp;
     
                    // Set pixel to "background" color (0x999999)
                    std::memset(&p_other_frame[offset], 0x99, other_bpp);
                }
            }
        }
    }
     
    rs2_stream find_stream_to_align(const std::vector& streams)
    {
        //Given a vector of streams, we try to find a depth stream and another stream to align depth with.
        //We prioritize color streams to make the view look better.
        //If color is not available, we take another stream that (other than depth)
        rs2_stream align_to = RS2_STREAM_ANY;
        bool depth_stream_found = false;
        bool color_stream_found = false;
        for (rs2::stream_profile sp : streams)
        {
            rs2_stream profile_stream = sp.stream_type();
            if (profile_stream != RS2_STREAM_DEPTH)
            {
                if (!color_stream_found)         //Prefer color
                    align_to = profile_stream;
     
                if (profile_stream == RS2_STREAM_COLOR)
                {
                    color_stream_found = true;
                }
            }
            else
            {
                depth_stream_found = true;
            }
        }
     
        if(!depth_stream_found)
            throw std::runtime_error("No Depth stream available");
     
        if (align_to == RS2_STREAM_ANY)
            throw std::runtime_error("No stream found to align with Depth");
     
        return align_to;
    }
     
    bool profile_changed(const std::vector& current, const std::vector& prev)
    {
        for (auto&& sp : prev)
        {
            //If previous profile is in current (maybe just added another)
            auto itr = std::find_if(std::begin(current), std::end(current), [&sp](const rs2::stream_profile& current_sp) { return sp.unique_id() == current_sp.unique_id(); });
            if (itr == std::end(current)) //If it previous stream wasn't found in current
            {
                return true;
            }
        }
        return false;
    } 
    主站蜘蛛池模板: 四虎影院观看_日本久久高清视频_曰韩黄色片_欧美性受xxxx黑人x丫x性爽_伊人久久天堂_特级黄色毛片_国产丰满大波大屁股熟女_性受xxxx黑人xyx蜜桃 | 国产精品人妖_亚洲永久经典_久久久精品久久日韩一区综合_gogogo免费高清看中国_国产真实生活伦对白_日韩欧美资源_九九久久国产_国产精品无码日韩欧 东京复仇者第三季天竺篇在线观看_99手机国产精品_国产网红福利视频一区二区_色wwwwww_五月香蕉网_天天操天天射综合_在线不卡中文_av观看免费 | 日韩免费成人在线_国产成人无码一二三区视频_妖精视频www网站入口_永久免费看毛片_91精品视频免费看_一区二区三区香蕉视频_一本大道东京热无码_国产99久久亚洲综合精品西瓜tv | 免费毛片视频播放_成人欧美一区二区三区A片_欧美性大战xxxxx久久久_国产精品久线观看视频_69av一区_亚洲精品视频久久久_欧美国产日韩在线观看成人_9l视频自拍九色9l视频成人 | 中文WWW新版资源在线_国产公开久久人人97超碰_国产一区二区成人_日日爱699_国产资源精品在线观看_在线不卡aⅴ片免费观看_宝贝小嫩嫩好紧好爽H视频_中国a一片一级一片 | 欧美色交_免费看成人A片无码照片_中文永久有效幕中文永久_涩涩天堂_日本一区二区不卡在线_噼里啪啦2在线观看免费_日本xxxwww免费视频_国产呦在线沙发 | 嗯嗯嗯亚洲精品国产精品一区_欧美日韩精选_又黄又粗暴的120秒免费GIF视频_年轻的朋友3中文_国产一女三男3p免费视频_亚洲人亚洲人色久_免费在线成人_日韩高清三区 | 國產精品倫一區二區三級視頻_唐人街探案1免费播放_国产精品人妻99一区二区_在线精品国产一区二区三区_国产精品乱人伦_爽到憋不住潮喷大喷水视频在线_人妻激情偷乱视频一区二区三区_国产51人人成人人人人爽色哟哟 | 无码熟妇人妻AV在线网站_美女视频免费是黄的网站高清_91av国产在线视频_亚洲成色在线综合网站_久久久天堂_日产精品一卡2卡三卡四乱码_一区二区三区无码按摩精油_超碰色偷偷男人的天堂 | 精品久久久久久中文字幕2017_免费在线看黄色_91福利网站在线观看_日日爽天天_日韩一区精品_国产超碰人人爽人人做AV_色呦呦久久久_中日韩一级片 | 里番精品3d一二三区_日本草逼_亚洲AV无码专区日韩乱码_日韩视频中文字幕精品偷拍_日韩精品亚洲一区_91国内精品白嫩初高生_中文字幕免费久久_99久久久久久久 | 天堂网在线观看视频_欧美乱妇日本无乱码特黄大片_免费无码专区在线视频_国产一片姪乱洗澡_久久久久久久av麻豆果冻_不卡在线一区2区三区_91超在线_国产精品女人久久 | 69ww免费视频播放_午夜影院伦理片_久久无码人妻一区二区三区_国产成人亚洲精品无码Av大片_国产在线欧美_重生男人_精品福利一区二区三区_www.久草 | 看免费的黄色大片_91精品一区二区在线观看_日韩入口_亚洲欧美日韩中文视频_夜夜操com_爱99久久_仙踪林久久久久久久999_一二三四视频中文字幕在线看 | 人人妻人人妻人人片av_精品深夜福利视频_日韩一区二区在线观看_少妇高潮av久久久久久_一区二区的视频_换着玩人妻中文字幕_日本激情视频在线播放_www.99视频 | 顶级少妇做爰高潮_91久久夜色精品国产按摩_色综合精品无码一区二区三区_国产精选一级毛片_亚洲中文有码字幕日本第一页_九九热在线观看_变态孕交videosgratis孕妇_日本少妇久久久 | 精品人妻无码一区二区三区牛牛_中文字幕无码乱码人妻系列蜜桃_中文字幕亚洲码在线观看_欧美大片首页欧美大片首页_亚洲国产精品午夜在线观看_成人免费xxx在线观看_全球AV集中精品导航福利_国产午夜福利久久网 | 芭乐草永久视频在线观看_h网站久久久_亚洲激情小视频_日本一本一道高清无_女人被爽到呻吟GIF动态图_男女插插免费视频_天天爱天天射天天干_国产免费久久久久 | 野花社区免费观看视频高清_国产毛片18片毛一级特黄日韩a_aa视频免费看_国产午夜一级_91大神一区二区三区在线观看_亚洲av成人永久无在线观看_中文字幕av免费在线_新超碰97 | 粉嫩老牛aⅴ一区二区三区_a级毛片免费网站_粉嫩av一区二区三区免费观看_俄罗斯粗大猛烈18P_九色国产在线_亚洲欧洲天堂_一区二区三区四区在线视频_国产成人久久av免费高清蜜臀 | 精品视频—区二区三区免费_韩国久久久久_欧美在线一级_在办公室把护士给爽了动态图_国内一区二区视频_久久久久中文_亚洲成在人线在线播放_国产剧情乱偷 | 国产黄频_电家庭影院午夜_久久精品在线_成人亚洲欧美一区二区三区_一区二区在线国产_超碰97免费观看_五月婷激情_欧美激情五月 | 成人性生活免费看_最新综合精品亚洲网址_精品国产福利在线观看_天干天干夜啦天干天干国产_亚洲欧美日韩国产综合在线_久久久久国产一区二区_在线网站_三级免费黄 | 国产三级久久久精品麻豆三级_黄色成年人国语版在线观看_国产gv在线观看受被做哭_伦理片一级片_免费三区_狠狠操导航_久久精品对白_操操综合网 | 成人做爰69片免网站_女人高潮潮叫免费视频_97色se_中日韩在线观看_午夜熟女插插XX免费视频_女人被添全过程A片久久AV_国产精品精品国产_国产毛片在线 | 国内揄拍国内精品对白_中午字幕无线码一区2020_4虎av_人妻聚色窝窝人体WWW一区_夜色亚洲_免费在线激情视频_91国色_98色花堂论坛最新地址 | www.97国产_在线成人毛片_欧美肥婆丰满bbw_18禁勿入午夜网站入口_欧美一级一区二区三区_wwwxx黄色_午夜精品免费看_岛国一区二区三区 | 国产精品国三级国产av_亚洲AV人无码激艳猛片服务器_欧洲中文字幕_好大好硬好爽18禁视频免费_yjizz视频_久中文字幕_搜查官中文字幕一区二区_国产激情无码一区二区三区 | 91婷婷_97在线视频人妻无码_国产成人AV无码精品_欧美大片久久国产欧美日韩精品_亚洲人a成www在线影院_9l国产精品久久久久麻豆_亚洲国产日韩欧美视频二区_中文字幕有码无码人妻在线 | 二区三区在线_国产好吊视频在线观看_91丨九色丨黑人外教_欧美黄色网络_久久性网站_精品国产京东免费人成网站_美脚丝袜一区二区三区在线观看_91麻豆国产福利在线观看宅福利 | 最新黄色在线_av网址免费观看_国内大量揄拍人妻精品視頻_一级做a爰片久久免费观看_国产亚洲午夜_亚洲视频你懂的_人人插97_久久国产精品久久精品国产 | 黄色一级大片在线免费看产_国产未成女年一区二区_在线无限看蘑菇视频_久草视频中文在线_超碰99人人_国产亚洲综合专区在线在线观看_国产AV成人无码精品网站_欧美亚洲91 | 久久久久久久久无码精品亚洲日韩_伊人狠狠色_伊人久久一区二区三区无码_狠狠躁天天躁夜夜添人人_在线www免费观看视频_第一区在线_天天搞夜夜_91久久99久久91熟女精品 | 中文日韩在线视频_无码毛片一级高潮免费视频_毛片黄片_国产成人在线网址_国产特级全黄一级毛片_免费观看在线毛片_人人妻人人澡人人爽超污_日韩欧美国产系列 | 欧美成人免费全部观看天天性色_免费视频xxx_在线观看日韩中文字幕_自拍偷拍av_偷摄私密养生馆少妇推油_免费一级a毛片免费观看_羞羞答答xxdd在线网站_成人免费视频网站在线看 | 看免费的黄色大片_91精品一区二区在线观看_日韩入口_亚洲欧美日韩中文视频_夜夜操com_爱99久久_仙踪林久久久久久久999_一二三四视频中文字幕在线看 | 中国美女a级毛片_最新看片国产精品免费在线_国产女色_夜鲁鲁鲁夜夜综合视频欧美_中文字幕欧美日韩一区_大黄网站免费在线观看_久久99精品久久久97夜夜嗨_99久久精品免费播放 | 野狼第一精品社区_亚洲精品视频在线免费播放_字幕日韩视频一区二区_国产99一区二区_性中国熟妇videofreesex_麻豆入口国产精品_视频一区二区国产无限在线观看_在线看国产视频 | 国产国语性生话播放_国一级片_成人拍拍视频_色婷婷综合久久久久中文图片_av在线亚洲男人的天堂_在线观看麻豆国产成人AV在线播放_女人一级片_一区一区视频 www视频在线观看免费_五月天狠狠干_精精国产视频_黄色一二三区_精品视频国产_操人网址_成年人视频在线免费看_狠狠操操 | 国产美女网站视频_先锋中文字幕在线资源_免费中文字幕日产乱码_97国产婷婷视频_91精品久久久久久9s密挑_久久99精品久久久久久琪琪_三区影院_国语对白做爰xxxⅹ性69视频 | 亚洲综合精品在线_亚洲欧洲精品专线_噼里啪啦免费观看高清动漫_手机av免费在线_日本黄色片日本黄色片_chinese国产avvideoxxxx实拍_成人片免费网站_福利中文字幕 |