GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo) { cv::gpu::DeviceInfo devInfo = GetParam(); cv::gpu::setDevice(devInfo.deviceID()); cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img_l_host.empty()); cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img_r_host.empty()); cv::gpu::StereoConstantSpaceBP csbp(128); cv::gpu::GpuMat img_l(img_l_host); cv::gpu::GpuMat img_r(img_r_host); cv::gpu::GpuMat dst; csbp(img_l, img_r, dst); declare.time(10.0); TEST_CYCLE() { csbp(img_l, img_r, dst); } }
void QtOpenCVZedDemo::doStereoCSBP_OCL(cv::Mat left, cv::Mat right ) { cv::ocl::StereoConstantSpaceBP csbp; int disp, iters, levels, planes; csbp.estimateRecommendedParams( left.cols, left.rows, disp, iters, levels, planes ); csbp.levels = levels; csbp.iters = iters; csbp.ndisp = disp; csbp.nr_plane = planes; if( left.channels() > 1 ) cv::cvtColor( left, left, CV_BGR2GRAY ); if( right.channels() > 1 ) cv::cvtColor( right, right, CV_BGR2GRAY ); cv::ocl::oclMat ocl_left; cv::ocl::oclMat ocl_right; cv::ocl::oclMat ocl_disp; ocl_left.upload( left ); ocl_right.upload( right ); csbp( ocl_left, ocl_right, ocl_disp ); ocl_disp.download( mDisparity ); normalize(mDisparity, mDisparity, 0, 255, CV_MINMAX, CV_8U); }