csbp_crash.cpp
1 | #include <iostream> |
---|---|
2 | #include <fstream> |
3 | #include <opencv2/highgui/highgui.hpp> |
4 | #include <opencv2/calib3d/calib3d.hpp> |
5 | #include <opencv2/imgproc/imgproc.hpp> |
6 | #include <opencv2/gpu/gpu.hpp> |
7 | |
8 | using namespace std; |
9 | using namespace cv; |
10 | using namespace cv::gpu; |
11 | |
12 | int main(int argc, char **argv) |
13 | { |
14 | |
15 | resetDevice(); |
16 | |
17 | string sImg1="left.png"; |
18 | string sImg2="right.png"; |
19 | string sOut="disp.png"; |
20 | int lNumDisparities=144; |
21 | |
22 | Mat img_left = imread(sImg1, IMREAD_GRAYSCALE); |
23 | Mat img_right = imread(sImg2, IMREAD_GRAYSCALE); |
24 | GpuMat imgLeftGPU(img_left); |
25 | GpuMat imgRightGPU(img_right); |
26 | GpuMat imgDispGPU(img_left.size(), CV_16SC1); |
27 | |
28 | int ndisp; int iters; int levels; int nr_plane; |
29 | gpu::StereoConstantSpaceBP::estimateRecommendedParams(img_left.cols,img_left.rows,ndisp,iters,levels,nr_plane); |
30 | gpu::StereoConstantSpaceBP bp(lNumDisparities,iters,levels,nr_plane,CV_16SC1); |
31 | bp.use_local_init_data_cost=false;
|
32 | bp(imgLeftGPU,imgRightGPU,imgDispGPU); |
33 | |
34 | Mat imgDisp(img_left.size(), CV_16SC1); |
35 | imgDispGPU.download(imgDisp); |
36 | imwrite(sOut,imgDisp); |
37 | return 0; |
38 | } |