Intel Realsense C/C++ 转 python rs-align 使用深度颜色映射介绍空间流对齐的概念(转不起来,缺少信息)
源網址:rs-align
Overview
This example introduces the concept of spatial stream alignment.
For example usecase of alignment, please check out align-advanced and measure demos.
The need for spatial alignment (from here “align”) arises from the fact
that not all camera streams are captured from a single viewport.
【本示例介紹了空間流對齊的概念。
例如對齊的用例,請查看align-advanced并測量演示。
由于以下事實,需要進行空間對齊(此處為“對齊”)
并非所有相機流都是從單個視口捕獲的。】
Align process lets the user translate images from one viewport to another.
That said, results of align are synthetic streams, and suffer from several artifacts:
【對齊過程使用戶可以將圖像從一個視口轉換到另一個視口。
就是說,align的結果是合成流,并且受到一些假象的困擾:】
Sampling - mapping stream to a different viewport will modify the resolution of the frame to match the resolution of target viewport. This will either cause downsampling or upsampling via interpolation. The interpolation used needs to be of type Nearest Neighbor to avoid introducing non-existing values.
?
【采樣-將流映射到其他視口將修改幀的分辨率以匹配目標視口的分辨率。 這將導致通過插值進行下采樣或上采樣。 所使用的插值類型必須為“最近鄰”,以避免引入不存在的值。】
Occlussion - Some pixels in the resulting image correspond to 3D coordinates that the original sensor did not see, because these 3D points were occluded in the original viewport. Such pixels may hold invalid texture values.
【遮擋-最終圖像中的某些像素對應于原始傳感器看不到的3D坐標,因為這些3D點被遮擋在原始視口中。 這樣的像素可能保存無效的紋理值。】
Expected Output
The application should open a window and display video stream from the color camera overlayed on top of depth stream data.
【應用程序應打開一個窗口,并顯示覆蓋在深度流數據頂部的彩色攝像機的視頻流。】
The slider in bottom of the window control the transparancy of the overlayed stream.
Checkboxes below allow toggling between depth to color vs color to depth alignment.
【窗口底部的滑塊控制疊加流的透明度。
下面的復選框允許在深度到顏色與顏色到深度對齊之間切換。】
Code Overview
This example is using standard librealsense API and IMGUI library for simple UI rendering:
【此示例使用標準librealsense API和IMGUI庫進行簡單的UI渲染:】
#include #include "../example.hpp" #include "imgui.h" #include "imgui_impl_glfw.h"In this example we are interested in RS2_STREAM_DEPTH and RS2_STREAM_COLOR streams:
【在此示例中,我們對RS2_STREAM_DEPTH和RS2_STREAM_COLOR流感興趣:】
// Create a pipeline to easily configure and start the camera rs2::pipeline pipe; rs2::config cfg; cfg.enable_stream(RS2_STREAM_DEPTH); cfg.enable_stream(RS2_STREAM_COLOR); pipe.start(cfg);SDK class responsible for stream alignment is called rs2::align. The user initializes it with desired target stream and applies it to framesets via process method.
【負責流對齊的SDK類稱為rs2 :: align。 用戶使用所需的目標流對其進行初始化,然后通過處理方法將其應用于幀集。】
***(我去!省略號是省掉了一大段代碼嗎??可折騰死我了!!)*** // Define two align objects. One will be used to align to depth viewport and the other to color. // 定義兩個對齊對象。 一個將用于與深度視口對齊,另一個將用于顏色。 // Creating align object is an expensive operation that should not be performed in the main loop // 創建對齊對象是一項昂貴的操作,不應在主循環中執行 rs2::align align_to_depth(RS2_STREAM_DEPTH); rs2::align align_to_color(RS2_STREAM_COLOR); // ... frameset = align_to_depth.process(frameset);Next, we render the two stream overlayed on top of each other using OpenGL blending feature:
【接下來,我們使用OpenGL混合功能渲染兩個疊加在一起的流:】
glEnable(GL_BLEND); // Use the Alpha channel for blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);if (dir == direction::to_depth) {// When aligning to depth, first render depth image// and then overlay color on top with transparancydepth_image.render(colorized_depth, { 0, 0, app.width(), app.height() });color_image.render(color, { 0, 0, app.width(), app.height() }, alpha); } else {// When aligning to color, first render color image// and then overlay depth image on topcolor_image.render(color, { 0, 0, app.width(), app.height() });depth_image.render(colorized_depth, { 0, 0, app.width(), app.height() }, 1 - alpha); }glColor4f(1.f, 1.f, 1.f, 1.f); glDisable(GL_BLEND);IMGUI is used to render the slider and two checkboxes:
【IMGUI用于呈現滑塊和兩個復選框:】
// Render the UI: ImGui_ImplGlfw_NewFrame(1); render_slider({ 15.f, app.height() - 60, app.width() - 30, app.height() }, &alpha, &dir); ImGui::Render();這程序沒法弄啊!牛頭不對馬嘴的!
果斷放棄!
看這個:Intel Realsense D435 (Python Wrapper)example03: Stream Alignment 流對齊 通過深度去除背景
總結
以上是生活随笔為你收集整理的Intel Realsense C/C++ 转 python rs-align 使用深度颜色映射介绍空间流对齐的概念(转不起来,缺少信息)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Intel Realsense 功能概览
- 下一篇: C++ 创建对象时带括号和不带括号的区别