OpenCV.js smaller package

asked 2019-02-22 10:08:37 -0600

robertral gravatar image

Hi there,

Is it possible to cheery pick modules from OpenCV.js as the package size is >>8mb so mobile users will struggle to download this in a reasonable time. I'm looking down the webpack route, but if anyone has any suggestions on how to make the package size smaller then please let me know. Thanks in advance

Paul

edit retag flag offensive close merge delete

Comments

1

You can try to build OpenCV with WASM support. It takes less size. But it's a good idea to split opencv.js to smallest parts. I.e. opencv_core.js or opencv_features2d.js or opencv_dnn.js. This way these libraries will contain only modules from suffix and their dependencies.

dkurt gravatar imagedkurt ( 2019-02-22 12:53:46 -0600 )edit

Thanks for your advice. I added WASM support and then manually changed the -DBUILD_opencv_xxx flags to OFF and I've managed to get it down to about 4.2MB from 8.4MB. I will have a proper look now to see if I can reduce it even further as I only really require the CORE.

robertral gravatar imagerobertral ( 2019-02-25 04:25:42 -0600 )edit

Any update on further reducing size? I am also interested in helping this effort.

JoeSquishy gravatar imageJoeSquishy ( 2019-03-19 06:14:16 -0600 )edit

Same here I only need core but currently I am loading a 7MB OpenCV.js file into a web app. It would be really nice and useful to have OpenCV as npm package and be able to cheery pick what is imported using ES6 Modules import style. There are a few things out there on npm but none of those solutions seem official aside from OpenCV.js from OpenCV site.

ludovic.vignals gravatar imageludovic.vignals ( 2020-02-07 12:57:41 -0600 )edit