Incorrect image from RGBA data [closed]
Hello, Iam using opencv4nodejs, Where i am creating a Mat with raw RGBA data (1440x1920)
this.mat = new cv.Mat(buff, width, height, cv.CV_8UC4);
this looks to go OK:
Mat {
step: 7680,
elemSize: 4,
sizes: [ 1440, 1920 ],
empty: 0,
depth: 0,
dims: 2,
channels: 4,
type: 24,
cols: 1920,
rows: 1440
}
When i try to write this back to an image with imwrite
const BGR = this.mat.cvtColor(cv.COLOR_RGBA2BGR);
cv.imwrite(`./server/vision/opencv/assets/img${this.count}.jpg`, BGR);
i get the following image, which has 4 vertical sections? Iam not sure where the problem is, reading or writing of the Mat
sorry to say so, but there's no support for opencv4nodejs from opencv, it's an entirely seperate 3rdparty effort, and we cannot help you from here
ah ok,
anyway i found out my stupid mistake, i had width and height mixed up with rows and cols.
if u do that on normal opencv, u will probably get the same output :)
true.