🏠 back to Observable

How can I process Uint8ClampedArray using OpenCV.JS?

I’m reading RGBA images using HTML canvas. So, I have data in Uint8ClampedArray format. Now I want to process Uint8ClampedArray data using OpenCV.JS in Observablehq notebook. I found one forum post for converting Uint8ClampedArray to OpenCV matrix here https://stackoverflow.com/questions/57830254/convert-canvas-imagedata-uint8clampedarray-to-opencv-matrix-brg-or-grey-usin. But I am getting the below error

BindingError {name: 'BindingError', message: 'Cannot pass "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0…0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" as a Mat', stack: 'BindingError: Cannot pass "0,0,0,0,0,0,0,0,0,0,0,0…leusercontent.com/next/worker-fa89dfea.js:2:42915'}
message: "Cannot pass \"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
name: "BindingError"
stack: "BindingError: Cannot pass \"0,0,0,0,0,0,0,0,0,0,0
[[Prototype]]: Error

I’m looking for a way to process Uint8ClampedArray data using OpenCV.JS in Observablehq notebook. Any help will be highly appreciable.

At first glance you’re specifying cv.CV_8UC3, but Uint8ClampedArray is RGBA (32bit).

Please also share the link to a notebook with your (ideally simplified) code.