shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.22k stars 1.13k forks source link

Linux ARM64 (Native bindings for Linux ARM64) #1644

Open DJSures opened 5 months ago

DJSures commented 5 months ago

Summary of your issue

OpenCVSharp is fantastic; kudos to all your hard work! My cross-platform experience is unfortunately limited because there are no Linux ARM64 native bindings. I'm surprised to see 32-bit ARM NuGet packages (OpenCvSharp4.runtime. Linux-arm) in 2024. Many of the OpenCVSharp user issues in this repo are because of the lack of ARM64 bindings. All Raspberry Pi and ARM SBC Linux's have favored 64bit for the last few years. You will be hard-pressed to find a 32-bit OS these days.

Environment

What did you do when you faced the problem?

I started Sherlock'n the interwebs to find a libOpenCvSharpExtern.so: ELF 64-bit LSB shared object, ARM aarch64 compatible with OpenCVSharp4 (not SDCB's Mini, because /dev/videoX is essential)

Until there's a build for Linux ARM64, I'll have to build it myself - but I'd prefer a shared Nuget that solves the many user issues in this repo.

Example code:

Build it yourself RN: https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html

Output:

sad face emoji

What did you intend to be?

Like all children, an astronaut, cowboy, firefighter, or robot. I made a few million robots possible, so I kind of achieved my goal! What did you intend to be?

sajmons commented 4 months ago

Thumbs up for ARM64 NuGet package for Raspberry Pi!

DJSures commented 4 months ago

Did you build it yourself or do you want me to post the one I built?

sajmons commented 4 months ago

No, I didn't build it myself, I yust wanna see it build as NuGet package so that can be easily included for linux-arm64 Raspberry Pi projects.

andywcoder commented 2 months ago

Did you build it yourself or do you want me to post the one I built?

Can you please post the one you built?

DJSures commented 2 months ago

Here you go libOpenCvSharpExtern.zip

andywcoder commented 2 months ago

Thanks for the library. Unfortunately it is dynamic linked unlike the static linked library in the nuget package OpenCvSharp4.runtime.linux-arm.

I built the OpenCV 4.9.0 binaries which took half a day on my Raspberry Pi 4. After that ldd /libOpenCvSharpExtern.so still displays a missing reference:

/lib/aarch64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.32' not found

Running strings /lib/aarch64-linux-gnu/libstdc++.so.6 | grep GLIBCXX prints

...
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_3.4.30

So I'm trying to update libstdc++.so.6 which apparently is part of GCC. After building the GCC 13.2 binaries for a couple of hours it stopped with an error about an symbol lookup error: /lib/aarch64-linux-gnu/libicuuc.so.72: undefined symbol: _ZSt15__once_callable, version GLIBCXX_3.4.11.

During all the building I rewrote the C# app in Python, which is much easier to run on Linux. I really like C# and .NET, but things like that are just a hassle I don't need.