added methods estimateRecopmmendedParams for StereoBP and StereoCSBP
This commit is contained in:
		@@ -235,7 +235,7 @@ namespace cv
 | 
			
		||||
 | 
			
		||||
        class CV_EXPORTS CudaMem
 | 
			
		||||
        {
 | 
			
		||||
        public:            
 | 
			
		||||
        public:
 | 
			
		||||
            enum  { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
 | 
			
		||||
 | 
			
		||||
            CudaMem();
 | 
			
		||||
@@ -266,7 +266,7 @@ namespace cv
 | 
			
		||||
            Mat createMatHeader() const;
 | 
			
		||||
            operator Mat() const;
 | 
			
		||||
 | 
			
		||||
            //! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.            
 | 
			
		||||
            //! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.
 | 
			
		||||
            GpuMat createGpuMatHeader() const;
 | 
			
		||||
            operator GpuMat() const;
 | 
			
		||||
 | 
			
		||||
@@ -342,7 +342,7 @@ namespace cv
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        ////////////////////////////// Image processing //////////////////////////////
 | 
			
		||||
        // DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation. 
 | 
			
		||||
        // DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
 | 
			
		||||
        // xymap.type() == xymap.type() == CV_32FC1
 | 
			
		||||
        CV_EXPORTS void remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, GpuMat& dst);
 | 
			
		||||
 | 
			
		||||
@@ -376,7 +376,7 @@ namespace cv
 | 
			
		||||
 | 
			
		||||
            //! the default constructor
 | 
			
		||||
            StereoBM_GPU();
 | 
			
		||||
            //! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8. 
 | 
			
		||||
            //! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8.
 | 
			
		||||
            StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
 | 
			
		||||
 | 
			
		||||
            //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair
 | 
			
		||||
@@ -405,7 +405,7 @@ namespace cv
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        ////////////////////////// StereoBeliefPropagation ///////////////////////////
 | 
			
		||||
        // "Efficient Belief Propagation for Early Vision" 
 | 
			
		||||
        // "Efficient Belief Propagation for Early Vision"
 | 
			
		||||
        // P.Felzenszwalb
 | 
			
		||||
 | 
			
		||||
        class CV_EXPORTS StereoBeliefPropagation
 | 
			
		||||
@@ -415,6 +415,8 @@ namespace cv
 | 
			
		||||
            enum { DEFAULT_ITERS  = 5  };
 | 
			
		||||
            enum { DEFAULT_LEVELS = 5  };
 | 
			
		||||
 | 
			
		||||
            static void estimateRecopmmendedParams( int width, int height, int & ndisp, int & iters, int & levels);
 | 
			
		||||
 | 
			
		||||
            //! the default constructor
 | 
			
		||||
            explicit StereoBeliefPropagation(int ndisp  = DEFAULT_NDISP,
 | 
			
		||||
                                             int iters  = DEFAULT_ITERS,
 | 
			
		||||
@@ -436,7 +438,7 @@ namespace cv
 | 
			
		||||
            //! Acync version
 | 
			
		||||
            void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            //! version for user specified data term
 | 
			
		||||
            void operator()(const GpuMat& data, GpuMat& disparity);
 | 
			
		||||
            void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream);
 | 
			
		||||
@@ -460,7 +462,7 @@ namespace cv
 | 
			
		||||
 | 
			
		||||
        /////////////////////////// StereoConstantSpaceBP ///////////////////////////
 | 
			
		||||
        // "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
 | 
			
		||||
        // Qingxiong Yang, Liang Wang<6E>, Narendra Ahuja         
 | 
			
		||||
        // Qingxiong Yang, Liang Wang<6E>, Narendra Ahuja
 | 
			
		||||
        // http://vision.ai.uiuc.edu/~qyang6/
 | 
			
		||||
 | 
			
		||||
        class CV_EXPORTS StereoConstantSpaceBP
 | 
			
		||||
@@ -471,6 +473,8 @@ namespace cv
 | 
			
		||||
            enum { DEFAULT_LEVELS   = 4   };
 | 
			
		||||
            enum { DEFAULT_NR_PLANE = 4   };
 | 
			
		||||
 | 
			
		||||
            static void estimateRecopmmendedParams( int width, int height, int & ndisp, int & iters, int & levels, int & nr_plane);
 | 
			
		||||
 | 
			
		||||
            //! the default constructor
 | 
			
		||||
            explicit StereoConstantSpaceBP(int ndisp    = DEFAULT_NDISP,
 | 
			
		||||
                                           int iters    = DEFAULT_ITERS,
 | 
			
		||||
@@ -524,7 +528,7 @@ namespace cv
 | 
			
		||||
 | 
			
		||||
        /////////////////////////// DisparityBilateralFilter ///////////////////////////
 | 
			
		||||
        // Disparity map refinement using joint bilateral filtering given a single color image.
 | 
			
		||||
        // Qingxiong Yang, Liang Wang<6E>, Narendra Ahuja         
 | 
			
		||||
        // Qingxiong Yang, Liang Wang<6E>, Narendra Ahuja
 | 
			
		||||
        // http://vision.ai.uiuc.edu/~qyang6/
 | 
			
		||||
 | 
			
		||||
        class CV_EXPORTS DisparityBilateralFilter
 | 
			
		||||
 
 | 
			
		||||
@@ -77,6 +77,19 @@ namespace
 | 
			
		||||
    const float DEFAULT_DISC_SINGLE_JUMP = 1.0f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void cv::gpu::StereoBeliefPropagation::estimateRecopmmendedParams( int width, int height, int & ndisp, int & iters, int & levels)
 | 
			
		||||
{
 | 
			
		||||
    ndisp = width / 4;
 | 
			
		||||
    if (ndisp & 1 != 0) ndisp++;
 | 
			
		||||
 | 
			
		||||
    int mm =::max(width, height);
 | 
			
		||||
    iters = mm / 100 + 2;
 | 
			
		||||
 | 
			
		||||
    levels = (int)(log(mm) + 1) * 4 / 5;
 | 
			
		||||
    if (levels == 0) levels++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cv::gpu::StereoBeliefPropagation::StereoBeliefPropagation(int ndisp_, int iters_, int levels_, int msg_type_)
 | 
			
		||||
    : ndisp(ndisp_), iters(iters_), levels(levels_),
 | 
			
		||||
      max_data_term(DEFAULT_MAX_DATA_TERM), data_weight(DEFAULT_DATA_WEIGHT),
 | 
			
		||||
@@ -117,7 +130,7 @@ namespace
 | 
			
		||||
            CV_DbgAssert(left.rows == right.rows && left.cols == right.cols && left.type() == right.type());
 | 
			
		||||
            CV_Assert(left.type() == CV_8UC1 || left.type() == CV_8UC3);
 | 
			
		||||
 | 
			
		||||
            rows = left.rows; 
 | 
			
		||||
            rows = left.rows;
 | 
			
		||||
            cols = left.cols;
 | 
			
		||||
 | 
			
		||||
            int divisor = (int)pow(2.f, rthis.levels - 1.0f);
 | 
			
		||||
@@ -134,14 +147,14 @@ namespace
 | 
			
		||||
 | 
			
		||||
            calcBP(disp, stream);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        void operator()(const GpuMat& data, GpuMat& disp, const cudaStream_t& stream)
 | 
			
		||||
        {
 | 
			
		||||
            CV_Assert((data.type() == rthis.msg_type) && (data.rows % rthis.ndisp == 0));
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            rows = data.rows / rthis.ndisp;
 | 
			
		||||
            cols = data.cols;
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            int divisor = (int)pow(2.f, rthis.levels - 1.0f);
 | 
			
		||||
            int lowest_cols = cols / divisor;
 | 
			
		||||
            int lowest_rows = rows / divisor;
 | 
			
		||||
@@ -198,7 +211,7 @@ namespace
 | 
			
		||||
            rows_all.resize(rthis.levels);
 | 
			
		||||
 | 
			
		||||
            cols_all[0] = cols;
 | 
			
		||||
            rows_all[0] = rows;           
 | 
			
		||||
            rows_all[0] = rows;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void calcBP(GpuMat& disp, const cudaStream_t& stream)
 | 
			
		||||
@@ -279,14 +292,14 @@ void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& left, const GpuM
 | 
			
		||||
    impl(left, right, disp, StreamAccessor::getStream(stream));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disp) 
 | 
			
		||||
{ 
 | 
			
		||||
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disp)
 | 
			
		||||
{
 | 
			
		||||
    ::StereoBeliefPropagationImpl impl(*this, u, d, l, r, u2, d2, l2, r2, datas, out);
 | 
			
		||||
    impl(data, disp, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disp, Stream& stream) 
 | 
			
		||||
{ 
 | 
			
		||||
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disp, Stream& stream)
 | 
			
		||||
{
 | 
			
		||||
    ::StereoBeliefPropagationImpl impl(*this, u, d, l, r, u2, d2, l2, r2, datas, out);
 | 
			
		||||
    impl(data, disp, StreamAccessor::getStream(stream));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -105,6 +105,20 @@ namespace
 | 
			
		||||
    const float DEFAULT_DISC_SINGLE_JUMP = 10.0f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void cv::gpu::StereoConstantSpaceBP::estimateRecopmmendedParams( int width, int height, int & ndisp, int & iters, int & levels, int &nr_plane)
 | 
			
		||||
{
 | 
			
		||||
    ndisp = (int) ((float) width / 3.14f);
 | 
			
		||||
    if (ndisp & 1 != 0) ndisp++;
 | 
			
		||||
 | 
			
		||||
    int mm = ::max(width, height);
 | 
			
		||||
    iters = mm / 100 + ((mm > 1200)? - 4 : 4);
 | 
			
		||||
 | 
			
		||||
    levels = (int)log(mm) * 2 / 3;
 | 
			
		||||
    if (levels == 0) levels++;
 | 
			
		||||
 | 
			
		||||
    nr_plane = (int) ((float) ndisp / pow(2.0, levels + 1));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cv::gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int ndisp_, int iters_, int levels_, int nr_plane_,
 | 
			
		||||
                                                      int msg_type_)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user