Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Multiplying a Mat against another Mat on a GPU

I can multiply a 10801920 pixel CV_32FC1 mat against another 33 Mat when using CPU based OpenCV, but when I convert the code to be Gpu Based, I get an error. Here is my CPU code

float matrix[3][3] = {{1.057311, -0.204043, 0.055648}, { 0.041556, 1.875992, -0.969256}, {-0.498535,-1.537150, 3.240479}};

Mat matrixMat = Mat(3, 3, CV_32FC1, matrix).t();

Mat orig_img_linear = linearMat.reshape(1, 1080*1920); Mat color_matrixed_linear = orig_img_linear * matrixMat; Mat final_color_matrixed = color_matrixed_linear.reshape(3, 1080);

When I run the following Gpu code, I get an error:

cv::gpu::multiply(orig_img_linear, matrixMat, color_matrixed_linear);

OpenCV Error: Assertion failed (src2.type() == src1.type() && src2.size() == src1.size()) in multiply, file /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp, line 934 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934: error: (-215) src2.type() == src1.type() && src2.size() == src1.size() in function multiply

Is there a way to accomplish the CPU code with the GPU?

Multiplying a Mat against another Mat on a GPU

I can multiply a 10801920 pixel CV_32FC1 mat against another 33 Mat when using CPU based OpenCV, but when I convert the code to be Gpu Based, I get an error. Here is my CPU code

float matrix[3][3] = {{1.057311, -0.204043, 0.055648}, { 0.041556, 1.875992, -0.969256}, {-0.498535,-1.537150, 3.240479}};

Mat matrixMat = Mat(3, 3, CV_32FC1, matrix).t();

Mat orig_img_linear = linearMat.reshape(1, 1080*1920); Mat color_matrixed_linear = orig_img_linear * matrixMat; Mat final_color_matrixed = color_matrixed_linear.reshape(3, 1080);

When I run the following Gpu code, I get an error:

cv::gpu::multiply(orig_img_linear, matrixMat, color_matrixed_linear);

OpenCV Error: Assertion failed (src2.type() == src1.type() && src2.size() == src1.size()) in multiply, file /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp, line 934 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934: error: (-215) src2.type() == src1.type() && src2.size() == src1.size() in function multiply

I assume from the error that the problem is that my two arrays' sizes are different. Is there a way to accomplish the CPU code with the GPU?

Multiplying a Mat against another Mat on a GPU

I can multiply a 10801920 1080X1920 pixel CV_32FC1 mat against another 33 3X3 Mat when using CPU based OpenCV, but when I convert the code to be Gpu Based, I get an error. Here is my CPU code

float matrix[3][3] = {{1.057311, -0.204043, 0.055648}, { 0.041556, 1.875992, -0.969256}, {-0.498535,-1.537150, 3.240479}};

Mat matrixMat = Mat(3, 3, CV_32FC1, matrix).t();

Mat orig_img_linear = linearMat.reshape(1, 1080*1920); Mat color_matrixed_linear = orig_img_linear * matrixMat; Mat final_color_matrixed = color_matrixed_linear.reshape(3, 1080);

When I run the following Gpu code, I get an error:

cv::gpu::multiply(orig_img_linear, matrixMat, color_matrixed_linear);

OpenCV Error: Assertion failed (src2.type() == src1.type() && src2.size() == src1.size()) in multiply, file /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp, line 934 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934: error: (-215) src2.type() == src1.type() && src2.size() == src1.size() in function multiply

I assume from the error that the problem is that my two arrays' sizes are different. Is there a way to accomplish the CPU code with the GPU?

Multiplying a Mat against another Mat on a GPU

I can multiply a 1080X1920 pixel CV_32FC1 mat against another 3X3 Mat when using CPU based OpenCV, but when I convert the code to be Gpu Based, I get an error. Here is my CPU code

float matrix[3][3] = {{1.057311, -0.204043, 0.055648}, { 0.041556, 1.875992, -0.969256}, {-0.498535,-1.537150, 3.240479}};

Mat matrixMat = Mat(3, 3, CV_32FC1, matrix).t();

