diff --git a/DH.Commons/Base/VisionEngineBase.cs b/DH.Commons/Base/VisionEngineBase.cs index dc1a769..f713dfb 100644 --- a/DH.Commons/Base/VisionEngineBase.cs +++ b/DH.Commons/Base/VisionEngineBase.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Drawing; using System.Drawing.Imaging; using DH.Commons.Enums; +using DH.Commons.Helper; using HalconDotNet; using OpenCvSharp; @@ -58,7 +59,8 @@ namespace DH.Commons.Base ImageSaveSet imageSaveSet = new ImageSaveSet() { FullName = fullname, - SaveImage = saveMap, + SaveImage = saveMap.CopyBitmap(), + ImageFormat = imageFormat.DeepSerializeClone() }; diff --git a/DH.Commons/DH.Commons.csproj b/DH.Commons/DH.Commons.csproj index 41a3dcc..1664e90 100644 --- a/DH.Commons/DH.Commons.csproj +++ b/DH.Commons/DH.Commons.csproj @@ -15,6 +15,7 @@ <ItemGroup> <PackageReference Include="AntdUI" Version="1.8.9" /> + <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" /> <PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" /> <PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" /> diff --git a/DH.Commons/Helper/StaticHelper.cs b/DH.Commons/Helper/StaticHelper.cs index e80421b..3a75811 100644 --- a/DH.Commons/Helper/StaticHelper.cs +++ b/DH.Commons/Helper/StaticHelper.cs @@ -1,5 +1,5 @@ using Microsoft.CSharp.RuntimeBinder; - +using Newtonsoft.Json; using System.Collections.ObjectModel; using System.Drawing.Imaging; using System.Dynamic; @@ -34,7 +34,10 @@ namespace DH.Commons.Helper return result; } - + public static T DeepSerializeClone<T>(this T t) + { + return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(t)); + } /// <summary> /// 字节数组转换为整数 /// </summary> diff --git a/DH.Devices.Vision/DH.Devices.Vision.csproj b/DH.Devices.Vision/DH.Devices.Vision.csproj index a1dfe88..cbe8a69 100644 --- a/DH.Devices.Vision/DH.Devices.Vision.csproj +++ b/DH.Devices.Vision/DH.Devices.Vision.csproj @@ -11,6 +11,14 @@ <Platforms>AnyCPU;x64</Platforms> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> + <Optimize>False</Optimize> + </PropertyGroup> + + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Optimize>False</Optimize> + </PropertyGroup> +