Simplicity
Simplicity

Reputation: 48926

Error when using cv::addWeighted

I was walking through an example, and got an error on the following line after running the code

cv::addWeighted(temp_image, 1.0, noise_image, 1.0, 0.0, temp_image);

This is the error:

libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/abd/Documents/opencv-3.0.0/modules/core/src/arithm.cpp:1987: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op

This is the error. How can I solve it?

Thanks.

Upvotes: 0

Views: 1212

Answers (1)

Berriel
Berriel

Reputation: 13611

You need to make sure that temp_image and noise_image have the same size and channel number. Usually, it happens when one of the images is BGR and the other is GRAY.

Upvotes: 1

Related Questions