I am using opencv.js imported into angular.json. With HTMLCanvasElement nativeelement in Angular 9, certain functions with canvases are working fine. However, the data types for certain Mat instances requires adjustment. For example, when I have to convert a 4 channel matrix to a 3 channel matrix.
I tried the easy way, by using
cv.cvtColor(dst, dst, cv.COLOR_RBGA2RGB);
but I am getting the error "ERROR TypeError: Cannot convert "undefined" to int" at Object.toWireType (opencv.js:21)
I am using the pre-built version of OpenCV.js and
The prototype for my images in my canvas context after it is loaded appears like so:
ImageData {data: Uint8ClampedArray(1048576), width: 512, height: 512}
data: Uint8ClampedArray(1048576) [188, 192, …]
height: 512
width: 512
__proto__: ImageData
I'm guessing this has to do with Angular's type checking, or not. Is there a way to make this function work, or can I create a new mat instance and modify those pointers with javascript elements? Or should I give up trying to integrate this into Angular?