Search code examples
c#wpfopencvclickonce

OpenCVSharp4 Huge DLLs size


I am trying to user opencvsharp4 package for webcam. I have a click once application but is 18 MB in size in total.

But I can see some of the nativedlls it comes up with OpenCvSharpExtern.dll is 40 MB+, opencv_videoio_ffmpeg480.dll is 22 MB+.

I wonder that will make my application size to 100 MB +.

Is there a way to reduce these dll size in KBs otherwise it is a big negative to use this package -:(

Try to reduce the native dll size or a way to lazy load them.


Solution

  • Is there a way to reduce these dll size

    The short answer is no: the project itself (https://github.com/shimat/opencvsharp) is a wrapper around ALL the existing C++ code and bundles it one nuget package.

    The longer answer is, theoretically yes. The original C++ OpenCV project is divided into separate modules, so it is theoretically possible to build only the modules you need or use and then just use that custom-built version of the library. Here's another SO answer that covers selectively building the C++ project this by changing the CMAKE settings: Build specific modules OpenCV

    However if you go down this route, you have to generate your own C# wrapping PInvoke code yourself.