Incorrect image from RGBA data [closed]

asked 2020-03-29 13:14:18 -0600

Defloyd gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2020-03-29 14:25:53.946686

Comments

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

berak gravatar imageberak ( 2020-03-29 14:25:36 -0600 )edit
1

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 :)

Defloyd gravatar imageDefloyd ( 2020-03-29 14:36:12 -0600 )edit

if u do that on normal opencv, u will probably get the same output

true.

berak gravatar imageberak ( 2020-03-30 03:49:29 -0600 )edit