Skip to content

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

@qrzychu

Description

@qrzychu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions