shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.37k stars 1.15k forks source link

System.TypeInitializationException: The type initializer for 'OpenCvSharp.Internal.NativeMethods' #1563

Open Robinbr21 opened 1 year ago

Robinbr21 commented 1 year ago

Summary of your issue

---> System.DllNotFoundException: Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libOpenCvSharpExtern: cannot open shared object file: No such file or directory at OpenCvSharp.Internal.NativeMethods.redirectError(CvErrorCallback errCallback, IntPtr userdata, IntPtr& prevUserdata) at OpenCvSharp.Internal.ExceptionHandler.RegisterExceptionCallback() at OpenCvSharp.Internal.NativeMethods.LoadLibraries(IEnumerable`1 additionalPaths) at OpenCvSharp.Internal.NativeMethods..cctor()

Environment

Ubuntu 18.04.6 LTS i also encounterd the same issue on Mac OS ,, but there is no issue in Windows system

Example code:

           string imagePath = Environment.GetEnvironmentVariable("HOME") +"/Pictures/Screenshot.png";
            Mat image = Cv2.ImRead(imagePath, ImreadModes.Unchanged);
            DetectSensitiveAreas(image);

the error hits on second line

ax-meyer commented 1 year ago

Having the same issue on an up2date M1 Air. Really annoying since I am trying to port some apps to Avalonia to be multiplatform, and now its an OpenCV issue being a show-stopper...