I am currently working on a Blazor component that requires opencv.
I've added opencv.js
(4.8.0) in wwwroot
.
Here is my html file:
<script async src="_content/MyComponent/opencv.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
I keep getting the following error :
Failed to start platform. Reason: Error: MONO_WASM: Module.ready couldn't be redefined.
at Vt (blazor.webassembly.js:1:62226)
I am very new to Blazor/Js and since I don't really understand how wasm works under the hood, it's hard for me to even understand the error.
Any documentation or explanation would be greatly appreciated.
Here is how I fixed my issue:
if (typeof Module === 'undefined')
Module = {};
return cv(Module);
}));
replace with
if (typeof OpenCvModule === 'undefined')
OpenCvModule = {};
return cv(OpenCvModule);
}));
Module
variable is apparently conflicting between Blazor's wasm and opencv.
Side note: to make sure that your script gets reloaded in your browser, rename it (do not forget the html file). Blazor's cache handling could be really annoying.