shimat / opencvsharp

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

[Jetson] libOpenCvSharpExtern: cannot open shared object file: No such file or directory #1266

Closed leopripos closed 2 years ago

leopripos commented 3 years ago

Summary of your issue

I'm trying to use opencvsharp in Jetson. The app is .NET 5 console app. I added OpenCvSharp4 and OpenCvSharp4.runtime.linux-arm. I got error libOpenCvSharpExtern: cannot open shared object file: No such file or directory.

  1. I'm not sure about OpenCvSharp4.runtime.linux-arm, can it work for linux-arm64? Or I need to build from source code by myself? If yes, do we have any instruction for this (jetson)?
  2. What about OpenCV 4.1.1, is it supported by opencvsharp?

    Environment

Example code:

var videoCapture = new VideoCapture();

videoCapture.Open(0);

var frame = new Mat();
var frameId = 0;
var maxFrame = 1;
while (videoCapture.IsOpened())
{
    if(videoCapture.Read(frame))
    {
        frameId++;
        var image = BitmapConverter.ToBitmap(frame);
        image.Save($"{frameId}.jpg");

        if (frameId >= maxFrame)
        {
            break;
        }
    }
}

Output:

Unhandled exception. System.TypeInitializationException: The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception.
 ---> 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()
   --- End of inner exception stack trace ---
   at OpenCvSharp.Internal.NativeMethods.videoio_VideoCapture_new1(IntPtr& returnValue)
   at OpenCvSharp.VideoCapture..ctor()
   at Program.Main(String[] args) in /Program.cs:line 18
AvenSun commented 3 years ago

try to run command as follows ldd /xxx/libOpenCvSharpExtern.so check the library marked "not found" then install it

leopripos commented 3 years ago

Sorry @AvenSun Where can I find libOpenCvSharpExtern.so? Is it the file generated by OpenCvSharp4.runtime.linux-arm?

dseferlis commented 3 years ago

@leopripos yes. If you build or publish your project for linux-arm it will be at the output directory.

dev-nextprogress commented 3 years ago

Hi and first let me thanks @shimat and all the contributors to this great library. I am having the same question about the linux-arm64 runtime identifier. It appears as if the linux-arm package is not compatible with ARM64. The LoadLibrary call on the linux-arm version fails (I verified that the O/S can find it). I know we could probably try to build it ourselves but it's a bit of a chore if you are not deeply familiar with CMake and such. So if there are any plans to create a linux-arm64 package that would be great to know. Thanks

AvenSun commented 3 years ago

@leopripos the attached file I built works well on Jetson, but it's not the latest version. libOpenCvSharpExtern for Jetson you can have a try.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

andreyserenkov commented 2 years ago

@leopripos the attached file I built works well on Jetson, but it's not the latest version. libOpenCvSharpExtern for Jetson you can have a try. How did you compile Jetson version? I follow guide, but my lib becomes 4mb only, but yours one is much bigger.

thylxl commented 9 months ago

@leopripos the attached file I built works well on Jetson, but it's not the latest version. libOpenCvSharpExtern for Jetson you can have a try.

Do you have the latest version? My project needs a copy that supports GTK2.0. My program still reports an error. Thank you! My error is as follows: OpenCvSharp.OpenCVException: The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script at OpenCvSharp.Internal.ExceptionHandler.ThrowPossibleException() at OpenCvSharp.Internal.NativeMethods.HandleException(ExceptionStatus status) at OpenCvSharp.Window..ctor(String name, Mat image, WindowFlags flags) at OpenCvSharp_ReadRTSPStream.Program.Main(String[] args) in D:\VisualStudio\TargetCenter\rtsp\Program.cs:line 233