Summary of three kinds of Stereo Matching and parallax graph algorithms in opencv

Source: Internet
Author: User

 

Code the three stereo matching algorithms involved in opencv and their respective advantages and disadvantages:

First, let's take a look at the BM algorithm:

The algorithm code:

 

Cvstereobmstate * bmstate = cvcreatestereobmstate (); <br/> int sadwindowsize = 15; <br/> bmstate-> sadwindowsize = sadwindowsize> 0? Sadwindowsize: 9; <br/> bmstate-> mindisparity = 0; <br/> bmstate-> numberofdisparities = 32; <br/> bmstate-> texturethreshold = 10; <br/> bmstate-> uniquenessratio = 15; <br/> bmstate-> specklewindowsize = 100; <br/> bmstate-> specklerange = 32; <br/> bmstate-> disp12maxdiff = 1; <br/> values (left, right, left_disp _, bmstate); <br/> cvnormalize (left_disp _, left_vdisp, 0,256, cv_minmax); <br/>

 

Mindisparity is the first parameter to control the matching search. It indicates where the matching search starts, and numberofdisparities indicates the maximum search parallax number uniquenessratio indicates the matching function. These three parameters are important, parameters can be set based on the experiment.

This method is the fastest. A 320*240 grayscale image has a matching time of 31 Ms. The Parallax is shown below.

The second method is the sgbm method, which is a new algorithm of opencv:

 

CV: stereosgbm sgbm; <br/> sgbm. prefiltercap = 63; <br/> int sadwindowsize = 11; <br/> int Cn = 1; <br/> sgbm. sadwindowsize = sadwindowsize> 0? Sadwindowsize: 3; <br/> sgbm. p1 = 4 * Cn * sgbm. sadwindowsize * sgbm. sadwindowsize; <br/> sgbm. p2 = 32 * Cn * sgbm. sadwindowsize * sgbm. sadwindowsize; <br/> sgbm. mindisparity = 0; <br/> sgbm. numberofdisparities = 32; <br/> sgbm. uniquenessratio = 10; <br/> sgbm. specklewindowsize = 100; <br/> sgbm. specklerange = 32; <br/> sgbm. disp12maxdiff = 1; </P> <p> sgbm (left, right, left_disp _); <br/> sgbm (right, left, right_disp _); 

 

The parameter settings, such as the BM method, are fast. The grayscale image matching time of 320*240 is 78 ms, and the parallax effect is shown in figure.

The third method is GC:

 

Cvstereogcstate * State = cvcreatestereogcstate (16, 2); <br/> left_disp _ = cvcreatemat (left-> height, left-> width, cv_32f ); <br/> right_disp _ = cvcreatemat (right-> height, right-> width, cv_32f); <br/> cvfindstereocorrespondencegc (left, right, left_disp _, right_disp _, state, state, 0); <br/> cvreleasestereogcstate (& State ); 

 

This method is slow, but the effect is superb.

The theory of each method can be referred to the literature.

 

Source: http://blog.csdn.net/mailang2008/archive/2010/09/09/5873883.aspx

 

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.