简体   繁体   English

Ionic 4 WebAssembly 未在旧手机上使用 OpenCV 定义

[英]Ionic 4 WebAssembly is not defined with OpenCV on an older phone

I am trying to develop a simple image processing mobile application using the Ionic Framework (version 4).我正在尝试使用Ionic Framework(版本 4)开发一个简单的图像处理移动应用程序。 I decided to use the OpenCV.js library and the way I am adding it to my ionic project is:我决定使用OpenCV.js库,我将它添加到我的ionic项目中的方式是:

1) I put the opencv.js file in app/assets/lib/opencv.js 1) 我把opencv.js文件放在app/assets/lib/opencv.js

2) I added 2)我补充说

 "scripts": [
          "src/assets/lib/opencv.js"
        ]

in my angular.json file.在我的angular.json文件中。

3) I put declare var cv: any; 3)我把declare var cv: any; on top of any ts file that I needed to use the opencv library in and then I just use cv to reference an opencv.js function like for example cv.imread(image) .在我需要使用 opencv 库的任何 ts 文件之上,然后我只使用 cv 来引用 opencv.js 函数,例如cv.imread(image)

My application works well in the browser, as well as on some test devices (I've tried Galaxy Note 10 , Galaxy S8 , Galaxy S6 ).我的应用程序在浏览器以及一些测试设备上运行良好(我已经尝试过Galaxy Note 10Galaxy S8Galaxy S6 )。 However, when I try to run the application on a Samsung Galaxy S5 , the app shows an error on the console upon startup:但是,当我尝试在Samsung Galaxy S5上运行该应用程序时,该应用程序在启动时在控制台上显示错误:

Uncaught ReferenceError: WebAssembly is not defined

and then, when I click a button that calls anything related to openCV I get the following message:然后,当我单击一个调用与 openCV 相关的任何内容的按钮时,我收到以下消息:

ERROR Error: Uncaught (in promise): ReferenceError: cv is not defined错误错误:未捕获(承诺):ReferenceError:未定义 cv

And of couse the openCV functinality does not work.当然, openCV功能不起作用。 I realize it must be something related to the phone being pretty old, but I would like to know exactly the reason why it works on other phones but does not on this one.我意识到这一定与手机太旧有关,但我想确切地知道它在其他手机上工作但在这个手机上不起作用的原因。 And maybe, if it is possible, it would be great to find out what can be done to make it work on this and other phones like this.也许,如果可能的话,找出可以做些什么来让它在这个和其他类似的手机上工作会很棒。

It is a Samsung Galaxy S5 with Android 5.0 .它是配备Android 5.0Samsung Galaxy S5

Also I do not really understand why WebAssembly is required in this particular case.我也不太明白为什么在这种特殊情况下需要 WebAssembly。 I thought the opencv.js file that I downloaded from here https://docs.opencv.org/master/opencv.js was just a JS file that contains the necessary functions (like a lib).我以为我从这里下载的 opencv.js 文件https://docs.opencv.org/master/opencv.js只是一个包含必要功能(如 lib)的 JS 文件。 How does webassembly come into play here? webassembly 如何在这里发挥作用?

The error reported indicates that the device and browser you are using does not have support for WebAssembly.报错说明您使用的设备和浏览器不支持WebAssembly。 For an overview of support see the following:有关支持的概述,请参阅以下内容:

https://caniuse.com/#feat=wasm https://caniuse.com/#feat=wasm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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