emgucv / emgucv

Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library.
https://www.emgu.com/
Other
2.13k stars 581 forks source link

deploy emgucv on ARM ubuntu 16.04 #453

Open timiil opened 3 years ago

timiil commented 3 years ago

hello all,

we are trying to deploy emgucv on an ARM board, Rockhip RK3399 SOC , ubuntu 16.04;

after install dotnet5, i had installed the requirement https://github.com/emgucv/emgucv/blob/master/platforms/ubuntu/20.04/apt_install_dependency.sh

apt-get install -y build-essential libgtk-3-dev libgstreamer1.0-dev libavcodec-dev \
  libswscale-dev libavformat-dev libdc1394-22-dev libv4l-dev cmake-curses-gui ocl-icd-dev freeglut3-dev libgeotiff-dev

the above installation is complete SUCCESS.

the csproj file is :

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Emgu.CV" Version="4.5.1.4349" />
    <PackageReference Include="Emgu.CV.runtime.linux-arm" Version="4.5.1.4349" />    
  </ItemGroup>

</Project>

so whe we run:

 dotnet run
Building...
/home/camgate/Controllers/CamController.cs(54,67): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/camgate/CamGate.csproj]
/home/camgate/Controllers/CamController.cs(53,17): warning CS0219: The variable 'first' is assigned but its value is never used [/home/camgate/CamGate.csproj]
Unhandled exception. System.TypeInitializationException: The type initializer for 'Emgu.CV.MatInvoke' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'cvextern' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libcvextern: cannot open shared object file: No such file or directory
   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.CvInvoke.Init()
   at Emgu.CV.MatInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.MatInvoke.cveMatCreate()
   at Emgu.CV.Mat..ctor()
   at CamGate.Program.Main(String[] args) in /home/camgate/Program.cs:line 16

so, i try ldd:

root@lubuntu:/home/camgate# ldd bin/Debug/net5.0/runtimes/linux-arm/native/libcvextern.so 
    not a dynamic executable

i try readelf:

root@lubuntu:/home/camgate# readelf -d bin/Debug/net5.0/runtimes/linux-arm/native/libcvextern.so 

