Decreasing size of opencv.js
Hello there.
I'm trying to use Vue.js and webpack with opencv. I followed the tutorial in the docs to compile to js from sources. However, when I try to integrate the resulting js file, I'm getting a "javascript heap out of memory" error. The file works when used in a very simple server environment though. I tried increasing the heap, but the build won't ever finish. I have no idea how to resolve this issue, but to maybe decrease the size of the file. is there a way to pick which classes to compile into the js file? for example, I personally only need the image preprocessing stack. Besides that: Do i have to compile opencv to js or is there another source for a js implementation?
Any help would be greatly appreciated. Thx.
btw, you can also use the prebuilt opencv.js and utils.js from the master docs
(it's still huge ! (~11mb))
Wow, thx! How did you find that? I can't find any path there other than your direct link.
by following the js tutorial src code (there's an iframe for each example, and that has the links)
i also found an older, 3.3.0 version of opencv.js on my box, that only had 6.8 mb, so it has grown significantly with latest version !
@berak could you upload the older version of opencv.js, and send me download link please ?
sorry, but i can't. (don't have any older version)
anyone got ant useful ideas on how to reduce the size of opencv.js? it's very big to be used on a mobile. I'm using very little of the total set of features so could cut down on it? it is minified though so pretty unintelligible on my end. thanks
Use a CDN like DropBox and cache repeated requests.
https://docs.opencv.org/3.3.1/opencv.js
https://docs.opencv.org/
Newer versions may have improvements.
Interested to know if there is an answer to this. I am also using opencv.js in Vue, specifically single file components. There is also the problem with the emscripten runtime not loading but that’s another issue. (I got around that by including opencv in the index.html as opposed to importing it locally in the .vue file) In any case, once you got passed that, you still have the minor issue that your smallish app is now > 8MB in size
Harsh reality? Recently, another thread mentioned they compiled it at 2MB. You could run your own server and make a request if you must solve a filesize bottleneck... but Google and AWS also offer cloud services. It's not meant to be trivial or a one-liner!