mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-15 07:43:20 +08:00
fix: 修复 RunMulti 中 Mat 所有权语义不明确导致的潜在 Dispose 问题 (#2730)
This commit is contained in:
@@ -95,7 +95,10 @@ public class Rec(
|
||||
// .AsParallel()
|
||||
.Select(src =>
|
||||
{
|
||||
using var channel3 = src.Channels() switch
|
||||
Mat? channel3 = default;
|
||||
try
|
||||
{
|
||||
channel3 = src.Channels() switch
|
||||
{
|
||||
4 => src.CvtColor(ColorConversionCodes.BGRA2BGR),
|
||||
1 => src.CvtColor(ColorConversionCodes.GRAY2BGR),
|
||||
@@ -110,6 +113,15 @@ public class Rec(
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Only dispose Mats created in this scope
|
||||
if (channel3 != null && !ReferenceEquals(channel3, src))
|
||||
{
|
||||
channel3.Dispose();
|
||||
}
|
||||
}
|
||||
})
|
||||
.Select(inputTensor =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user