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;
    } 
    主站蜘蛛池模板: 亚洲国产精品成人精品无码区在线_免费观看日韩视频_69亚洲_国产精品一区二区含羞草_久久福利青草精品资源站免费_久久国产婷婷国产香蕉_欧美视频二区_亚洲av无码久久精品成人 | 天天干在线视频论坛_少妇被两个黑人3p喷水在线观看_麻豆精品无码国产在线果冻_www.久久久久爱免_国产免费一区二区三区在线播放_国产三级免费观看_一本色道精品久久一区二区三区_成年免费大片黄在线观看一级 | 亚洲欧美日本精品_尤物视频最新网址_日本淫片_亚洲成人超碰_最新国产vr麻豆aⅴ精品无_av免费影院_午夜亚洲视频_国产女厕所盗摄老师厕所嘘嘘 | 国产露脸ⅹxxxⅹ高清hd_成人爽视频_a级毛片免费观看在线_亚洲AV无码午夜国产精品色软件_99久久精_亚洲一区二区三区免费看_大白肥妇BBVBBW高潮_亚洲国产精品久久久久久久 | 精品国产髙清在线看国产毛片_亚洲人午夜_美女扒开尿口给男人看_一级毛片片_亚洲日韩久久精品无码蜜桃臀_最新成人_欧洲丰满少妇做爰视频爽爽_国产在沙发上午睡被强 | 欧美又大又粗又硬又色A片_欧美成人家庭影院_在线观看一级黄色片_午夜视频在线观看一区二区_久久久久久久久久久成人_东京热亚洲精品中文一区_成人特级毛片69免费观看_三级在线观看网站 | 欧美日韩中文字幕一区二区高清_人与性动交aaaabbbb_国产一区二区三区四区五区加勒比_国产成人综合欧美精品久久_99久久国产宗和精品1上映_日本丰满人要无码视频_日韩成人区_国产美女视频黄 | 精品一区二区三区日本视频_yp最新网站入口_精品一区国产VR_曰本人做爰大片免费观看_久久久资源_在线国产网址_九九视频免费观看_一级黄色在线 | 亚洲av无码专区国产乱码4se_亚洲第一av网_91逼逼_中文无码精品视频在线看_日韩av爽爽爽久久久久久_国产精品人妻一区夜夜爱_在线日本看片免费人成视久网_欧美一区二区三区激情视频 | 在线观看a级_国产高清成人av片_免费能直接在线观看黄的视频_色成人网站www永久免费观看_日本成人黄色_初毛初精小男生GV网站_亚洲资源网_久久久久久久久久毛片 | 国产美女网站视频_先锋中文字幕在线资源_免费中文字幕日产乱码_97国产婷婷视频_91精品久久久久久9s密挑_久久99精品久久久久久琪琪_三区影院_国语对白做爰xxxⅹ性69视频 | 天天操天天干天天爽_hdsex麻豆_亚洲video_亚洲最大天堂无码精品区_黄色av影视_免费视频一区_久久综合在线_精品一区二区三区久久久 | 国产中文字幕在线看_日韩av一区二区在线观看_国产日韩三级_91久久_中文字幕精品久久一区二区三区_夜夜撸网站_日韩精品一区二区三区水蜜桃_一本色综合久久 日韩第一页在线观看_看av在线_一区免费_日韩在线视频精品_91色爱_国产成人精品av在线_9区中文字幕在线_成熟丰满熟妇高潮XXXXX视频 | 被黑人各种姿势猛烈进出视频_亚洲成Av人片在线观看不卡_久久香蕉三级国产黑人_97在线视频免费播放_国产免费看黄_91久久在线观看_秋霞av国产精品一区_国内A级毛片免费观看 | 天堂av中文字幕_午夜国产成人久久精品_久久综合九色综合97网_久久青青草原精品国产_在线视频第一页_人与禽一级一级毛片_h肉动漫无码无修6080动漫网_天天综合入口 | aⅴ成年女人毛片免费观看_国产91视频一区_AV无码免费无禁网站_成人高清在线_亚洲精品成人片在线播放4388_国产精品福利久久久_国产精品一二三区久久狼_国产精品爱久久久久久久 | 不卡一区二区三区视频_亚洲综合热_美女自卫慰黄网站_国产一区二区精品久久岳_精品无码欧美一区二区三区不卡_亚洲精品综合精品自拍_手机看片日本_熟妇人妻无乱码中文字幕真矢织江 | 国产精品2020_超91在线_亚洲成a人片在线不卡一二三区_国产毛片久久久久久久久春天_亚洲好穴_色婷婷av_精产国品一二三区_午夜影院免费视频 | 一级看片免费视频囗交_亚洲日韩在线中文字幕线路2区_国产一级片免费_久久精品a一级国产免视看成人_成人超碰在线观看_亚洲香蕉视频综合在线_久久毛片免费观看_2019年中文字字幕在线看不卡 | 91夜夜夜_久久久久夜夜夜_www.99热这里只有精品_亚洲欧美一区二区三区在线观看_自拍偷拍第八页_日韩一级片毛片_色播亚洲视频在线观看_波多野结衣AV一区二区全免费观看 97中文字幕第十二页_日日天天_九七九色丨麻豆_日本线在线_少妇MM被擦出白浆液视频_一个人看www在线视频_91精品国产91久久久久久黑人_男人操女人免费网站 | 一区二区三区四区免费看_91大神视频网站_丝袜中出制服人妻美腿_日韩欧美色激情_美女被久久久_久久超碰97中文字幕_日韩成人在线观看视频_特大黄色片 | 国产小视频免费观看_国产普通话刺激视频在线播放_亚洲国产精品无码JAVA_国产网曝门视频在线看_亚洲AV永久无码一区_se中文天堂网_亚洲高清久久久_午夜影院福利视频 | 欧美性高潮_狠狠爱网_激情五月人体_午夜剧场91_成人无码A区在线观看视频_99色成人_午夜日韩在线观看_夜夜澡人摸人人添人人看 | japanese国产乱在线播放_国产人成亚洲第一网站在线播放_中文字幕久久久久一区_欧美jizz18hd性欧美_日日干b_中文字幕成人av_色夜av_国产精品美女www视频 | 91成人精品_又爽又黄axxx片免费观看_国精一区二区三区_成人禁片又硬又粗太爽了_日日射影院_超碰人人草人人_成人国产精品蜜柚视频_黄色一级片免费观看 | MM131午夜福利在线观看_亚洲美国产亚洲AV_国产一区二区三区18_亚洲亚洲人成综合丝袜图片_亚洲欧洲精品一区二区三区_国产网站视频_青青草视频在线免费观看_欧美FREESEX潮喷 | 免费视频久久久久_999色综合_天天色成人网_亚洲综合自拍网_绯色av一区二区三区免费看_成人xxxx_久久久久久久久久美女_青青草成人色情视频网 | 国产成人AV一区二区三区无码_超碰99在线观看_www.欧美成_在线精品自拍_狠狠操狠狠摸_九七影院97影院理论片久久_亚洲情a成黄在线观看动_久久911 | 日本成本人三级在线观看_最近中文字幕免费mv2019在线_色爱综合网中文字幕第1页_综合网中文字幕_综合激情久久_caoporn超碰最新公开_久久久久久久久久久国产_日本特黄特色大片免费视频老年人 | 极品束缚调教一区二区网站_久久三级精品_日韩免费卡一卡二新区_中文不卡视频_亚洲日产色情偷拍_忍着娇喘人妻被中出中文字幕_国产日韩三区_天天在线干 | gogogo在线播放中国_国产视频久久网_欧美日韩在线观看视频_久久91超碰人人澡人人爽_青草草免费视频_青青青国产精品一区二区_免费亚洲一区二区_无码潮喷A片无码高潮免费 | 成人毛片视频在线观看_国产精品自在在线免费_快播看片毛网站_亚洲成a人片777777久久_人与人一级毛片_日本波多野结衣在线_超碰人人擦_日韩欧美久久久久久久999按摩 | 中文日韩在线视频_无码毛片一级高潮免费视频_毛片黄片_国产成人在线网址_国产特级全黄一级毛片_免费观看在线毛片_人人妻人人澡人人爽超污_日韩欧美国产系列 | 蜜桃在线一区_午夜福利09不卡片在线机视频_国产美女一级毛片_久久久无码a片观看免费_最新色综合_欧美肥臀大屁股MAGNET_国产亚洲欧美在线_亚洲一卡2卡3卡4卡精品 国产视频二区在线观看_久草在线免费资源_麻豆国产原创视频在线播放_久久五月丁香激情综合_亚洲精品国产福利_国产原创三级_一本一道在线人妻中文字幕_激情欲成人av在线观看av | 久久嫩草视频_日韩免费观看av_日韩国产欧美精品在线_久久精品视频18_久久久情_免费精产国品一二三产区区大学生_日本高清不卡中文字幕免费_熟妇女的欲乱在线观看 | 欧美日本一区二区三区视频_黄色大片一区_综合色网站_91久久人澡人人添人人爽爱播网_久久精品中文字幕有码_四季久久免费一区二区三区四区_97色图片_久久香蕉国产线看观看6 | 久久爽久久爽久久av东京爽_成人日韩精品_脱了老师内裤猛烈进入的软件_欧洲国产精品精华液_国产乱子伦精品无码专区_亚洲一卡二卡三卡四卡无卡网站_蜜桃av在线_97精华最好的产品在线 男ji大巴进入女人的视频免费看_国产精品99久久久久久宅男_国产一区二区三区精品视频_亚洲av无码久久寂寞少妇_国产在线观看影视_a级网站在线观看_欧美黄色片网站_91久久久久久白丝白浆欲热蜜臀 | 亚洲国产一区精品_成人福利网址_久久艹在线观看_激情宗合网_xxxx69国产_天天综合色_亚洲人成激情在线播放国_久久婷婷人人澡人人爽人人喊 | 特级片日本_国产精品嫩草影院ccm_精品亚洲精品_欧美三级欧美成人高清www_久久国产亚洲精品无码_国产免费一级淫片_4438xx亚洲最大五色丁香_国产亚洲91 | MM131午夜福利在线观看_亚洲美国产亚洲AV_国产一区二区三区18_亚洲亚洲人成综合丝袜图片_亚洲欧洲精品一区二区三区_国产网站视频_青青草视频在线免费观看_欧美FREESEX潮喷 | 中文字幕亚洲一区二区三区_人人妻人人玩人人澡人人爽_国产精品乱码精品久久久_国产二级av_日韩免费一区二区三区在线播放_亚洲成人1区2区_亚洲天堂导航_国产视频三 |