深度图优化之ThreadDepthCleaner

2023-12-15 20:47:51

github地址:ThreadedDepthCleaner

按github上的说明配置环境:

git clone https://github.com/juniorxsound/ThreadedDepthCleaner --recursive
mkdir build && cd build && cmake ../ && make -j4

这一步容易出现undefined reference to symbol ‘dlclose@@GLIBC_2.2.5‘
和undefined reference to symbol ‘pthread_create‘报错,
解决方法见:
undefined reference to symbol dlclose
undefined reference to symbol ‘pthread_create‘

github中的main.cpp是直接连接realsense相机的,这里没有用相机,直接优化深度图,
所以要改一下代码,最后cleanedDepth就是优化后的深度图。

Mat rawDepthMat = imread("depth.png", cv::IMREAD_UNCHANGED);
const int w = rawDepthMat.cols;
const int h = rawDepthMat.rows;

// Create an openCV matrix for the DepthCleaner instance to write the output to
Mat cleanedDepth(Size(w, h), CV_16U);

//Run the RGBD depth cleaner instance
depthc->operator()(rawDepthMat, cleanedDepth);

//补空洞
const unsigned char noDepth = 0; // change to 255, if values no depth uses max value
Mat temp, temp2;

// Downsize for performance, use a smaller version of depth image (defined in the SCALE_FACTOR macro)
Mat small_depthf;
resize(cleanedDepth, small_depthf, Size(), SCALE_FACTOR, SCALE_FACTOR);

// Inpaint only the masked "unknown" pixels
inpaint(small_depthf, (small_depthf == noDepth), temp, 5.0, INPAINT_TELEA);

// Upscale to original size and replace inpainted regions in original depth image
resize(temp, temp2, cleanedDepth.size());
temp2.copyTo(cleanedDepth, (cleanedDepth == noDepth));  // add to the original signal

文章来源:https://blog.csdn.net/level_code/article/details/135010041
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。