Performing reshape on GpuMat cause unexpected error

Hi,

I am trying to perform a color correction operation on GPU. Basically what I do is reading a pic, uploading to GPU, matrix multiplying GpuMat by a color correction 3*3 GpuMat matrix and downloading result to CPU for display.

I use cv::cuda::gemm for CUDA based matrix multiplication, therefore I need to reshape original CV_32FC3 GpuMat Image to CV_32FC1 in advance, since gemm will not accept CV_32FC3 type.

However when I do:

cuda::GpuMat d_img.upload(h_img);
cuda::GpuMat d_temp=d_img.reshape(1,h_img.size().width*h_Img.size().height);

It will throw out unexpected error at cuda::GpuMat::reshape.

Meanwhile, if I perform the same reshape task on CPU:

Mat h_img;
h_img=imread("some pic");
Mat h_temp=h_img.reshape(1,h_img.size().height*h_img.size().width);

Everything works just as fine. My question is how to perform reshape on GpuMat, or is there any other ways to perform Matrix multiplication on two GpuMat other than cv::cuda::gemm.

Thanks.
Steven

BTW, the error been thrown out is “The matrix is not continuous”