Dynamic section at offset 0x27bcdf4 contains 61 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]
 0x00000001 (NEEDED)                     Shared library: [libgeotiff.so.2]
 0x00000001 (NEEDED)                     Shared library: [libSM.so.6]
 0x00000001 (NEEDED)                     Shared library: [libICE.so.6]
 0x00000001 (NEEDED)                     Shared library: [libX11.so.6]
 0x00000001 (NEEDED)                     Shared library: [libXext.so.6]
 0x00000001 (NEEDED)                     Shared library: [libXt.so.6]
 0x00000001 (NEEDED)                     Shared library: [libOpenGL.so.0]
 0x00000001 (NEEDED)                     Shared library: [libGLX.so.0]
 0x00000001 (NEEDED)                     Shared library: [libGLU.so.1]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libfreetype.so.6]
 0x00000001 (NEEDED)                     Shared library: [libharfbuzz.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdc1394.so.22]
 0x00000001 (NEEDED)                     Shared library: [libavcodec.so.58]
 0x00000001 (NEEDED)                     Shared library: [libavformat.so.58]
 0x00000001 (NEEDED)                     Shared library: [libavutil.so.56]
 0x00000001 (NEEDED)                     Shared library: [libswscale.so.5]
 0x00000001 (NEEDED)                     Shared library: [libgtk-3.so.0]
 0x00000001 (NEEDED)                     Shared library: [libgdk-3.so.0]
 0x00000001 (NEEDED)                     Shared library: [libpangocairo-1.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libpango-1.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libatk-1.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libcairo-gobject.so.2]
 0x00000001 (NEEDED)                     Shared library: [libcairo.so.2]
 0x00000001 (NEEDED)                     Shared library: [libgdk_pixbuf-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libgio-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libgobject-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libglib-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libgthread-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [librt.so.1]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
 0x0000000e (SONAME)                     Library soname: [libcvextern.so]
 0x0000000c (INIT)                       0x381074
 0x0000000d (FINI)                       0x1f481fc
 0x00000019 (INIT_ARRAY)                 0x2767190
 0x0000001b (INIT_ARRAYSZ)               3648 (bytes)
 0x0000001a (FINI_ARRAY)                 0x2767fd0
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x6ffffef5 (GNU_HASH)                   0x158
 0x00000005 (STRTAB)                     0xf0850
 0x00000006 (SYMTAB)                     0x4f760
 0x0000000a (STRSZ)                      1662285 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0x27cd000
 0x00000002 (PLTRELSZ)                   113776 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x365404
 0x00000011 (REL)                        0x29aadc
 0x00000012 (RELSZ)                      829736 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x29a7bc
 0x6fffffff (VERNEEDNUM)                 13
 0x6ffffff0 (VERSYM)                     0x28659e
 0x6ffffffa (RELCOUNT)                   54351
 0x00000000 (NULL)                       0x0

any idea ? should i post the LD_DEBUG detail log ?

emgucv commented 3 years ago

The "Emgu.CV.runtime.linux-arm" nuget package version "4.5.1.4349" is built to target Raspberry OS, on a 32bit ARM operation system.

If your Ubuntu OS ARM (32-bit) or ARM64 (64-bit)? Either way, you will most likely won't get that binary to work on Ubuntu 16.04 ARM (or ARM64) OS. The best bet will be building the binary from source code. Instruction for building the binary from Git for Ubunutu 20.04 (x64) can be found here: https://www.emgu.com/wiki/index.php/Download_And_Installation#Ubuntu_20.04

You may need to make some modification to build for Ubuntu 16.04 (ARM or ARM64).

timiil commented 3 years ago

The "Emgu.CV.runtime.linux-arm" nuget package version "4.5.1.4349" is built to target Raspberry OS, on a 32bit ARM operation system.

If your Ubuntu OS ARM (32-bit) or ARM64 (64-bit)? Either way, you will most likely won't get that binary to work on Ubuntu 16.04 ARM (or ARM64) OS. The best bet will be building the binary from source code. Instruction for building the binary from Git for Ubunutu 20.04 (x64) can be found here: https://www.emgu.com/wiki/index.php/Download_And_Installation#Ubuntu_20.04

You may need to make some modification to build for Ubuntu 16.04 (ARM or ARM64).

It is an ARM64 SOC, and the Ubuntu is 64bit.

I may make a try on building it from source code.

HryhoriiHordiichuk commented 3 years ago

Hello all, I am trying to deploy emgucv (with CUDA support) on Jetson Xavier NX (Ubuntu 18.04 aarch64). I used cmake configure files for ubuntu 20.04 and RaspberryPi which contained in source code (file for raspberry i changed for CUDA support). Then i included Emgu.CV.Platform.NetStandard.dll(which i taked from build) to my source code. In all cases, when i use any class of EmguCV, when i first call to it i have "segmentation fault(core dumped)" error. (cvextern i put to app folder) @timiil did you deploy emgucv for Arm64 architecture? @emgucv Will the project support Arm64 architecture?

timiil commented 3 years ago

Hello all, I am trying to deploy emgucv (with CUDA support) on Jetson Xavier NX (Ubuntu 18.04 aarch64). I used cmake configure files for ubuntu 20.04 and RaspberryPi which contained in source code (file for raspberry i changed for CUDA support). Then i included Emgu.CV.Platform.NetStandard.dll(which i taked from build) to my source code. In all cases, when i use any class of EmguCV, when i first call to it i have "segmentation fault(core dumped)" error. (cvextern i put to app folder) @timiil did you deploy emgucv for Arm64 architecture? @emgucv Will the project support Arm64 architecture?

no, not yet :(