opencv-js in webworker

asked 2017-11-08 03:50:03 -0600

Hi, I'm using opencv-js in the WebAssembly version.

I try to out-source CPU-intensive processing to Webworkers. Spawning a webworker and include opencv.js inside the webworker will take several seconds. I think fetching the compiled module from indexedDB might also take about 0.25s.

This implies, I would need to spawn the workers in the beginning and reuse them. For a complex project, this is very unfortunate (queue management needed) and it would be much easier if I could spawn webworkers on demand, in shorter time.

https://stackoverflow.com/questions/4... This post implies, that the compiled Module can be sent to the webworker via postMessage (structured clone).

However, I cannot get this working. At least, I cannot simply send worker.postMessage(cv) or worker.postMessage(Module) or worker.postMessage(WebAssembly.Module), and I get errors that the object cannot be cloned. I think this might be related to the embind-type Module of opencv vs. more low-level wasm access?

Any suggestions or experience?

edit retag flag offensive close merge delete