OpenCvSharp4.runtime.linux-arm doesn't work on raspberry pi 4
See original GitHub issueSummary of issue
Hello everyone. First of all thank you for your effort to make this lib. Trying to use opencvsharp on an image capture app on a raspberry pi. Installed the OpenCvSharp4.runtime.linux-arm nuget package thinking of this is what I need. Although I get the error bellow. Is there something I can do to make it work?
Environment
Raspberry pi model 4 4GB OS: Raspbian 10 buster (armv7l) Project framework: .net 5
Example code:
using OpenCvSharp;
namespace OpencvTest.Console
{
class Program
{
static void Main(string[] args) {
var capture = new VideoCapture(0);
var window = new Window("Test");
var image = new Mat();
while (true) {
capture.Read(image);
if (image.Empty()) {
break;
}
window.ShowImage(image);
if (Cv2.WaitKey(1) == 113) {
break;
}
}
System.Console.WriteLine("Hello World!");
}
}
}
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: wrong ELF class: ELFCLASS64
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_new3(Int32 device, Int32 apiPreference, IntPtr& returnValue)
at OpenCvSharp.VideoCapture..ctor(Int32 index, VideoCaptureAPIs apiPreference)
at OpencvTest.Console.Program.Main(String[] args)
Issue Analytics
- State:
- Created 2 years ago
- Comments:31 (10 by maintainers)
Top Results From Across the Web
OpenCvSharp4.runtime.linux-arm doesn't work on ...
Hello everyone. First of all thank you for your effort to make this lib. Trying to use opencvsharp on an image capture app...
Read more >Docker multi-architecture, .NET 6.0 and OpenCVSharp
Looking into OpenCvSharp4 NuGet packages, there is already a native binding package for ARM devices named OpenCvSharp4.runtime.linux-arm .
Read more >Arch Linux ARM not booting on Pi 4B - Raspberry Pi Forums
I'm attempting to install Arch Linux ARM on my Raspberry Pi 4B using ... The Boot Problems sticky post says 0 long flashes...
Read more >OpenCvSharp4.runtime.linux-arm 4.8.0.20230708
Internal implementation package for OpenCvSharp to work on Ubuntu 18.04 for ARM.
Read more >OpenCV import on Raspberry Pi 4 not working
I am experiencing a lot of trouble installing OpenCV for my Raspberry Pi 4 running rasbian full. I believe i have installed the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A bit late to the discussion but recently I experienced a similar issue too. If using Docker to run on Raspberry Pi, building OpenCV and OpenCvSharp as a multi architecture Docker build and then copy the native libraries to the target image when building the application.
Here is an example: https://github.com/syamaner/docker-multi-arch-opencvsharp/tree/main/docker And a bit more in the post: https://dev.to/syamaner/docker-multi-architecture-net-60-and-opencvsharp-1okd
Essentially all it does is to build both libraries, copy libOpenCvSharpExtern.so and all dependencies to /artifacts directory. Then when building an application image, use it as a stage to copy contents of the /artifacts into the target image. the build image is only 94 to 125 mb depending on target architecture:
https://hub.docker.com/repository/docker/syamaner/opencvsharp-build/tags
This way I only need to add OpenCvSharp4 as a package reference and native bindings will be handled at Docker build time when building the application image. I have tested using 32 and 64 bit OS on Raspberry pi including official Rabpbian as well as Ubuntu 20.04 and 22.04.
Hope it helps.
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.