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

Is there a way to trim the OpenCvSharpExtern.dll size? #1735

Open
qrzychu opened this issue Jan 14, 2025 · 0 comments
Open

Is there a way to trim the OpenCvSharpExtern.dll size? #1735

qrzychu opened this issue Jan 14, 2025 · 0 comments

Comments

@qrzychu
Copy link

qrzychu commented Jan 14, 2025

I created the following sample program:

using OpenCvSharp;

using var m = new Mat([100,100], MatType.CV_8SC1);

m.FloodFill(new (0,0), Scalar.White);

m.SaveImage("out.png");

I want to use native AOT to publish it, it works fine, but as usual, the native binaries are included:

image

The size is 85MB. If I need a single function from OpenCV, I increase my app size by 85MB.

Is it possible to have a version of OpenCVSharp that trims the native code? Maybe some kind of code generator, where you have a partial class and you have to specify which methods of Mat you want to use, and it compiles only those?

I am aware that this would require local compilation of the C++ code, but maybe it's worth exploring?

OpenCVSharp is a great piece of tech, but it falls into the category of bloat at some point, especially if you don't need to use the full range of OpenCV functions. If you use Mat in a button in WPF for example, 85MB is big enough that the first time you click it, there is a noticeable delay when it loads into memory.

Reducing the final DLL size would be really benefitial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant