Ask Your Question

yiannis's profile - activity

2017-03-06 21:25:06 -0600 received badge  Nice Question (source)
2015-09-21 15:42:45 -0600 received badge  Famous Question (source)
2012-07-13 11:49:05 -0600 received badge  Student (source)
2012-07-13 11:12:44 -0600 received badge  Notable Question (source)
2012-07-13 03:34:37 -0600 received badge  Scholar (source)
2012-07-13 00:56:37 -0600 received badge  Popular Question (source)
2012-07-12 12:20:12 -0600 asked a question How to add 2 Mat objects of different type?

Hi all, When I run the following code:

const Mat A( 10, 20, CV_32FC1, Scalar::all(CV_PI) );
const Mat B( A.size(), CV_8UC1, Scalar::all(10) );
Mat C( A.size(), A.type() );
C = A + B;

I get the run-time error:

    OpenCV Error: Bad argument (When the input arrays in add/subtract/multiply/divide
functions have different types, the output array type must be explicitly specified) in
 arithm_op, file /usr/local/src/OpenCV/modules/core/src/arithm.cpp, line 1269

So, is there a way to explicitly specify the output array type of A+B as float? Thanks