c++ - opencv sgbm 在对象边缘产生异常值

标签 c++ opencv image-processing stereo-3d 3d-reconstruction

我正在使用 opencv sgmb 进行立体视差计算,以重建放在 table 上的一些简单物体。一切都或多或少地运作良好,除了在对象的边缘我发现一些异常值将其与背景颜色粘在一起。问题是我认为 sgbm 与对象边缘相邻的背景点不匹配,并且它们获得与这些边缘相同的视差值。 这是一个例子 first rectified image second rectified image disparity image 3D

如您所见,地板上的一些图像粘在了物体上。我正在为 sgbm 参数使用标准值:

int sgbmWinSize = 3;//size of the window to be matched
int numberOfDisparities = 256; //number of different disparity values in pixels

int cn = inputImage1.channels();

sgbm.minDisparity = -128; //minimum possible disparity value in pixels
sgbm.SADWindowSize = sgbmWinSize;
sgbm.numberOfDisparities = numberOfDisparities;
//parameters controling disparity smoothness 
//values taken from openCV example
//additional tuning may be needed
sgbm.P1 = 8 * cn*sgbmWinSize*sgbmWinSize;
sgbm.P2 = 32 * cn*sgbmWinSize*sgbmWinSize;

sgbm.uniquenessRatio = 1;

//parameters for speckle filtering
sgbm.speckleWindowSize = 100;
sgbm.speckleRange = 5;

//maximum difference value in left-right disparity check
sgbm.disp12MaxDiff = 1;

//wether to run the full dp algorithm
//if set to true it may consume a lot of memory
sgbm.fullDP = true;
sgbm.preFilterCap = 4;

我已经尝试更改和调整参数以获得更好的视差,但无论我做什么,一些背景点仍然粘在物体上。 有没有人有过类似的经历?有谁知道解决这个问题的方法吗?

最佳答案

这对于 SGBM 来说是完全正常的。您可以通过调整 block 大小来减少这种影响,但在对象的边缘总会有一些噪音。另一个常见的技巧是对视差图应用中值滤波器。还有其他视差算法,例如 Graph Cuts,它会产生更清晰的边缘。

关于c++ - opencv sgbm 在对象边缘产生异常值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30784030/

相关文章:

image - opencv将Mat的submat设置为另一个Mat

c++ - 冒泡排序不工作

c++ - 移位导致奇怪的类型转换

c++ - 比较服务器端接收到的字符串 - C++

image-processing - 我怎样才能得到一条完整的中轴线,其垂直线穿过它?

c++ - 用于选择颜色的轨迹栏。使用C++、opencv

JavaCV:如何获取描述符的二进制字符串

c++ - 从函数返回一个带有值模板参数的类模板

python-2.7 - 视差图教程 SADWindowSize 和图像不能 float

image-processing - 使用 ImageMagick 通过保留半透明像素将 32 位 png 转换为 8 位 png