Code Monkey home page Code Monkey logo

ethan-li-coding / semiglobalmatching Goto Github PK

View Code? Open in Web Editor NEW
1.0K 17.0 215.0 13.64 MB

SGM,立体匹配StereoMatching最经典应用最广泛算法,4000+引用,兼顾效率和效果。完整实现,代码规范,注释清晰,博客教学,欢迎star!

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

License: MIT License

C++ 99.23% C 0.77%
sgm semiglobalmatching census stereo semi-global-matching stereo-matching depth-estimation 3d-reconstruction semi-global

semiglobalmatching's Introduction

SemiGlobalMatching

SGM,立体匹配最经典应用最广泛算法,4000+引用,兼顾效率和效果。完整实现,代码规范,注释清晰,博客教学,欢迎star!

CSDN博客

【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(1)框架与类设计
【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(2)代价计算
【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(3)代价聚合
【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(4)代价聚合2
【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(5)视差优化
【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(6)视差填充
【恒叨立码】【码上实战】【立体匹配系列】经典SGM:(7)弱纹理优化

环境

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

第三方库

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库读取和显示图像,也可替换成其他图像库

算法引导

SGM步骤图


SGM类设计图

备注

算法优点:效果好,效率高,且可高度并行
算法缺点:效果非SOTA、内存占用高(可优化)、对弱纹理、重复纹理支持不太好

论文

  1. Heiko Hirschmüller. Hirschmüller, H: Stereo processing by semiglobal matching and mutual information. IEEE PAMI 30(2), 328-341[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2008, 30(2):328-341.
  2. Humenberger M , Engelke T , Kubinger W . A census-based stereo vision algorithm using modified Semi-Global Matching and plane fitting to improve matching quality[C]// IEEE Computer Society Conference on Computer Vision & Pattern Recognition-workshops. IEEE, 2010.

实验图

上行:左视图、右视图、初始代价结果、聚合代价结果
下行:一致性检查、唯一性约束+去小连通区、中值滤波、视差填充

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

semiglobalmatching'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

semiglobalmatching's Issues

communicate

您好,可否加个好友交流下相关技术

代价聚合公式使用初始代价值

您好,李博士
我们正在打算将sgm放到FPGA中
在您的算法中,计算代价聚合公式中L1 L2 L3 L4时,用到了上一个点的聚合代价值,请问是否可以改为初始代价值
因为用初始代价值方便FPGA实现

效果不好

您好,我用自己的双目相机拍的照片,将校正后的核线图片输入程序,但效果不好,是什么原因呢。哪些sgm匹配参数修改一下可以让我程序的效果更好呢。还是我的双目图像本身效果不好。

代码运行问题

李老师您好!我在VS2017中运行代码时遇到了一些问题,想向您寻求帮助。
image

运行效果

你好作者,我运行了你放在data目录中得测试图像,为什么得到得效果跟你展示得不一样哈,没有修改任何地方。
Reindeer结果
image

Input image were rectified

Looks like the input image must be rectified. Could you please tell us how to rectify two original camera images?

exe闪退

您好,我使用的平台是VS2017.
打开的文档是SemiGlobalMatching-vs2015.sln
我起初遇到了您说的缺失.dll文档的问题,我将Opencv/bin下的opencv_world310d.dll文档复制到了x64/Debug的文件下。
但在我再运行时,界面直接闪退
“SemiGlobalMatching.exe”(Win32): 已加载“E:\Desktop\立体匹配学习积累\CSDN 李迎松\SGM代码\SemiGlobalMatching-master\x64\Debug\SemiGlobalMatching.exe”。已加载符号。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\ntdll.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\kernel32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\KernelBase.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\vcruntime140d.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\msvcp140d.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\ucrtbased.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“E:\Desktop\立体匹配学习积累\CSDN 李迎松\SGM代码\SemiGlobalMatching-master\x64\Debug\opencv_world310d.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\user32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\win32u.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\gdi32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\gdi32full.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\msvcp_win.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\ucrtbase.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\ole32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\combase.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\rpcrt4.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\bcryptprimitives.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\advapi32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\msvcrt.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\sechost.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\oleaut32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\comdlg32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\SHCore.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\shlwapi.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\shell32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.18362.1082_none_73b2803ad816b43c\comctl32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\cfgmgr32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\windows.storage.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\profapi.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\powrprof.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\umpdc.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\kernel.appcore.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\cryptsp.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\msvfw32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\avifil32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\avicap32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\concrt140d.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\winmm.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\msacm32.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\winmmbase.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\winmmbase.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已卸载“C:\Windows\System32\winmmbase.dll”
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\winmmbase.dll”。无法查找或打开 PDB 文件。
“SemiGlobalMatching.exe”(Win32): 已卸载“C:\Windows\System32\winmmbase.dll”
“SemiGlobalMatching.exe”(Win32): 已加载“C:\Windows\System32\imm32.dll”。无法查找或打开 PDB 文件。

***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

线程 0x3140 已退出,返回值为 -1 (0xffffffff)。
线程 0x5200 已退出,返回值为 -1 (0xffffffff)。
线程 0x5654 已退出,返回值为 -1 (0xffffffff)。
程序“[17812] SemiGlobalMatching.exe”已退出,返回值为 -1 (0xffffffff)。

聚合sgm_util::CostAggregateLeftRight中的cost

代码:147-157行in sgm_util.cpp
// 自方向上第2个像素开始按顺序聚合
for (sint32 j = 0; j < width - 1; j++) {
gray = *img_row;
uint8 min_cost = UINT8_MAX;
for (sint32 d = 0; d < disp_range; d++){
// Lr(p,d) = C(p,d) + min( Lr(p-r,d), Lr(p-r,d-1) + P1, Lr(p-r,d+1) + P1, min(Lr(p-r))+P2 ) - min(Lr(p-r))
const uint8 cost = cost_init_row[d];
const uint16 l1 = cost_last_path[d + 1];
const uint16 l2 = cost_last_path[d] + P1;
const uint16 l3 = cost_last_path[d + 2] + P1;
const uint16 l4 = mincost_last_path + std::max(P1, P2_Init / (abs(gray - gray_last) + 1));
这里面的l1-l3
难道不应该是:
const uint16 l1 = cost_last_path[d - 1] + P1;
const uint16 l2 = cost_last_path[d] ;
const uint16 l3 = cost_last_path[d + 1] + P1;
为啥cost_last_path的d的索引偏差一个而cost_init_row没有?

issue

SemiGlobalMatching/SemiGlobalMatching/sgm_util.cpp

Line 332
使用的是vs2015,程序运行之后
显示的是0x00007FF7F86CF0C4 处(位于 SemiGlobalMatching.exe 中)引发的异常: 0xC0000005: 读取位置 0x000001A9B12D8000 时发生访问冲突。
请问这是因为什么呢

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.