Home > other >  In c # using OpenCV (using OpenCVSharp)
In c # using OpenCV (using OpenCVSharp)

Time:10-10

1, what is OpenCVSharp
In order to solve the problem of under the Csharp write OpenCV program, I have been a more in-depth research, and implement the most efficient methods available (GOCW); This few days at the time of data collection, occasionally saw OpenCVSharp, from the time point of view, it has passed a long development, there should be many reference directly, or directly use place,

OpenCVSharp have a Japanese engineers to develop, project address is: https://github.com/shimat/opencvsharp, it is OpenCV..net wrapper, it is more close to the original than Emgucv OpenCV, and there are a lot of sample reference, it USES the LGPL, friendly to business applications (BSD) basically,
2, what is the distinguishing feature of OpenCVSharp

Encapsulates the more OpenCV method directly, reduce the difficulty of learning, more easy to use than EmguCV
Most inherited the IDisposable interface, easy to use using statements
Can directly call the original style of OpenCV method
Can be directly into use GDI Bitmap image object and WPF WriteBitmap
Supports Mono,

3, OpenCVSharp in VS environment configuration of the

There are two ways: one kind is to use NuGet (library package manager) in this configuration, the ways are well worth reference; Another kind of direct download the installation package,

The first way: use NuGet (library package manager), first open the VS, whether in the [tools] options have [library package manager]

If not good to install NuGet.

https://jingyan.baidu.com/article/066074d636fd19c3c21cb0a2.html (reproduced since baidu)

After installed, open the [tools] - & gt; [library package manager] - & gt; [management solution NuGet package], in which the search OpenCVSharp, choosing the right click [install] (had better install the latest), has been waiting for,

After complete the installation, need to the DLL file is installed in the project of executable file the Debug folder, how to find installed files

The second way is to directly download the installation package

https://github.com/shimat/opencvsharp/releases

After you download it to a folder (any folder)

File after installed, right-click in the [the solution] [quote] - & gt; [add reference], [through] choice, will download file OpenCvSharp. DLL files added to the reference,

Will download file OpenCvSharpExtern. DLL is copied to the executable file of the Debug folder, all configuration is OK, the following test whether configuration is successful,

Pay attention to here, if you use the first way, it is automatically copy the DLL file for you; If you use the second way, the need to copy,

4, the test code
Using System. Collections. Generic;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
Using OpenCvSharp;//add the corresponding reference
The namespace OpenCVSharpTest2
{
Class Program
{
The static void Main (string [] args)
{
Mat source=new Mat (@ "1. BMP," ImreadModes. Color);
Cv2. ImShow (" Demo ", source);
Cv2. WaitKey (0);
}
}

5, the principle of movement of

After the preliminary understanding OpenCVSharp implementation effect, in addition to feel amazing, I would like to know how it is done, after all, I think a lot on GOCW method, spent a lot of time,

Download master code, need vs2017 can open,



Here you can see from the structure, OpenCVsharpExtern is c + + code, everything else is Csharp code, as expected, it must be to do the CLR encapsulation, it is a large number of dependent 341

OpenCVSharp, contains a large number of encapsulation of OpenCV function should be done quite a lot of work inside,

6, preliminary summary

Although compared OpenCVSharp emgucv really is very concise, but also has a larger code capacity, mainly because of once thinking of OpenCV transplanted, inevitably need to do a lot of repetitive work -- and OpenCV each upgrade
Possible side needs to be synchronized to upgrade, so I still think GOCW method is more suitable, also responsible for the interface of the interface program, don't do the work of reinventing the wheel,
That being said, this project is still has many places worth digging, thank you for reading this and want to help,

CodePudding user response:

To support brother!
 c # like Opencv 
  • Related