Comparison of the effect of two stereo matching algorithms in OpenCV3.4

Source: Internet
Author: User

Take the aloe image pair with OpenCV as an example:

1.BM Algorithm (Block Matching)

The parameters are set as follows:

    intNumberofdisparities = ((Imgsize.width/8) + the) &- -; CV::P TR<cv::StereoBM> BM = Cv::stereobm::create ( -,9);    Cv::rect Roi1, Roi2; BM-setROI1 (ROI1); BM-setROI2 (ROI2); BM->setprefiltercap ( to); BM->setblocksize (9); BM->setmindisparity (0); BM-setnumdisparities (numberofdisparities); BM->settexturethreshold (Ten); BM->setuniquenessratio ( the); BM->setspecklewindowsize ( -); BM->setspecklerange ( +); BM->setdisp12maxdiff (1); BM->compute (IMGL, imgr, disp);

The effect is as follows:

The parallax map (left) obtained by the BM algorithm, and the disparity map (right) resulting from the cavity filling.

2.SGBM (semi-global Block matching) algorithm:

The parameters are set as follows:

enum{STEREO_BM =0, STEREO_SGBM =1, stereo_hh =2, Stereo_var =3, Stereo_3way =4 }; intNumberofdisparities = ((Imgsize.width/8) + the) &- -; CV::P TR<cv::StereoSGBM> SGBM = Cv::stereosgbm::create (0, -,3); SGBM->setprefiltercap ( the); intSadwindowsize =9; intSgbmwinsize = sadwindowsize >0? Sadwindowsize:3; SGBM-setblocksize (sgbmwinsize); intCN =imgl.channels (); SGBM-&GT;SETP1 (8* cn*sgbmwinsize*sgbmwinsize); SGBM-&GT;SETP2 ( +* cn*sgbmwinsize*sgbmwinsize); SGBM->setmindisparity (0); SGBM-setnumdisparities (numberofdisparities); SGBM->setuniquenessratio (Ten); SGBM->setspecklewindowsize ( -); SGBM->setspecklerange ( +); SGBM->setdisp12maxdiff (1); intALG =STEREO_SGBM; if(ALG = =stereo_hh) SGBM-SetMode (CV::STEREOSGBM::MODE_HH); Else if(ALG = =STEREO_SGBM) SGBM-SetMode (CV::STEREOSGBM::MODE_SGBM); Else if(ALG = =stereo_3way) SGBM-SetMode (Cv::stereosgbm::mode_sgbm_3way); SGBM->compute (IMGL, imgr, disp);

Effect

The disparity map (left) obtained by the SGBM algorithm, and the disparity map (right) resulting from the hole filling.

It can be seen that the disparity map obtained by the SGBM algorithm reduces a lot of inaccurate matching points compared to the BM algorithm, especially in the depth discontinuous region, the speed SGBM is slower than the BM algorithm. OpenCV3.0 later did not implement the GC algorithm, may be due to speed considerations, later find time to fill the comparison chart, as well as the detailed principle of each algorithm analysis.

I fill the void after the effect is not very good, if there is a better way, hope to enlighten.

Comparison of the effect of two stereo matching algorithms in OpenCV3.4

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.