Stereo Matching algorithm

Source: Internet
Author: User

Three stereo matching algorithms are implemented in OPENCV:

BM algorithm

SGBM algorithm

GC algorithm

Reference: http://blog.csdn.net/wqvbjhc/article/details/6260844

First introduced:SGBM algorithm , as a global matching algorithm, the effect of stereo matching is better than the local matching algorithm, but at the same time the complexity is much larger than the local matching algorithm. The algorithm is mainly referred to stereo processing by Semiglobal Matching and Mutual information

Reference: http://www.opencv.org.cn/forum.php?mod=viewthread&tid=23854

#include #include<cv.h>#include<cxcore.h>#include<iostream>using namespacestd;using namespaceCV;intMain () {Iplimage* IMG1 = Cvloadimage ("Left.png",0); Iplimage* Img2 = Cvloadimage ("Right.png",0);    CV::STEREOSGBM SGBM; intSadwindowsize =9; Sgbm.prefiltercap= the; SGBM. Sadwindowsize= sadwindowsize >0? Sadwindowsize:3; intCN = img1->nchannels; intnumberofdisparities= -; SGBM. P1=8*CN*SGBM. sadwindowsize*SGBM.    Sadwindowsize; SGBM. P2= +*CN*SGBM. sadwindowsize*SGBM.    Sadwindowsize; Sgbm.mindisparity=0; Sgbm.numberofdisparities=numberofdisparities; Sgbm.uniquenessratio=Ten; Sgbm.specklewindowsize= -; Sgbm.specklerange= +; Sgbm.disp12maxdiff=1;    Mat disp, DISP8; Int64 T=GetTickCount ();    SGBM (MAT) IMG1, (MAT) Img2, disp); T= GetTickCount ()-T; cout<<"Time Elapsed:"<<t* +/gettickfrequency () <<Endl; Disp.convertto (DISP8, cv_8u,255/(numberofdisparities* -.)); Namedwindow (" Left",1); Cvshowimage (" Left", IMG1); Namedwindow (" Right",1); Cvshowimage (" Right", IMG2); Namedwindow ("Disparity",1); Imshow ("Disparity", DISP8);    Waitkey (); Imwrite ("Sgbm_disparity.png", DISP8);    Cvdestroyallwindows (); return 0;}

Stereo Matching algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.