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

[Meta] Bulding opencv.js to integrate a couple of functions from a specific module for use in Node and browser apps #267

Open
aptlin opened this issue Jul 10, 2019 · 4 comments
Labels

Comments

@aptlin
Copy link

aptlin commented Jul 10, 2019

Hi @huningxin and the team, thank you for your extensive work!

TLDR

  1. Is installing opencv.js from NPM the recommended way to use in Node/browsers?

  2. Is there any way to compile a very strict subset of opencv.js (down to several functions, described below) in order to achieve a small bundle size, other than forking opencv, tracing and removing the unneeded files from imgproc, and then compiling with build flags like here?

Explanation

I am a fellow GSoC participant, growing the TF.js model garden. The current model I am working on is text detection based on PSENet, which relies heavily on the opencv imgproc module for post-processing (in particular, the progressive scale expansion algorithm uses ConnectedComponents, and then the results are processed using minAreaRect and boxPoints).

Now I am trying to reproduce these steps in combination with TF.js inference, having stuck in the conundrum how to integrate opencv.js into the pipeline.

There are other implementations like the one from UC Irvine, while the official docs only provide some guidance on how to compile opencv.js locally, so I feel a bit confused about what to do next. The reason why there is no official npm package seems to be just that: opencv is huge and use-cases are often too specific in scope to justify the use of vanilla opencv.js, which blows up the bundle size.

I would love to hear your ideas on how you would achieve the above!

Thank you for your time and effort.

@aptlin aptlin changed the title [Meta] Reasons why there is no official NPM opencv.js module [Meta] Bulding opencv.js to integrate a couple of functions from a specific module for use in Node and browser apps Jul 10, 2019
@Wenzhao-Xiang
Copy link
Collaborator

Hi, @sdll do you mean you want to build a specific subset of opencv.js by yourself?

@aptlin
Copy link
Author

aptlin commented Jul 10, 2019

@Wenzhao-Xiang, I was wondering about that as one of the solutions, yes, since PSENet only requires the imgproc module of opencv, and whether it was the preferred solution in my case, given the size of vanilla opencv.js (~9 mb). Or would you recommend using the opencv.js NPM module, even though it has not been updated for two years?

@huningxin
Copy link
Owner

@sdll , thanks for your comments.

2. Is there any way to compile a very strict subset of opencv.js (down to several functions, described below) in order to achieve a small bundle size, other than forking opencv, tracing and removing the unneeded files from imgproc, and then compiling with build flags like here?

You may need to tweak the function white-list of OpenCV.js to achieve that. The white-list is defined in embindgen.py. You may remove modules except imgproc and core, and unneeded functions of the imgproc module.

  1. Is installing opencv.js from NPM the recommended way to use in Node/browsers?

Regarding to the npm module, it was maintained by @sajjadt . Sajjad, do you have any plans to update the OpenCV.js NPM module?

@aptlin
Copy link
Author

aptlin commented Jul 11, 2019

@huningxin, thank you so much for your help!

@sajjadt, it would be nice to revive the npm package, and probably borrow TypeScript typings from opencv4nodejs. It might also be nice to configure CI for keeping the build up to date with opencv master. I would be more than happy to help with those!

@huningxin huningxin added the other label Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants