From ed0b1e3c75489ea76e01b1c6bebd3bb2d90e7535 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期四, 25 十二月 2025 09:49:34 +0800
Subject: [PATCH] 修复log显示以及文件大小问题。

---
 LB_VisionProcesses/Cameras/CameraConfig.cs |   47 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/LB_VisionProcesses/Cameras/CameraConfig.cs b/LB_VisionProcesses/Cameras/CameraConfig.cs
index fa0bb79..86ebc86 100644
--- a/LB_VisionProcesses/Cameras/CameraConfig.cs
+++ b/LB_VisionProcesses/Cameras/CameraConfig.cs
@@ -206,12 +206,24 @@
                         return Result;
                     }
 
-                    if (Camera == null || Camera.SN != SN)
+                    // 濮嬬粓妫�鏌ョ紦瀛樼殑Camera瀵硅薄鏄惁涓庡叏灞�瀛楀吀涓殑涓�鑷�
+                    // 闃叉鐩告満琚垹闄ゅ苟閲嶅缓鍚�(SN鐩稿悓), 浠嶇劧寮曠敤鏃х殑宸查攢姣佸璞�
+                    if (dicCameras.ContainsKey(SN))
                     {
-                        if (dicCameras.ContainsKey(SN))
-                            Camera = dicCameras[SN];
-                        else
-                            Camera = null;
+                        var currentCam = dicCameras[SN];
+                        if (Camera != currentCam)
+                        {
+                            Camera = currentCam;
+                            // 濡傛灉鍒囨崲浜嗙浉鏈哄疄渚嬶紝涓旀湭寮�濮嬮噰闆嗭紝灏濊瘯寮�鍚噰闆�
+                            if (Camera != null && !Camera.isGrabbing)
+                            {
+                                try { Camera.StartGrabbing(); } catch { }
+                            }
+                        }
+                    }
+                    else
+                    {
+                        Camera = null;
                     }
 
                     if (Camera == null)
@@ -244,12 +256,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}");
@@ -257,8 +274,9 @@
                     } while (times > 0 && isRegrab);
 
                     if (isUpParams)
+                    {
                         Camera.SetCamConfig(oriConfig);
-
+                    }
                     OutputImage = bitmap;
                 }
 
@@ -281,14 +299,23 @@
         {
             Result = true;
             Msg = "";
-            OutputImage = null;
-
+            if (OutputImage != null)
+            {
+                if (OutputImage is Bitmap)
+                {
+                    ((Bitmap)OutputImage).Dispose();
+                }
+                OutputImage = null;
+            }
             if (Record != null)
+            {
                 Record.Dispose();
+            }
         }
 
         public override void Dispose()
         {
+
             return;
         }
 
@@ -302,7 +329,9 @@
                 if (OutputImage != null)
                 {
                     if (OutputImage is Bitmap)
+                    {
                         obj.OutputImage = ((Bitmap)OutputImage).Clone();
+                    }
                 }
 
                 return obj;

--
Gitblit v1.9.3