Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HoughLinesPointSet test #1729

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions nuget/OpenCvSharp4.Extensions.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
<dependencies>
<group targetFramework="net48">
<dependency id="OpenCvSharp4" version="4.5.3.20211226" />
<dependency id="System.Drawing.Common" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.11" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="OpenCvSharp4" version="4.3.0.20190901" />
<dependency id="System.Drawing.Common" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.11" />
</group>
<group targetFramework="netstandard2.1">
<dependency id="OpenCvSharp4" version="4.5.3.20211226" />
<dependency id="System.Drawing.Common" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.11" />
</group>
<group targetFramework="net6.0">
<dependency id="OpenCvSharp4" version="4.5.3.20211226" />
<dependency id="System.Drawing.Common" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.11" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/OpenCvSharp4.WpfExtensions.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
<dependencies>
<group targetFramework="net48">
<dependency id="OpenCvSharp4" version="4.3.0.20190901" />
<dependency id="System.Drawing.Common" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.11" />
</group>
<group targetFramework="net6.0">
<dependency id="OpenCvSharp4" version="4.3.0.20190901" />
<dependency id="System.Drawing.Common" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.11" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
8 changes: 4 additions & 4 deletions nuget/OpenCvSharp4.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
<dependencies>
<group targetFramework="net48">
<dependency id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" />
<dependency id="System.Memory" version="4.5.5" />
<dependency id="System.Memory" version="4.6.0" />
<dependency id="System.ValueTuple" version="4.5.0" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" />
<dependency id="System.Memory" version="4.5.5" />
<dependency id="System.Memory" version="4.6.0" />
</group>
<group targetFramework="netstandard2.1">
<dependency id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" />
<dependency id="System.Memory" version="4.5.5" />
<dependency id="System.Memory" version="4.6.0" />
</group>
<group targetFramework="net6.0">
<dependency id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" />
<dependency id="System.Memory" version="4.5.5" />
<dependency id="System.Memory" version="4.6.0" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
2 changes: 1 addition & 1 deletion src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<ItemGroup>
<PackageReference Include="System.Drawing.Common">
<Version>8.0.6</Version>
<Version>8.0.11</Version>
</PackageReference>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="8.0.6" />
<PackageReference Include="System.Drawing.Common" Version="8.0.11" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/OpenCvSharp/Modules/core/Mat/Mat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3516,7 +3516,7 @@ private void CheckArgumentsForConvert<T>(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)
Expand Down
3 changes: 1 addition & 2 deletions src/OpenCvSharp/OpenCvSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Memory" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="System.Memory" Version="4.6.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta15" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="System.Memory" Version="4.6.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
56 changes: 56 additions & 0 deletions test/OpenCvSharp.Tests/imgproc/ImgProcTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void BuildPyramidTest()
Cv2.BuildPyramid(src, dst, 2);
Assert.Equal(3, dst.Size);
}

[Fact]
public void MorphologyExDilate()
{
Expand Down Expand Up @@ -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()
{
Expand Down
Loading