能用 大概

This commit is contained in:
JEFF 2025-01-16 19:11:55 +08:00
parent 4bcbd8e920
commit 5fa4d4dd60

View File

@ -178,6 +178,7 @@ namespace Camera_connect
if (Basler != null) if (Basler != null)
{ {
Basler.KeepShot(); // 啟動連續拍攝 Basler.KeepShot(); // 啟動連續拍攝
isKeepShotting = true;
} }
else else
{ {
@ -198,8 +199,9 @@ namespace Camera_connect
if (selectedCamera == "IDS") if (selectedCamera == "IDS")
{ {
cts.Cancel(); cts.Cancel(); // 停止拍攝
isKeepShotting = false; isKeepShotting = false;
Label_status.Text = "IDS結束連續取像";
} }
else if (selectedCamera == "Basler") else if (selectedCamera == "Basler")
{ {
@ -207,6 +209,7 @@ namespace Camera_connect
{ {
Basler.Stop(); Basler.Stop();
Basler.CameraImageEvent -= Camera_CameraImageEvent; Basler.CameraImageEvent -= Camera_CameraImageEvent;
Label_status.Text = "basler結束連續取像";
} }
} }
} }
@ -235,13 +238,16 @@ namespace Camera_connect
// 更新 PictureBox 圖像 // 更新 PictureBox 圖像
pictureBox1.Invoke((MethodInvoker)delegate pictureBox1.Invoke((MethodInvoker)delegate
{ {
Bitmap oldImage = pictureBox1.Image as Bitmap;
pictureBox1.Image = image; pictureBox1.Image = image;
oldImage?.Dispose(); // 確保釋放舊的 Bitmap 資源
}); });
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
// 可以選擇記錄日誌或顯示錯誤訊息 // 可以選擇記錄日誌或顯示錯誤訊息
Console.WriteLine($"捕獲影像時發生錯誤:{ex.Message}");
} }
} }
}, token); }, token);