Mat orig_img_linear = linearMat.reshape(1, 1080*1920); Mat color_matrixed_linear = orig_img_linear * matrixMat; Mat final_color_matrixed = color_matrixed_linear.reshape(3, 1080);

When I run the following Gpu code, I get an error:

cv::gpu::multiply(orig_img_linear, matrixMat, color_matrixed_linear);

OpenCV Error: Assertion failed (src2.type() == src1.type() && src2.size() == src1.size()) in multiply, file /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp, /Users/user/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp, line 934 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/patrickcusack/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934: /Users/user/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934: error: (-215) src2.type() == src1.type() && src2.size() == src1.size() in function multiply

I assume from the error that the problem is that my two arrays' sizes are different. Is there a way to accomplish the CPU code with the GPU?

click to hide/show revision 5
No.5 Revision

updated 2016-03-18 00:53:44 -0600

berak gravatar image

Multiplying a Mat against another Mat on a GPU

I can multiply a 1080X1920 pixel CV_32FC1 mat against another 3X3 Mat when using CPU based OpenCV, but when I convert the code to be Gpu Based, I get an error. Here is my CPU code

 float matrix[3][3] = {{1.057311,
{{1.057311, -0.204043, 0.055648},
  { 0.041556, 1.875992, -0.969256},
 {-0.498535,-1.537150, 3.240479}};

3.240479}}; Mat matrixMat = Mat(3, 3, CV_32FC1, matrix).t();

CV_32FC1, matrix).t(); Mat orig_img_linear = = linearMat.reshape(1, 1080*1920); Mat color_matrixed_linear = = orig_img_linear * matrixMat; Mat final_color_matrixed = color_matrixed_linear.reshape(3, 1080);

= color_matrixed_linear.reshape(3, 1080);

When I run the following Gpu code, I get an error:

cv::gpu::multiply(orig_img_linear,

cv::gpu::multiply(orig_img_linear, matrixMat, color_matrixed_linear);

color_matrixed_linear); OpenCV Error: Assertion failed failed (src2.type() == src1.type() && && src2.size() == src1.size()) in in multiply, file /Users/user/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp, line 934 libc++abi.dylib: terminating terminating with uncaught exception of type cv::Exception: /Users/user/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934: error: (-215) src2.type() == == src1.type() && src2.size() == == src1.size() in function multiply

multiply

I assume from the error that the problem is that my two arrays' sizes are different. Is there a way to accomplish the CPU code with the GPU?

click to hide/show revision 6
No.6 Revision

updated 2016-03-18 00:55:19 -0600

berak gravatar image

Multiplying a Mat against another Mat on a GPU

I can multiply a 1080X1920 pixel CV_32FC1 mat against another 3X3 Mat when using CPU based OpenCV, but when I convert the code to be Gpu Based, I get an error. Here is my CPU code

 float matrix[3][3] = {{1.057311, -0.204043, 0.055648},
                                { 0.041556, 1.875992, -0.969256},
                                {-0.498535,-1.537150, 3.240479}};

 Mat matrixMat = Mat(3, 3, CV_32FC1, matrix).t();

 Mat orig_img_linear = linearMat.reshape(1, 1080*1920); Mat
 1080*1920);
 Mat color_matrixed_linear = orig_img_linear * matrixMat; Mat
 
 Mat final_color_matrixed = color_matrixed_linear.reshape(3, 1080);

When I run the following Gpu code, I get an error:

cv::gpu::multiply(orig_img_linear, matrixMat, color_matrixed_linear);

 OpenCV Error: Assertion failed (src2.type() == src1.type() && src2.size() == src1.size())  in multiply, file
file  /Users/user/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp,
 line 934 libc++abi.dylib: terminating with uncaught exception of type
 cv::Exception:
 /Users/user/Downloads/opencv-2.4.11/modules/gpu/src/element_operations.cpp:934:
 error: (-215) src2.type() == src1.type() && src2.size() == src1.size() in function multiply

I assume from the error that the problem is that my two arrays' sizes are different. Is there a way to accomplish the CPU code with the GPU?