Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM in node #1

Open
bartbutenaers opened this issue Aug 7, 2018 · 1 comment
Open

WASM in node #1

bartbutenaers opened this issue Aug 7, 2018 · 1 comment

Comments

@bartbutenaers
Copy link

Hi @kizerkizer,

Thanks for sharing your example!
I'm struggling already quite some time getting wasm up and running in Node (to run OpenCv.js). Have tried all kind of stuff, but can't get it done. So hopefully you can give me some tips ...

OpenCv is a large C++ program for image processing. Recently they have ported it to Javascript (called OpenCv.js), to make it available for web applications. But I would like to run it in node:

var cv = require('opencv.js');
var matrix = new cv.Mat();
...

The above code uses the non-wasm (i.e. normal javascript) opencv.js file. That works fine in node, but it is VERY slow: takes 15 seconds to do some image processing on a single image. Since they have also build a WASM version of that opencv.js file, I tried to use that one (without success...).

I have installed wabt like in your repo, but some issues:

  • Can use "--expose-wasm" but not "--experimental-modules". Is there perhaps a minimal Node version required for (decent) Webassembly support?
  • When skipping the "--experimental-modules", the following error occurs:
    image

Thanks in advance for your help!
Kind regards,
Bart Butenaers

@bartbutenaers
Copy link
Author

I don't quite understand yet if I need to load in node the .wasm file (like you do) or the opencv.js file that they generated during their wasm build. Do you have any idea about that?

I think you have pointed me in the correct direction (with this repo), but their .wasm file is not usable to be loaded in node. Saw this in my startup log:
image
Seems the original C++ contains __file__ and __dirname__ statements, which is not known by node. And this is only recently fixed in emscripten which is used by the opencv.js project...

So not that easy to run large (converted) wasm projects in node ;-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant