Intel Realsense d435 使用python对深度图进行预处理
Intel Realsense d435 使用python對深度圖進行預(yù)處理
本文中主要翻譯一下一篇關(guān)于深度圖預(yù)處理過濾器的內(nèi)容,后面還會有關(guān)于距離測量的。
原文中的圖像顯示,是使用matplotlib.pyplot工具,在本文中,使用opencv來顯示深度圖》
首先常規(guī)操作導(dǎo)入包:
獲取我們所需要的圖像,通過攝像頭或者本地都可以
pipe = 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) profile = pipe.start(cfg)try:while True:frame = pipe.wait_for_frames()depth_frame = frame.get_depth_frame()print('capture success')if cv2.waitKey(10)&0xff == ord('q'):breakfinally:pipe.stop()獲取成功,在終端打印信息
一、深度圖像的可視化
使用pyrealsense2庫中提供的colorizer來將圖像中的深度值轉(zhuǎn)為可以顯示的形式:
colorizer = rs.colorizer() colorizer_depth = np.asanyarray(colorizer.colorize(depth_frame).get_data()) cv2.imshow('colorizer depth',colorizer_depth)二、應(yīng)用過濾器
(1)抽取(Decimation)
When using Depth-from-Stereo solution, z-accuracy is related to original spacial resolution.
If you are satisfied with lower spatial resolution, the Decimation Filter will reduce spatial resolution preserving z-accuracy and performing some rudamentary hole-filling.
這段話的意思就是類似與圖像處理中的降采樣,圖像的分辨率會降低(640x480----->320x240),但會講一些黑色的空洞進行填充。
(2)空間過濾器(Spatial Filter)
空間濾波器的論文:
Domain Transform for Edge-Aware Image and Video Processing
同時,spatial也提供了一個基本的空洞填充操作:
spatial.set_option(rs.option.holes_fill,3)filtered_depth = spatial.process(depth_frame)colorized_depth = np.asanyarray(colorizer.colorize(filtered_depth).get_data())cv2.imshow('fill hole',colorized_depth)(3)時間過濾器(Temporal Filter)
Our implementation of Temporal Filter does basic temporal smoothing and hole-filling. It is meaningless when applied to a single frame, so let’s capture several consecutive frames:
我們對“時間過濾器”的實現(xiàn)實現(xiàn)了基本的時間平滑和孔填充。 當應(yīng)用于單個幀時它是沒有意義的,因此讓我們捕獲幾個連續(xù)的幀:
(4)孔填充(Hole Filling)
Hole Filling filter offers additional layer of depth exterpolation:
孔填充過濾器提供了深度外推的附加層:
(5)放在一起(Putting Everything Together)
These filters work best when applied sequentially one after another. At longer range, it also helps using disparity_transform to switch from depth representation to disparity form:
依次順序應(yīng)用這些過濾器時,效果最佳。 在更大范圍內(nèi),它還有助于使用disparity_transform從深度表示轉(zhuǎn)換為視差形式:
總結(jié)
以上是生活随笔為你收集整理的Intel Realsense d435 使用python对深度图进行预处理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 不申明构造函数,PHP的构造函数
- 下一篇: 【算法】一个简单的决策树(DT)原理