Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds 32F disparity support to CUDA DisparityBilateralFilter #3779

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/cudastereo/include/opencv2/cudastereo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class CV_EXPORTS_W DisparityBilateralFilter : public cv::Algorithm
public:
/** @brief Refines a disparity map using joint bilateral filtering.

@param disparity Input disparity map. CV_8UC1 and CV_16SC1 types are supported.
@param disparity Input disparity map. CV_8UC1, CV_16SC1, and CV_32FC1 types are supported.
@param image Input image. CV_8UC1 and CV_8UC3 types are supported.
@param dst Destination disparity map. It has the same size and type as disparity .
@param stream Stream for the asynchronous version.
Expand Down
11 changes: 6 additions & 5 deletions modules/cudastereo/src/cuda/disparity_bilateral_filter.cu
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ namespace cv { namespace cuda { namespace device

const T disp_reg = disp_y[xi];

cost[0] += ::min(cmax_disc, ::abs(disp_reg - dp[0])) * weight;
cost[1] += ::min(cmax_disc, ::abs(disp_reg - dp[1])) * weight;
cost[2] += ::min(cmax_disc, ::abs(disp_reg - dp[2])) * weight;
cost[3] += ::min(cmax_disc, ::abs(disp_reg - dp[3])) * weight;
cost[4] += ::min(cmax_disc, ::abs(disp_reg - dp[4])) * weight;
cost[0] += ::min((float)cmax_disc, (float)::abs(disp_reg - dp[0])) * weight;
cost[1] += ::min((float)cmax_disc, (float)::abs(disp_reg - dp[1])) * weight;
cost[2] += ::min((float)cmax_disc, (float)::abs(disp_reg - dp[2])) * weight;
cost[3] += ::min((float)cmax_disc, (float)::abs(disp_reg - dp[3])) * weight;
cost[4] += ::min((float)cmax_disc, (float)::abs(disp_reg - dp[4])) * weight;
}
}

Expand Down Expand Up @@ -199,6 +199,7 @@ namespace cv { namespace cuda { namespace device

template void disp_bilateral_filter<uchar>(PtrStepSz<uchar> disp, PtrStepSzb img, int channels, int iters, const float *table_color, const float *table_space, size_t table_step, int radius, short, short, cudaStream_t stream);
template void disp_bilateral_filter<short>(PtrStepSz<short> disp, PtrStepSzb img, int channels, int iters, const float *table_color, const float *table_space, size_t table_step, int radius, short, short, cudaStream_t stream);
template void disp_bilateral_filter<float>(PtrStepSz<float> disp, PtrStepSzb img, int channels, int iters, const float *table_color, const float *table_space, size_t table_step, int radius, short, short, cudaStream_t stream);
} // namespace bilateral_filter
}}} // namespace cv { namespace cuda { namespace cudev

Expand Down
4 changes: 2 additions & 2 deletions modules/cudastereo/src/disparity_bilateral_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ namespace
GpuMat& table_color, GpuMat& table_space,
const GpuMat& disp, const GpuMat& img, OutputArray dst, Stream& stream);
const bilateral_filter_operator_t operators[] =
{disp_bilateral_filter_operator<unsigned char>, 0, 0, disp_bilateral_filter_operator<short>, 0, 0, 0, 0};
{disp_bilateral_filter_operator<unsigned char>, 0, 0, disp_bilateral_filter_operator<short>, 0, disp_bilateral_filter_operator<float>, 0, 0};

CV_Assert( 0 < ndisp_ && 0 < radius_ && 0 < iters_ );

GpuMat disp = _disp.getGpuMat();
GpuMat img = _image.getGpuMat();

CV_Assert( disp.type() == CV_8U || disp.type() == CV_16S );
CV_Assert( disp.type() == CV_8U || disp.type() == CV_16S || disp.type() == CV_32F );
CV_Assert( img.type() == CV_8UC1 || img.type() == CV_8UC3 );
CV_Assert( disp.size() == img.size() );

Expand Down