[英]externalInterface javascript not working in internet explorer 11
[英]How to get OpenCV (javascript edition) working on Internet Explorer 11?
我正在嘗試在IE11上使用OpenCV javascript版本進行輪廓檢測。 我的代碼可在所有其他現代瀏覽器上使用,但出現以下錯誤:
TypeError: Object doesn't support this action
我收到此錯誤的OpenCV庫的代碼行是:
var imgData=new ImageData(new Uint8ClampedArray(img.data),img.cols,img.rows);
因此,似乎IE11不支持該語法。 我一直在嘗試找到一些polyfill來使它工作,但目前還沒有運氣。
因此,有人知道如何在IE11上實現這項功能嗎?
謝謝。
IE瀏覽器不支持ImageData()構造函數 ,您可以嘗試使用CanvasRenderingContext2D.createImageData()方法創建ImageData對象。
像這樣的代碼:
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] }
我最終為此使用了一個polyfill,現在它可以與IE11一起使用。
我針對特定的用例做了一些更改,但是要點如下:
https://gist.github.com/Convicted202/7684bc8113b3011b4a6a1b2aa9f7a36f
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.