Hello World for Ubuntu: Difference between revisions
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
== Installing the dependencies == | == Installing the dependencies == | ||
The pre-compiled Emgu CV binary requires a few package to be installed on the Ubuntu instance. You will need to run this script to install the dependencies. | The pre-compiled Emgu CV binary requires a few package to be installed on the Ubuntu instance. You will need to run this script to install the dependencies. | ||
https://github.com/emgucv/emgucv/blob/4.5.1/platforms/ubuntu/20.04/apt_install_dependency.sh | |||
== Creating the first Emgu CV console program with .Net Core == | == Creating the first Emgu CV console program with .Net Core == | ||
Line 9: | Line 11: | ||
Add the Emgu CV nuget packages | Add the Emgu CV nuget packages | ||
<pre> dotnet add package Emgu.CV.runtime.ubuntu.20.04-x64 </pre> | <pre> dotnet add package Emgu.CV.runtime.ubuntu.20.04-x64 </pre> | ||
Fire up | Fire up your favorite editor and replace Program.cs file with the following | ||
<syntaxhighlight lang="csharp"> | <syntaxhighlight lang="csharp"> | ||
using System; | using System; | ||
Line 27: | Line 29: | ||
Run the project | Run the project | ||
<pre> dotnet run </pre> | <pre> dotnet run </pre> | ||
The program should now display the Open CV's BuildInformation for the native runtime. | |||
If you saw error message such as | |||
<pre> | |||
Unhandled 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 | |||
</pre> | |||
It is likely there is a missing dependency for "libcvextern.so" file. In this case, following [[Download_And_Installation#System.DllNotFoundException | this instuction]] to trouble shot. |
Latest revision as of 14:26, 29 April 2021
This example is based on Emgu CV 4.5.1, Ubuntu 20.04 and dotnet 5.0
Installing the dependencies
The pre-compiled Emgu CV binary requires a few package to be installed on the Ubuntu instance. You will need to run this script to install the dependencies.
https://github.com/emgucv/emgucv/blob/4.5.1/platforms/ubuntu/20.04/apt_install_dependency.sh
Creating the first Emgu CV console program with .Net Core
From the command console, first create a console project in .Net Core
dotnet new console
Add the Emgu CV nuget packages
dotnet add package Emgu.CV.runtime.ubuntu.20.04-x64
Fire up your favorite editor and replace Program.cs file with the following
using System;
using Emgu.CV;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(CvInvoke.BuildInformation);
}
}
}
Run the project
dotnet run
The program should now display the Open CV's BuildInformation for the native runtime.
If you saw error message such as
Unhandled 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
It is likely there is a missing dependency for "libcvextern.so" file. In this case, following this instuction to trouble shot.