From a9bc7819f4f7e66159a93e955944728c25ba3e53 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期三, 07 一月 2026 14:10:11 +0800
Subject: [PATCH] 优化相机管理和界面布局 - 在 `CreateCameraForm.cs` 中添加对 `LBCameras` 的引用,并修复相机创建逻辑。 - 调整 `VisionForm.Designer.cs` 和 `2DCameraForm.Designer.cs` 中多个控件的大小和位置,改善界面布局。 - 在 `VisionForm.cs` 中添加对 `LBCameras` 的引用以支持新相机类型。 - 注释掉 `PHM6000Sensor.cs` 和 `PHM6000Profiler.cs` 中与相机信息获取相关的 P/Invoke 方法。 - 重构 `LBCamera.cs`,添加新的相机初始化和参数设置逻辑,确保与 PHM6000 SDK 的兼容性。 - 移除 `PHM6000Camera.cs` 中与 `PHM6000Camera` 相关的代码,简化相机管理逻辑。 Merge branch 'master' of http://lanpucloud.cn:1111/r/~zhengyabo/LB_TyreAppearanceInspectionSoftware
---
LB_VisionProcesses/Cameras/CameraConfig.cs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/LB_VisionProcesses/Cameras/CameraConfig.cs b/LB_VisionProcesses/Cameras/CameraConfig.cs
index 66303bd..4bec6f7 100644
--- a/LB_VisionProcesses/Cameras/CameraConfig.cs
+++ b/LB_VisionProcesses/Cameras/CameraConfig.cs
@@ -1,6 +1,9 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing HalconDotNet;
+using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using OpenCvSharp;
+using OpenCvSharp.Extensions;
+using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Text;
@@ -190,7 +193,7 @@
Mat src = Cv2.ImRead(SN);
if (src != null && !src.Empty())
- OutputImage = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src);
+ OutputImage = src.ToBitmap();
}
}
}
@@ -256,12 +259,17 @@
{
times--;
if (TriggerSource == TriggerSource.Software)
+ {
Camera.GetImageWithSoftTrigger(out bitmap, timeout);
+ }
else
+ {
Camera.GetImage(out bitmap, timeout);
-
+ }
if (bitmap != null)
+ {
break;
+ }
else if (isRegrab)
{
Debug.WriteLine($"鍙栧浘澶辫触,閲嶆柊鍙栧浘,鍓╀綑娆℃暟:{times}");
@@ -269,8 +277,9 @@
} while (times > 0 && isRegrab);
if (isUpParams)
+ {
Camera.SetCamConfig(oriConfig);
-
+ }
OutputImage = bitmap;
}
@@ -293,14 +302,49 @@
{
Result = true;
Msg = "";
- OutputImage = null;
+ if (OutputImage != null)
+ {
+ if (OutputImage is HObject)
+ ((HObject)OutputImage).Dispose();
+ else if (OutputImage is Mat)
+ ((Mat)OutputImage).Dispose();
+ else if (OutputImage is Bitmap)
+ ((Bitmap)OutputImage).Dispose();
+ OutputImage = null;
+ }
if (Record != null)
+ {
Record.Dispose();
+ Record = null;
+ }
}
public override void Dispose()
{
+ if (InputImage != null)
+ {
+ if (InputImage is HObject)
+ ((HObject)InputImage).Dispose();
+ else if (InputImage is Mat)
+ ((Mat)InputImage).Dispose();
+ else if (InputImage is Bitmap)
+ ((Bitmap)InputImage).Dispose();
+
+ InputImage = null;
+ }
+
+ if (OutputImage != null)
+ {
+ if (OutputImage is HObject)
+ ((HObject)OutputImage).Dispose();
+ else if (OutputImage is Mat)
+ ((Mat)OutputImage).Dispose();
+ else if (OutputImage is Bitmap)
+ ((Bitmap)OutputImage).Dispose();
+
+ OutputImage = null;
+ }
return;
}
@@ -314,7 +358,9 @@
if (OutputImage != null)
{
if (OutputImage is Bitmap)
+ {
obj.OutputImage = ((Bitmap)OutputImage).Clone();
+ }
}
return obj;
--
Gitblit v1.9.3