close
加入現有屬性工作表
#include "stdafx.h"
#include <core\core.hpp>
#include <calib3d\calib3d.hpp>
#include <highgui\highgui.hpp>
#include <imgproc\imgproc.hpp>
#include <contrib\contrib.hpp>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Mat img1, img2, g1, g2;
Mat disp, disp1, disp2;
img1 = imread("tsukuba1.jpg");
img2 = imread("tsukuba2.jpg");
cvtColor(img1, g1, CV_BGR2GRAY);
cvtColor(img2, g2, CV_BGR2GRAY);
//-----------------------------------------------------------
StereoBM sbm;
sbm.state->SADWindowSize = 5;
sbm.state->numberOfDisparities = 112;
sbm.state->preFilterSize = 5;
sbm.state->preFilterCap = 61;
sbm.state->minDisparity = -39;
sbm.state->textureThreshold = 507;
sbm.state->uniquenessRatio = 0;
sbm.state->speckleWindowSize = 0;
sbm.state->speckleRange = 8;
sbm.state->disp12MaxDiff = 1;
sbm(g1, g2, disp);
normalize(disp, disp1, 0, 255, CV_MINMAX, CV_8U);
StereoSGBM sgbm;
sgbm.SADWindowSize = 5;
sgbm.numberOfDisparities = 192;
sgbm.preFilterCap = 4;
sgbm.minDisparity = -64;
sgbm.uniquenessRatio = 1;
sgbm.speckleWindowSize = 150;
sgbm.speckleRange = 2;
sgbm.disp12MaxDiff = 10;
sgbm.fullDP = false;
sgbm.P1 = 600;
sgbm(g1, g2, disp);
normalize(disp, disp2, 0, 255, CV_MINMAX, CV_8U);sgbm.P2 = 2400;
imshow("left", img1);
imshow("right", img2);
imshow("disp1", disp1);
imshow("disp2", disp2);
cvWaitKey();
return 0;
}
以下是[2]測試結果, 讓新手可以清楚了解到什麼是Disparity Map
參考資料
全站熱搜
留言列表