简体   繁体   中英

How to get OpenCV (javascript edition) working on Internet Explorer 11?

I'm trying to get OpenCV javascript version working on IE11 for contour detection. My code works on every other modern browser, but I'm getting errors like:

TypeError: Object doesn't support this action

The line of code of the OpenCV library where I'm getting this error is:

var imgData=new ImageData(new Uint8ClampedArray(img.data),img.cols,img.rows);

So it seems IE11 doesn't support that syntax. I've been trying to find some polyfill to make it work, but no luck for now.

So anyone knows how to make this work on IE11?

Thanks.

IE Browser not support the ImageData() constructor , you could try to use the CanvasRenderingContext2D.createImageData() method to create the ImageData object .

Code like this:

const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');

const imageData = ctx.createImageData(100, 50);
console.log(imageData);
// ImageData { width: 100, height: 50, data: Uint8ClampedArray[20000] }

I ended up using a polyfill for this one and now it works with IE11.

I did some changes for my particular use case, but this gist is the following:

https://gist.github.com/Convicted202/7684bc8113b3011b4a6a1b2aa9f7a36f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM