Giter VIP home page Giter VIP logo

ethan-li-coding / patchmatchstereo Goto Github PK

View Code? Open in Web Editor NEW
679.0 18.0 120.0 3.94 MB

PatchMatchStereo,倾斜窗口经典,效果极佳,OpenMVS&Colmap稠密匹配算法。完整实现,代码规范,注释清晰,博客教学,欢迎star!

Home Page: https://github.com/ethan-li-coding/PatchMatchStereo.git

License: MIT License

C++ 98.85% C 1.15%
patchmatch stereo stereo-matching 3d-reconstruction patchmatchstereo stereo-vision depth-estimation patchmatch-stereo patch-match-stereo

patchmatchstereo's Introduction

PatchMatchStereo

PatchMatch,倾斜窗口经典,效果极佳,OpenMVS&Colmap稠密匹配算法。完整实现,代码规范,注释清晰,博客教学,欢迎star!

CSDN博客

如果你想了解更多代码讲解,下面的博客或许能帮到你:
【码上实战】【立体匹配系列】经典PatchMatch: (1)框架
【码上实战】【立体匹配系列】经典PatchMatch: (2)主类
【码上实战】【立体匹配系列】经典PatchMatch: (3)随机初始化
【码上实战】【立体匹配系列】经典PatchMatch: (4)代价计算
【码上实战】【立体匹配系列】经典PatchMatch: (5)迭代传播
【码上实战】【立体匹配系列】经典PatchMatch: (6)后处理

环境

windows10 / visual studio 2015&2019
代码基本没有使用系统api,你可以非常方便的移植到linux,可能需要做极少量的修改

强烈建议你使用release模式运行代码,强烈不建议使用debug模式运行代码

第三方库

opencv310
百度网盘连接:https://pan.baidu.com/s/1_WD-KdPyDBazEIim7NU3jA
提取码:aab4

解压后放将名称为OpenCV的文件夹复制到到3rdparty文件夹下

若运行时提示缺少opencv_world310(d).dll,则在OpenCV文件夹里找到对应的dll文件复制到程序exe所在的目录即可(Opencv\dll\opencv_world310(d).dll),带d为debug库,不带d为release库。

为便于移植,算法是不依赖任何图像库的,只在算法实验部分调用opencv库读取和显示图像,也可替换成其他图像库

算法引导

算法框架图


代码框架图

备注

算法优点:效果好,内存占用低
算法缺点:效率低,速度比较慢,不建议跑大图,建议跑个小图看看效果(Release模式)。如果设置为前端平行窗口(PatchMatchStereo为倾斜窗口时效果最好),则速度会更快,如下:

pms_option.is_fource_fpw = true;

论文

Bleyer M, Rhemann C, Rother C. PatchMatch Stereo-Stereo Matching with Slanted Support Windows[C]. British Machine Vision Conference 2011. 2011.

Github图片不显示的解决办法

修改hosts

C:\Windows\System32\drivers\etc\hosts

在文件末尾添加:

# GitHub Start
192.30.253.119      gist.github.com
151.101.184.133     assets-cdn.github.com
151.101.184.133     raw.githubusercontent.com
151.101.184.133     gist.githubusercontent.com
151.101.184.133     cloud.githubusercontent.com
151.101.184.133     camo.githubusercontent.com
151.101.184.133     avatars0.githubusercontent.com
151.101.184.133     avatars1.githubusercontent.com
151.101.184.133     avatars2.githubusercontent.com
151.101.184.133     avatars3.githubusercontent.com
151.101.184.133     avatars4.githubusercontent.com
151.101.184.133     avatars5.githubusercontent.com
151.101.184.133     avatars6.githubusercontent.com
151.101.184.133     avatars7.githubusercontent.com
151.101.184.133     avatars8.githubusercontent.com
# GitHub End

patchmatchstereo's People

Contributors

ethan-li-coding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

patchmatchstereo's Issues

关于结果的测试

看了您的AD-Census以及PatchMatch这两个项目,想问下您有相关的测试代码嘛?因为我之前跑的是
https://github.com/WangHewei16/Stereo-Matching 这个项目中Tablecode中的测试Error_Non31这个测试代码,但是目前感觉有几个问题:1.想问下生成的这些各种各样的图片的对应关系,因为在
https://github.com/WangHewei16/Stereo-Matching
这个项目中,生成了许多的结果,比如result生成了许多注入dispLR,dispBoth这样的图片。
您生成的是视差图,和我生成的视差图在使用测试代码的时候结果差异很大,比如这张图片是使用您的代码生成的结果以及他这个项目生成的结果对比,result2我用测试代码运行您的patchmatch得到的图片(view1.png-d.png),以及另一个项目得到的图片(203_dispLR_so.png)去分别测试做对比,结果发现您的图片得到的结果错误率为99%。99
然而实际上肉眼可见您的方法生成的图片效果更好,是什么原因导致的这样的结果呢?路径是因为生成的图片的格式问题嘛?因为我看到您的方法生成的图片的灰度貌似看上去和他这个项目生成的图片灰度不一样2.可以把AD-Census以及PatchMatch两个算法取各自最优的部分结合起来,然后得到更好的测试结果吗?3.您有专门用来测试的更好的测试代码吗?谢谢!

