Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I can't get different convolution results when calling the function successively with different parameters.

 void Gauss_conv(const cv::cuda::GpuMat& src,
    cv::cuda::GpuMat& conv,
    int gauss_size,
    bool convert_to_8bit = true)
{
    cv::Mat gauss_kernel;
    cv::cuda::GpuMat gf_src, gf_gauss, gf_conv;
    std::vector <cv::cuda::GpuMat> gfv_src, gfv_gauss,  gfv_conv;

    src.convertTo(gf_src, CV_32FC3);

    //Split the source image on the GPU
    cv::cuda::split(gf_src, gfv_conv);
    cv::cuda::split(gf_src, gfv_src);

    //Prepare the input image for Gauss filtering
    cv::cuda::copyMakeBorder(gf_src, gf_gauss, 0.5 * gauss_size,
        0.5 * gauss_size, 0.5 * gauss_size, 0.5 * gauss_size,
        cv::BORDER_REPLICATE);
    cv::cuda::split(gf_gauss, gfv_gauss);

    //Create the Gauss kernel and upload it to the GPU
    cv::Ptr < cv::cuda::Convolution> c1 = cv::cuda::createConvolution();
    cv::mulTransposed(cv::getGaussianKernel(gauss_size, -1, CV_32FC1),
        gauss_kernel, false);
    gf_gauss.upload(gauss_kernel);

    //Apply Gaussian blur to all channels independently, also compute subtraction image
    for (int i = 0; i < src.channels(); i++)
    {
        c1->convolve(gfv_gauss[i], gf_gauss, gfv_conv[i], true);
    }

    cv::cuda::merge(gfv_conv, conv);

}

//in main

Gauss_conv(gpu_src_uchar, conv1, 131, true); //131
Gauss_conv(gpu_src_uchar, conv2, 531, true); //531
Gauss_conv(gpu_src_uchar, conv3, 1631, true); //1631

I want three different convolution results: conv1, conv2, and conv3. But I got the same result of conv1 for all cases. Can someone help me fix this problem.