From 641de5fb74d56da9b922d7612063642455dbc1d4 Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 9 Dec 2024 00:56:42 +0900 Subject: [PATCH 1/2] update nuget --- nuget/OpenCvSharp4.Extensions.nuspec | 8 ++++---- nuget/OpenCvSharp4.WpfExtensions.nuspec | 4 ++-- nuget/OpenCvSharp4.nuspec | 8 ++++---- src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj | 2 +- .../OpenCvSharp.WpfExtensions.csproj | 2 +- src/OpenCvSharp/OpenCvSharp.csproj | 3 +-- .../OpenCvSharp.Tests.Windows.csproj | 8 ++++---- test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj | 8 ++++---- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/nuget/OpenCvSharp4.Extensions.nuspec b/nuget/OpenCvSharp4.Extensions.nuspec index 0e24da518..773924eb8 100644 --- a/nuget/OpenCvSharp4.Extensions.nuspec +++ b/nuget/OpenCvSharp4.Extensions.nuspec @@ -18,19 +18,19 @@ - + - + - + - + diff --git a/nuget/OpenCvSharp4.WpfExtensions.nuspec b/nuget/OpenCvSharp4.WpfExtensions.nuspec index 6a681a603..f4c0d2deb 100644 --- a/nuget/OpenCvSharp4.WpfExtensions.nuspec +++ b/nuget/OpenCvSharp4.WpfExtensions.nuspec @@ -18,11 +18,11 @@ - + - + diff --git a/nuget/OpenCvSharp4.nuspec b/nuget/OpenCvSharp4.nuspec index 76a7e1e27..2353c7a49 100644 --- a/nuget/OpenCvSharp4.nuspec +++ b/nuget/OpenCvSharp4.nuspec @@ -18,20 +18,20 @@ - + - + - + - + diff --git a/src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj b/src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj index b30735442..caea99cd8 100644 --- a/src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj +++ b/src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj @@ -44,7 +44,7 @@ - 8.0.6 + 8.0.11 diff --git a/src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj b/src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj index b4778a924..a6ca2c9ba 100644 --- a/src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj +++ b/src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj @@ -19,7 +19,7 @@ true - + diff --git a/src/OpenCvSharp/OpenCvSharp.csproj b/src/OpenCvSharp/OpenCvSharp.csproj index ece6b4d0a..d2502d28d 100644 --- a/src/OpenCvSharp/OpenCvSharp.csproj +++ b/src/OpenCvSharp/OpenCvSharp.csproj @@ -27,8 +27,7 @@ - - + diff --git a/test/OpenCvSharp.Tests.Windows/OpenCvSharp.Tests.Windows.csproj b/test/OpenCvSharp.Tests.Windows/OpenCvSharp.Tests.Windows.csproj index dde3f8905..814b60d64 100644 --- a/test/OpenCvSharp.Tests.Windows/OpenCvSharp.Tests.Windows.csproj +++ b/test/OpenCvSharp.Tests.Windows/OpenCvSharp.Tests.Windows.csproj @@ -32,10 +32,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj b/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj index c3fbe3624..9ce6173a9 100644 --- a/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj +++ b/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj @@ -37,12 +37,12 @@ - + - - - + + + all runtime; build; native; contentfiles; analyzers From b545253cde6fc9fd2d2ddd1132a6bc42acaf097b Mon Sep 17 00:00:00 2001 From: shimat Date: Mon, 9 Dec 2024 00:57:00 +0900 Subject: [PATCH 2/2] Add HoughLinesPointSet test --- src/OpenCvSharp/Modules/core/Mat/Mat.cs | 2 +- test/OpenCvSharp.Tests/imgproc/ImgProcTest.cs | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/OpenCvSharp/Modules/core/Mat/Mat.cs b/src/OpenCvSharp/Modules/core/Mat/Mat.cs index cabb7a014..c64ca2051 100644 --- a/src/OpenCvSharp/Modules/core/Mat/Mat.cs +++ b/src/OpenCvSharp/Modules/core/Mat/Mat.cs @@ -3516,7 +3516,7 @@ private void CheckArgumentsForConvert(Array data) throw new OpenCvSharpException( $"Provided data element number ({data.Length}) should be multiple of the Mat channels count ({t.Channels})"); - if (acceptableTypes is not null && acceptableTypes.Length > 0) + if (acceptableTypes.Length > 0) { var isValidDepth = acceptableTypes.Any(type => type == t); if (!isValidDepth) diff --git a/test/OpenCvSharp.Tests/imgproc/ImgProcTest.cs b/test/OpenCvSharp.Tests/imgproc/ImgProcTest.cs index 393f63608..1ddfdd1ad 100644 --- a/test/OpenCvSharp.Tests/imgproc/ImgProcTest.cs +++ b/test/OpenCvSharp.Tests/imgproc/ImgProcTest.cs @@ -15,6 +15,7 @@ public void BuildPyramidTest() Cv2.BuildPyramid(src, dst, 2); Assert.Equal(3, dst.Size); } + [Fact] public void MorphologyExDilate() { @@ -689,6 +690,61 @@ public void HoughLinesP() } } + [Fact] + public void HoughLinesPointSet() + { + Vec2f[] points = + [ + new(0.0f, 369.0f), + new(10.0f, 364.0f), + new(20.0f, 358.0f), + new(30.0f, 352.0f), + new(40.0f, 346.0f), + new(50.0f, 341.0f), + new(60.0f, 335.0f), + new(70.0f, 329.0f), + new(80.0f, 323.0f), + new(90.0f, 318.0f), + new(100.0f, 312.0f), + new(110.0f, 306.0f), + new(120.0f, 300.0f), + new(130.0f, 295.0f), + new(140.0f, 289.0f), + new(150.0f, 284.0f), + new(160.0f, 277.0f), + new(170.0f, 271.0f), + new(180.0f, 266.0f), + new(190.0f, 260.0f) + ]; + + const int + linesMax = 20, + threshold = 1; + const double + rhoMin = 0.0f, + rhoMax = 360.0f, + rhoStep = 1, + thetaMin = 0.0f, + thetaMax = Cv2.PI / 2.0f, + thetaStep = Cv2.PI / 180.0f; + + using var pointsMat = new Mat(points.Length, 1, MatType.CV_32FC2); + pointsMat.SetArray(points); + using var linesMat = new Mat(); + Cv2.HoughLinesPointSet(pointsMat, linesMat, linesMax, threshold, rhoMin, rhoMax, rhoStep, thetaMin, thetaMax, thetaStep); + + Assert.False(linesMat.Empty()); + Assert.Equal(MatType.CV_64FC3, linesMat.Type()); + + Assert.True(linesMat.GetArray(out Vec3d[] lines)); + Assert.NotEmpty(lines); + + var (votes, rho, theta) = lines[0]; + Assert.True(votes > 10); + Assert.Equal(320, rho, 6); + Assert.Equal(1.0471975803375244, theta, 6); + } + [Fact] public void Integral() {