Skip to content

Commit

Permalink
bump opencv versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Jun 25, 2024
1 parent 2900763 commit b870710
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Sdcb.Paddle2Onnx/Sdcb.Paddle2Onnx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.13.2">
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
5 changes: 1 addition & 4 deletions src/Sdcb.PaddleDetection/Preprocessers/PermuteOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ public override void Run(Mat src, ImageProcessContext data)
IntPtr resultPtr = resultHandle.AddrOfPinnedObject();
for (int i = 0; i < channels; ++i)
{
using Mat cmat = new(
src.Height, src.Width,
MatType.CV_32FC1,
resultPtr + i * size.Width * size.Height * sizeof(float));
using Mat cmat = Mat.FromPixelData(src.Height, src.Width, MatType.CV_32FC1, resultPtr + i * size.Width * size.Height * sizeof(float));
Cv2.ExtractChannel(src, cmat, i);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.PaddleDetection/Sdcb.PaddleDetection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenCvSharp4" Version="4.9.0.20240103" />
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20240616" />
<PackageReference Include="YamlDotNet" Version="13.1.1" />
<PackageReference Include="Sdcb.PaddleInference" Version="2.5.0.1" Condition="'$(Configuration)' != 'Debug'" />
<ProjectReference Include="..\Sdcb.PaddleInference\Sdcb.PaddleInference.csproj" Condition="'$(Configuration)' == 'Debug'" />
Expand Down
4 changes: 2 additions & 2 deletions src/Sdcb.PaddleOCR/PaddleOcrDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public Mat RunRaw(Mat src, out Size resizedSize)
float[] data = output.GetData<float>();
int[] shape = output.Shape;

return new Mat(shape[2], shape[3], MatType.CV_32FC1, data);
return Mat.FromPixelData(shape[2], shape[3], MatType.CV_32FC1, data);
}
}

Expand Down Expand Up @@ -274,7 +274,7 @@ internal static float[] ExtractMat(Mat src)
IntPtr resultPtr = resultHandle.AddrOfPinnedObject();
for (int i = 0; i < src.Channels(); ++i)
{
using Mat dest = new(rows, cols, MatType.CV_32FC1, resultPtr + i * rows * cols * sizeof(float));
using Mat dest = Mat.FromPixelData(rows, cols, MatType.CV_32FC1, resultPtr + i * rows * cols * sizeof(float));
Cv2.ExtractChannel(src, dest, i);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sdcb.PaddleOCR/PaddleOcrRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private PaddleOcrRecognizerResult[] RunMulti(Mat[] srcs)
float score = 0;
for (int n = 0; n < charCount; ++n)
{
using Mat mat = new(1, labelCount, MatType.CV_32FC1, dataPtr + (n + i * charCount) * labelCount * sizeof(float));
using Mat mat = Mat.FromPixelData(1, labelCount, MatType.CV_32FC1, dataPtr + (n + i * charCount) * labelCount * sizeof(float));
int[] maxIdx = new int[2];
mat.MinMaxIdx(out double _, out double maxVal, new int[0], maxIdx);
Expand Down Expand Up @@ -253,7 +253,7 @@ private static float[] ExtractMat(Mat[] srcs, int channel, int height, int width
}
for (int c = 0; c < channel; ++c)
{
using Mat dest = new(height, width, MatType.CV_32FC1, resultPtr + (c + i * channel) * height * width * sizeof(float));
using Mat dest = Mat.FromPixelData(height, width, MatType.CV_32FC1, resultPtr + (c + i * channel) * height * width * sizeof(float));
Cv2.ExtractChannel(src, dest, c);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.PaddleOCR/PaddleOcrTableRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static float[] ExtractMat(Mat src)
IntPtr resultPtr = resultHandle.AddrOfPinnedObject();
for (int i = 0; i < src.Channels(); ++i)
{
using Mat dest = new(rows, cols, MatType.CV_32FC1, resultPtr + i * rows * cols * sizeof(float));
using Mat dest = Mat.FromPixelData(rows, cols, MatType.CV_32FC1, resultPtr + i * rows * cols * sizeof(float));
Cv2.ExtractChannel(src, dest, i);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.PaddleOCR/Sdcb.PaddleOCR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenCvSharp4" Version="4.9.0.20240103" />
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20240616" />
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.RotationDetector/PaddleRotationDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal static float[] ExtractMat(Mat src)
IntPtr resultPtr = resultHandle.AddrOfPinnedObject();
for (int i = 0; i < src.Channels(); ++i)
{
using Mat dest = new(rows, cols, MatType.CV_32FC1, resultPtr + i * rows * cols * sizeof(float));
using Mat dest = Mat.FromPixelData(rows, cols, MatType.CV_32FC1, resultPtr + i * rows * cols * sizeof(float));
Cv2.ExtractChannel(src, dest, i);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sdcb.RotationDetector/Sdcb.RotationDetector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenCvSharp4" Version="4.8.0.20230708" />
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20240616" />
<PackageReference Include="Sdcb.PaddleInference" Version="2.5.0" Condition="'$(Configuration)' != 'Debug'" />
<ProjectReference Include="..\Sdcb.PaddleInference\Sdcb.PaddleInference.csproj" Condition="'$(Configuration)' == 'Debug'" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions tests/Sdcb.Paddle2Onnx.Tests/Sdcb.Paddle2Onnx.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Sdcb.Paddle2Onnx.runtime.win64" Version="1.0.0.2" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.5.1" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.6.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
16 changes: 11 additions & 5 deletions tests/Sdcb.PaddleNLP.Lac.Tests/Sdcb.PaddleNLP.Lac.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.5.1" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.6.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/Sdcb.PaddleOCR.Tests/Sdcb.PaddleOCR.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.9.0.20240103" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.5.1" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20240616" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.6.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="OpenCvSharp4" Version="4.8.0.20230708" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.8.0.20230708" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.5.1-preview.1" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20240616" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20240616" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="2.6.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit b870710

Please sign in to comment.