How to solve memory leak problem when using opencv.js?
I am using opencv.js to process images upload by user but met memory leak problem. I have tried the same code as opencv.js document but still met the problem.
Here is my code:
let land = window.cv.imread("land-show");
let mask = window.cv.imread("mask-show");
let sky = window.cv.imread("sky-show");
window.cv.threshold(mask, mask, parseFloat(trackBarValue), parseFloat(trackBarValue), window.cv.THRESH_TRUNC);
let mat = mask.clone();
window.cv.resize(sky, sky, land.size());
window.cv.resize(mask, mask, land.size());
sky.convertTo(sky, window.cv.CV_64FC4, 1);
mask.convertTo(mask, window.cv.CV_64FC4, 1 / 255);
land.convertTo(land, window.cv.CV_64FC4, 1);
sky = sky.mul(mask, 1);
window.cv.cvtColor(mat, mat, window.cv.COLOR_RGBA2RGB, 0);
window.cv.bitwise_not(mat, mat)
window.cv.cvtColor(mat, mat, window.cv.COLOR_RGB2RGBA, 0);
mat.convertTo(mat, window.cv.CV_64FC4, 1 / 255);
land = land.mul(mat, 1);
window.cv.add(land, sky, land);
land.convertTo(land, window.cv.CV_8UC4, 1);
window.cv.imshow("output", land);
land.delete();
mask.delete();
sky.delete();
mat.delete();
use stack trace for idle process (i.e. weatherbug) in dev tool