关于算法速度问题解答

PatchMatch速度是比较慢的。确保你的运行环境是Release模式,若为Debug模式则会非常慢,对代码里带的示例数据,Release模式可以在几分钟至十几分钟跑出结果。
此外,如果你设置为前端平行窗口模式,则速度会加快很多,这样设置:
pms_option.is_fource_fpw = true

关于运行

您好我想请问一下您这个项目如何在CLion上运行呀 谢谢

关于测试我自己的图像

您的工作对我帮助很大,谢谢!如果我想用您的程序测试自己的数据,我该更改哪些参数?

Accuracy on Kitti dataset

Can I use Kitti 2015 dataset instead of Middlebury? With Kitti I am getting 3-pixel error of around 15-16%. Can you suggest methods to further reduce it. Also, can you please explain significance of these parameters:
// alpha
. pms_option Alpha = 0 . 9F ;
// t_col
. pms_option tau_col = 10 . 0F ;
// t_grad
. pms_option tau_grad = 2 . 0F ;
// Number of propagation iterations
pms_option. num_iters = 3 ;

Can I alter these parameters to reduce accuracy.

关于数值量化

还有一个问题,将视差值量化为0-255之间的灰度值的公式是什么?

关于数组的转化问题

大佬您好 我想问一下 您这个跑到最后得到的是不是一个float的数组呀?如果我想转化为Mat数组进行操作,具体要怎么做呢?是不是想如图中这里在ShowDisparityMap函数中的操作就是在转化为Mat呀?disp_mat就是得到的Mat类型的数组?
2月21日

openmvs和colmap里面的密集匹配算法异同

您好,
打扰了,又是从您的博客过来。不知您是否研究过这两个库里面的密集匹配算法,想请教一点问题。。最近我阅读了colmap密集匹配算法的文章,数学公式太多有些地方没怎么看明白,只知道colmap里面的方法view selection和depth estimation是通过EM迭代同时完成的,view selection考虑更为全面一些,等等。还想请教一下下面的问题:
(1)colmap里面的深度值是怎么传播的,如何理解里面的状态转移方程 ,能否对比openmvs里面的方法稍微讲解一下不同之处。
(2)colmap法线优化是生成了额外的超参然后计算谁是最优,相比openmvs里面使用的二分法,这种方法的优势和劣势是什么
(3)相比openmvs,colmap方法更为耗时,耗时主要是因为EM这个迭代过程需要反复进行吗?
国庆期间还发来问题,希望不会过分打扰到您。
谢谢~

to_another_view算法解释 ?

照李博原本的说法是这样算的
image

但代码却被改成了这样
image

原本的代码还能理解,但改过之后反倒不理解了,有高手能解惑吗?

关于pms_propagation.cpp里ViewPropagation的一个问题

首先感谢大佬分享
在论文第5页 View Propagation中,作者提到: “We check all pixels of the second view that have our current pixel p as a
matching point according to their current plane”。
但是在代码实现中,好像是用当前点 p 的视差计算出了唯一的一个对应点 p'
是我理解有误还是,这一点不是特别重要 被省略掉了?
`void PMSPropagation::ViewPropagation(const sint32& x, const sint32& y) const
{
// --
// 视图传播
// 搜索p在右视图的同名点q,更新q的平面

// 左视图匹配点p的位置及其视差平面 
const sint32 p = y * width_ + x;
const auto& plane_p = plane_left_[p];
auto* cost_cpt = dynamic_cast<CostComputerPMS*>(cost_cpt_right_);

const float32 d_p = plane_p.to_disparity(x, y);

// 计算右视图列号
const sint32 xr = lround(x - d_p);
if (xr < 0 || xr >= width_) {
	return;
}

const sint32 q = y * width_ + xr;
auto& plane_q = plane_right_[q];
auto& cost_q = cost_right_[q];

// 将左视图的视差平面转换到右视图
const auto plane_p2q = plane_p.to_another_view(x, y);
const float32 d_q = plane_p2q.to_disparity(xr,y);
const auto cost = cost_cpt->ComputeA(xr, y, plane_p2q);
if (cost < cost_q) {
	plane_q = plane_p2q;
	cost_q = cost;
}

}`

您好,感谢您的分享,关于运行时间我还是想问一下

我在 release x64的情况下,用vs2019跑的代码,系统配置是win10 i3 8G
跑的是middlebury的 Dolls ,分辨率只有 463*370 ,
但是目前跑了30多分钟了还是没有出结果,不知道是否有某些设置没有考虑到呢? 期待您的回答! 感谢!

补充:跑了四十多分钟出结果了 效果并不如所示那样。。 不知道是有什么问题嘛

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.