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;
    } 
    主站蜘蛛池模板: 久草视频手机在线观看_高清一区二区三区四区_999ZYZ玖玖资源站永久_99热精品在线播放_国产老熟妇精品观看_欧美日韩成人网_天天摸日日添狠狠添婷婷_激情av中文字幕 | 成人无码午夜在线观看_福利视频三区_91超碰caoporm国产香蕉_亚洲精品综合久久中文字幕_国产农村妇女一区二区三区_91福利在线观看_美女被按在床上_亚州一区 | 久色视频_a视频免费看_强插女教师AV在线_亚洲午夜免费福利视频_日韩第一精品_蜜桃久久精品一区二区_经典久久久_特黄A片女人亚洲一区小说 | 欧美午夜寂寞影院_91精品欧美一区综合在线观看_中文字幕乱码亚洲无线码按摩_免费看片免费播放国产_精品视频二区_韩日a级片_日本XXXX色视频在线观看免费,_亚洲成av人影片在线观看 | 久久久免费看视频_99爱国产_午夜免费_brazzershd欧美情趣丝袜_日本一级黄色大片_成人性生交大片免费看中国A片_久久婷婷国产综合精品_精品国产一区二区三区av性色 | 日韩一二三区在线观看_肥白大屁股BBWBBWHD_久久国产福利国产秒拍_日本XXXX色视频在线播放_久久久久久久久久97_密桃视频成人免费_大白天情侣对白肉麻的很_免费播放一级毛片 | 免费a在线看_黑人30厘米少妇高潮全部进入_久久国产午夜精品理论片_国产精品视频1区_夜夜爱爱_麻豆免费进入_亚洲色大成网站WWW永久_亚洲第一区精品 | 黄色a级一级片_国内精品久久久久久99蜜桃_日产精品久久久久久久蜜臀_国产福利男女XX00视频_韩国美女一区二区三区_午夜观看视频_久久综合久久自在自线精品自_国产一级特黄a大片免费 | 国产精品3_九一视频国产_国产免费极品av吧在线观看_999久久免费精品国产_国产亚洲综合网曝门系列_青青草最新视频_久久久久久久久久久妇女_亚洲最大中文字幕无码网站 | www久_无码国产福利av私拍_无码中文字幕日韩专区_亚洲中又文字幕精品av_精品国产欧美_在线观看免费视频91_久久婷婷日日澡天天添_九色91国产 | 麻豆天美蜜桃91_www在线免费观看欧美黄_91女神在线观看_特一级黄色片_亚洲第三色_人人爽久久久噜人人看_99网站_97色伦图片97综合影院 | 国产对白女主播勾搭野战在线_69久久无码一区人妻A片_日本久久艹_国产胸大一区二区三区粉嫩思欲_国产高清久久久久久_成人免费网站_超碰在线免费播放_日韩免费视频在线观看 | 天天想夜夜操_后入内射欧美99二区视频_国产自一区_日本BBW丰满牲交片_1000部又爽又黄无遮挡的视频_毛片链接_国产精品国精无码A片AV_成人av集中营 | 天堂网www天堂在线资源_2020日日夜夜噜噜噜com_18禁成年免费无码国产_好色一区_91freehdxxxx欧美_4p在线观看_可以免费观看的av_国产热A欧美热A在线视频 | 精品国产99久久久久久_偷窥目拍性综合图区_亚洲黄色小说网_国产一区成人在线_久久午夜无码免费_偷偷草网站_久久在线视频免费观看_国产精品乱战久久久 | 麻豆蜜桃_欧美黑人巨大久久久精品一区小蓝_久久青草av_成年人xxxx_狠狠躁夜夜躁人人爽天天开心婷婷_午夜一区在线观看_青草网址_小视频在线看 | 久久福利一区二区_91av网址_久草午夜_色综合伊人丁香五月桃花婷婷_日本人丰满XXXXHD_一本色道久久亚洲综合精品蜜桃_成人国产三级_欧美黑人牲交videossexeso | 亚洲在线免费观看视频_野花社区观看在线www官网_热久久国产_亚洲国产精品无码观看久久_两个人的WWW免费视频_超乳爆乳上司在线观看_亚洲天堂一区在线观看_久久天天躁狠狠躁夜夜96流白浆 | 一二三国产视频_91九色网址_动漫精品h_日韩不卡1卡2卡三卡免费网站2021_扒开双腿猛进入喷水高潮叫声_a一级黄色毛片_国产爽视频_久操精品在线观看 | 久久久久久色_国产成人亚洲第一_91香蕉亚洲精品_欧美日韩国产中文字幕_天堂资源在线官网_夜色福利院在线观看免费_国产成网站18禁止久久影院_色青青草原桃花久久综合 | 蜜臀久久精品久久久久久酒店?_日韩成人av影院_国产办公室秘书无码精品_中文字幕91爱爱_人妻丝袜AV中文系列先锋影音_欧美一区三区_国产精品美女久久久网站_无码精品一区二区三区四区爱奇艺 | 人妻无码αv中文字幕久久琪琪布_正在播放亚洲一区_日韩欧美在_狠狠色噜噜狠狠狠777米奇小说_婷婷综合基地俺也来_成人依依网_久久久这里有精品999_国产精品久久久久一区二区三区 | 国产成人精品怡红院在线观看_欧美精品欧美精品系列c_国产精品馆_97天天综合网_久久av福利_四虎中文_日本老师xxxx18学生_中国vodafonewifi精品网站 | 欧美日产国产成人免费图片_日日拍夜夜嗷嗷叫国产_日韩—二三区免费观看av_最好看免费观看高清视频大全国语_91精品国产综合久久久久久蜜臀_久久免费看少妇高潮A片麻豆_国产人妻久久精品二区三区特黄_久久精品一本久久99精品 | 美女视频黄频A免费高清不卡_窝窝人体色www_国产A∨天天免费观看美女_极品美女Aⅴ在线观看_操操操.com_亚洲日本区_亚洲精品一区二区三区樱花_国产AV仑乱内谢 | 亚洲成人av一区二区三区_中文字幕在线中文字幕二区_欧美巨大XXXX做受中文字幕_超碰在线久_av永久免费观看_欧美成人精品高清在线观看_一个人免费在线观看动漫视频www_永久不封国产av毛片 | 成年人免费大片_久久精品这里只有精品_日韩草逼_亚洲综合视频在线_男人天堂视频在线观看_欧洲成人在线_日韩一区二区精品_黄色毛片免费进入 | 欧美在线视频一区在线观看_久久22_第一宅男av导航入口_亚洲欧美精品一中文字幕_国产女同91疯狂高潮互磨_youjizz国产_性天堂AV系列_97人人超碰国产精品最新O | 四虎成人精品国产永久免费_一区二区欧美在线观看_少妇寂寞找男按摩师性M_久夜精品_国内精品国产三级国产_国产精品视频六区_成人性视频免费看的鲁片_黄片毛片免费看 | 日韩精品中文字幕无码专区_欧美日韩综合精品_91成人看片_蜜臀av免费一区二区三区久久乐_粉色视频在线观看免费观看_亚洲av日韩av综合_日本艳妓BBW高潮一19_女人扒开屁股让男人桶 | 国产精品国产精品偷麻豆_一级特黄视频_久久综合九色综合97婷婷_亚洲色图在线免费观看_极品少妇XXXX_久久国语_亚洲成人经典_久久99婷婷国产精品免费| 久草久热_亚洲AV综合日韩_精品日韩一区_720lu国产刺激在线观看_日本娇小xxxⅹhd_亚洲爆乳AAA无码专区_日本少妇高潮喷水视频_久久精品国产国产精品四凭 | 在线99_三年片免费观看影视大全满天星_国产网红主播精品av_日韩美女在线_一级在线播放_国产精品成人一区无码_精品久久久久一区二区_H无码精品动漫在线观看导航 | 久久综合久久精品_人人妻人人澡人人爽人人精品AV_97久久夜色精品国产九色_老司机深夜福利视频_无码人妻精品1国产婷婷_china直男gay国产_色妹子综合网_最近最新中文第一页 | 麻豆精品国产免费_久久婷婷国产综合一区二区_国产在线视频网站_亚洲最新版av无码中文字幕一区_国产女教师高潮叫床视频网站_国产高清自拍_久久欧美_国产片一区二区三区 | 久久99精品久久久秒播_视频一区二区视频_cijilu在线视频最新地址_看全色黄大色大片女人爽吗_国产精品久久秋霞鲁丝片_久久高清毛片_青青青在线视频免费观看_色窝窝无码一区二区三区 | 影音先锋中文字幕无码资源站_亚洲区成人_在线观看中文字幕一区_亚洲美女黄色_久久精品国产69国产精品亚洲_国产成人无码a区精油按摩_国产不卡一区二区视频_噜噜噜视频在线观看 | 第一页av_久久久久久国_国产农村妇女毛片精品久久_免费91看片_欧美黑人又粗又大又爽免费_自拍偷拍专区_精品国产一区二区三区香蕉沈先生_久久午夜国产 | 久久精品国产99久久久古代_a级毛片黄片_亚洲欧美日韩一区二区三区在线_国产亚洲精品久久久久久老妇_国产免费AV片在线观看播放器_av成人在线观看_2018成人影院_大地资源高清在线 | 水中色av综合_久久婷婷五月综合尤物色国产_做暖暖小视频免费xo_久久久久精品无码专区_四虎国产成人_九九热在线视频免费观看_手机成人在线观看_999久久久精品一区二区 | 北条麻纪av无码_国产盗摄XXXX视频XXXⅩ_亚洲人妻古典系列_二区免费视频_在线不卡AV片免费观看_久草在线色站_乱人伦人妻系列_扒开美女内裤狂揉下部 |