Decreasing size of opencv.js

asked 2018-01-08 11:20:25 -0600

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.

edit retag flag offensive close merge delete

Comments

btw, you can also use the prebuilt opencv.js and utils.js from the master docs

(it's still huge ! (~11mb))

berak gravatar imageberak ( 2018-01-09 03:24:53 -0600 )edit

Wow, thx! How did you find that? I can't find any path there other than your direct link.

ChrisMSurix gravatar imageChrisMSurix ( 2018-01-09 03:44:57 -0600 )edit

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 gravatar imageberak ( 2018-01-09 03:53:32 -0600 )edit

@berak could you upload the older version of opencv.js, and send me download link please ?

Mustafa gravatar imageMustafa ( 2018-06-22 07:24:17 -0600 )edit

sorry, but i can't. (don't have any older version)

berak gravatar imageberak ( 2018-06-22 08:22:46 -0600 )edit
1

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

GJ gravatar imageGJ ( 2018-10-19 10:39:02 -0600 )edit

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.

kpachinger gravatar imagekpachinger ( 2018-11-04 07:31:57 -0600 )edit

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

pfjf20 gravatar imagepfjf20 ( 2020-06-27 02:44:51 -0600 )edit

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!

kpachinger gravatar imagekpachinger ( 2020-07-01 03:11:49 -0600 )edit