Ask Your Question
0

addWeighted in OpenCV JS

asked 2018-12-25 06:35:30 -0500

Lucy8 gravatar image

updated 2018-12-25 06:49:24 -0500

I want to use addweighted function with opencv.js. I've attached opencv.js to my HTML

<script src="opencv.js"></script>

And here is the code that I use

const image1 = cv.imread(imgElement);
const image2 = image.clone();  //image2 is cloned from image1  to be sure that they have the same size
const addWeightedMat = new cv.Mat(image1.rows, image1.cols, image1.type());
const alpha = 0.7;
const betta = 0.3;
const gamma = 0;

cv.addWeighted(image1, alpha, image2, betta, addWeightedMat, gamma);

The Error message says

Uncaught TypeError: Cannot convert "[object Object]" to double
at Object.toWireType (opencv.js:24)
at Object.addWeighted (eval at new_ (opencv.js:24), <anonymous>:11:26)
at Object.addWeighted (opencv.js:24)

How can I fix this?

edit retag flag offensive close merge delete

Comments

1

please be so nice, and replace the screenshot of your error with a TEXT version, thank you !

berak gravatar imageberak ( 2018-12-25 06:44:45 -0500 )edit
2

Sure, will replace it

Lucy8 gravatar imageLucy8 ( 2018-12-25 06:47:48 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-12-25 07:20:20 -0500

berak gravatar image

have a look at the docs, you have gamma and dst swapped, it must be:

cv.addWeighted(image1, alpha, image2, beta, gamma, addWeightedMat);
edit flag offensive delete link more

Comments

2

Thank you, it solved my problem

Lucy8 gravatar imageLucy8 ( 2018-12-25 07:36:17 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-25 06:35:30 -0500

Seen: 233 times

Last updated: Dec 25 '18