日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Intel RealsenseD435 color图与depth图的两种对齐(align)方式

發布時間:2025/3/19 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Intel RealsenseD435 color图与depth图的两种对齐(align)方式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import pyrealsense2 as rs import cv2 as cv import numpy as nppipeline = rs.pipeline()cfg = rs.config() cfg.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) cfg.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)# 設定需要對齊的方式(這里是深度對齊彩色,彩色圖不變,深度圖變換) align_to = rs.stream.color # 設定需要對齊的方式(這里是彩色對齊深度,深度圖不變,彩色圖變換) # align_to = rs.stream.depthalignedFs = rs.align(align_to)profile = pipeline.start(cfg)try:while True:fs = pipeline.wait_for_frames()aligned_frames = alignedFs.process(fs)color_frame = aligned_frames.get_color_frame()depth_frame = aligned_frames.get_depth_frame()if not depth_frame or not color_frame:continuecolor_image = np.asanyarray(color_frame.get_data())depth_image = np.asanyarray(depth_frame.get_data())# D·C 191122:打印depth_image的最大值看看# print(depth_image.max())# 可以看到,最大的數值從一萬到六萬不等(表示最遠距離十多米到六十米這樣)# D·C 191122:打印數據類型看看# print(depth_image.dtype)# uint16# print(color_image.dtype)# uint8# D·C 191122:打印color_image的維度看看# print(color_image.shape)# (480, 640, 3)# print(depth_image.shape)# (480, 640)# D·C 191122:打印cv.convertScaleAbs(depth_image, alpha=0.03)的數據類型和維度看看:# print(cv.convertScaleAbs(depth_image, alpha=0.03).dtype)# uint8# print(cv.convertScaleAbs(depth_image, alpha=0.03).shape)# (480, 640)# D·C 191122:打印cv.applyColorMap(cv.convertScaleAbs(depth_image, alpha=0.03), cv.COLORMAP_JET)的數據類型和維度看看# print(cv.applyColorMap(cv.convertScaleAbs(depth_image, alpha=0.03), cv.COLORMAP_JET).dtype)# uint8# print(cv.applyColorMap(cv.convertScaleAbs(depth_image, alpha=0.03), cv.COLORMAP_JET).shape)# (480, 640, 3)# D·C 191122:打印cv.convertScaleAbs(depth_image, alpha=0.03)的最大值看看# print(cv.convertScaleAbs(depth_image, alpha=0.03))# 可看到最大值為255# 估計若原值*alpha大于255,則將其取值為255,而當alpha為0.03時,能夠映射的最大可變距離為255/0.03=8500mm=8.5m# D·C 191122:修改alpha參數后,發現圖像對比度發生變化(比如alpha=1,圖像基本呈紅沒啥對比度、alpha=0.001,圖像呈藍也沒啥對比度、alpha=1點幾,效果也不行)# origin:depth_image = cv.applyColorMap(cv.convertScaleAbs(depth_image, alpha=0.03), cv.COLORMAP_JET)depth_image = cv.applyColorMap(cv.convertScaleAbs(depth_image, alpha=0.03), cv.COLORMAP_JET)images = np.hstack((color_image, depth_image))# window = cv.namedWindow('window', cv.WINDOW_AUTOSIZE)cv.imshow('window', images)cv.waitKey(1) finally:pipeline.stop()

對齊原理

The term “alignment” w.r.t SDK denotes a synthetic image generation with the help of depth map. In the process a new image is created using triangulation method comprising of 2D=>3D=>2D transformations.
The transformation is akin to a ray tracing - each pixel is first “fired” from 2D to 3D space, and then projected into the 2D plane of another sensor.
So by definition the aligned data is generated from depth in conjunction with color/ir data, hence the areas with no depth data coverage result in “holes” in the generated image.
The above serves a specific purpose - allowing 1:1 mapping of depth to color and vice versa. So when a user selects RGB pixel of interest then the SDK will be able to provide the corresponding Depth deterministically with no false positives.
This is a critical feature in scenarios where the depth is essentially used as a validation filter for other sensors - collision avoidance, segmentation, object recognition.
While using sheer 2D image manipulations would similarly allow to recalculate an image from a different point of view, it would also introduce fundamental flaws - preserve the pixels for which there is no corresponding depth data, and also introduce artifacts due to occlusion and different perspective, which would undermine the declared purpose.
Eventually there are more than one way to “align” images, depending of the use-case requirements. And the above explanation highlights the specific advantage (and also the utility) of the method implemented by the SDK.

SDK中的“對齊”一詞表示借助深度圖生成的合成圖像。在此過程中,將使用由2D => 3D => 2D轉換組成的三角測量方法來創建新圖像。
轉換類似于ray tracing-每個像素首先從2D空間“發射”到3D空間,然后投影到另一個傳感器的2D平面中。
因此,根據定義,對齊的數據是結合顏色/ ir數據從深度生成的,因此沒有深度數據覆蓋的區域會在生成的圖像中產生“孔”。

上面的內容用于特定目的-
允許將深度與顏色進行1:1映射,反之亦然。因此,當用戶選擇感興趣的RGB像素時,SDK將能夠確定性地提供相應的深度,而不會產生誤報。
這在深度實際上用作其他傳感器的驗證過濾器(避免碰撞,分割,物體識別)的情況下是至關重要的功能。

雖然使用純粹的2D圖像處理可以類似地從不同的角度重新計算圖像,但它也會帶來基本的缺陷-保留沒有相應深度數據的像素,并且還會由于遮擋和視角不同而引入偽像,這會破壞宣布的目的。

最終,取決于用例需求,有不止一種“對齊”圖像的方法。上面的說明著重介紹了由SDK實現的方法的特定優勢(以及實用程序)。

參考文章:Align to Depth produces lossy color image #5030

總結

以上是生活随笔為你收集整理的Intel RealsenseD435 color图与depth图的两种对齐(align)方式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。