Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

addWeighted in OpenCV JS

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

image description

How can I fix this?

addWeighted in OpenCV JS

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)

image description

How can I fix this?