shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.39k stars 1.15k forks source link

Can NOT use this repo in C# for Windows 10. #1320

Closed zydjohnHotmail closed 2 years ago

zydjohnHotmail commented 3 years ago

Summary of your issue

Visual Studio restart for simple statement in this repo.

Environment

Windows 10 (Version 21H1) Visual Studio 2019 (Version 16.11.3) PM> Install-Package OpenCvSharp4 -Version 4.5.3.20210817

Write your environment.

What did you do when you faced the problem?

When I run my code, Visual Studio 2019 simply restart Write here

Example code:

using OpenCvSharp;

namespace MatchImages
{
    class Program
    {
        public const string Image1_File = @"C:\Images\1.PNG";
        public const string Image2_File = @"C:\Images\2.PNG";

        static void Main()
        {
            Mat image1 = new(Image1_File, ImreadModes.AnyColor);
            Mat image2 = new(Image2_File, ImreadModes.AnyColor);
            Mat mat3 = new();
            mat3.Create(image1.Cols - image2.Cols + 1, image1.Rows - image2.Rows + 1, MatType.CV_32FC1);
            Cv2.MatchTemplate(image1, image2, mat3, TemplateMatchModes.SqDiff);
            Cv2.Normalize(mat3, mat3, 1, 0, NormTypes.MinMax, -1);
        }
    }
}

Output:

paste your output

What did you intend to be?

NilesDavis commented 2 years ago

Did you try to take the nuget-package "OpenCvSharp4.runtime.win" instead of "OpenCvSharp4" as it includes all original sources you will need.

kkh3049 commented 2 years ago

As noted here: https://github.com/shimat/opencvsharp#windows-except-uwp Please install either the OpenCVSharp4.Windows NuGet package or both the OpenCVSharp4 and the OpenCVSharp4.runtime.win NuGet packages.