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