justadudewhohacks / justadudewhohacks/opencv4nodejs
Mat noise artifacts being randomly produced
- Dominant language
- C++
- Stars
- 5.1k
- Forks
- 826
- PR merge metrics
- No merged PRs in 30d
Description
# Error Message
# Auto Build - Full Error Log
# Manual Build - Environment Information
*OpenCV version* (example 3.4.1): 5.1.0
*With OpenCV-contrib?* (extra modules): no
*OS*: Windows 7 / 8 / 10? / MacOSX? / Ubuntu?: Windows 10
Generating new cv.Mat()s and adding content by various means frequently, randomly and non-deterministically adds random smatterings of noise, most often when generating smaller-sized Mats (200 x 200 for example, as opposed to 1080 x 720). I have been running into this from several methods, such as drawing in a region with `mat.drawFillPoly`, using `mat.setTo`, and some others.
The severity seems to be random, for example I will use one of these methods to draw a basic mask to use as an overlay elsewhere. I can delete this mask, regenerate it, and a differently shaped bit of noise will be added to the image. The noise seems to originate from the top downwards by varying degrees, sometimes being a few pixels, sometimes being noise covering half the image.
I have checked and simplified everything down to just passing in a few points to generate a basic mask Mat, normal dimensions, nothing complicated, and still see the effect. Any guesses as to what this could be? I have provided the output of me drawing several poly points, filling in the fill region with simple [255,255,255] values.


Edit:
To create these RGB masks (and save the mats to check) I do the following, passing in the image width, height and an array of { x, y } points:
```
export const generatePolyMask = (width, height, points) => {
let p2s = [
points.map((p) => {
return new cv.Point2(p.x, p.y);
}),
];
let maskRGB = new cv.Mat(height, width, cv.CV_8UC3, new cv.Vec3(0, 0, 0));
maskRGB.drawFillPoly(p2s, new cv.Vec3(255, 255, 255), cv.LINE_4);
cv.imwrite('/rgbPolyMask.png', maskRGB);
return maskRGB.splitChannels()[0];
};
```
Contributor guide
Assessment
This issue has not been assessed yet.