Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Incorrect image from RGBA data

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

image description