From df5faaa04b582bec2ae7636478f72996a608f8c3 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期五, 26 十二月 2025 12:27:15 +0800
Subject: [PATCH] ”添加运动控制功能。“
---
LB_SmartVision/ProcessRun/ProcessContext.cs | 68 ++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/LB_SmartVision/ProcessRun/ProcessContext.cs b/LB_SmartVision/ProcessRun/ProcessContext.cs
index 0604acf..ff803a2 100644
--- a/LB_SmartVision/ProcessRun/ProcessContext.cs
+++ b/LB_SmartVision/ProcessRun/ProcessContext.cs
@@ -301,7 +301,7 @@
return res;
}
- public bool GetImage(Layout layout, out HObject InputImage, out HObject RecordImage)
+ public bool GetImage(Layout layout, out HImage InputImage, out HObject RecordImage)
{
InputImage = null; RecordImage = null;
try
@@ -329,24 +329,37 @@
IndexValueName = arrOutputs[2];
object o_InputImage = ((IProcess)dicContext[IndexProcessName]).OutputImage;
- if (o_InputImage is HObject ho_image && ho_image.IsInitialized())
- InputImage = ho_image;
- else if (o_InputImage is Bitmap)
+ if (o_InputImage != null && o_InputImage is HImage ho_image && ho_image.IsInitialized())
{
- //灏哅at杞崲涓篐Object
- TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage, out HObject ho_RecordImage);
- InputImage = ho_RecordImage;
+ InputImage = ho_image.Clone();
+ ho_image.Dispose();
}
- else if (o_InputImage is Mat)
+ else if (o_InputImage != null && o_InputImage is Bitmap)
{
//灏哅at杞崲涓篐Object
- TAlgorithm.Mat2HObject((Mat)o_InputImage, out HObject ho_RecordImage);
- InputImage = ho_RecordImage;
+ using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage))
+ {
+ if (ho_RecordImage != null)
+ {
+ InputImage = ho_RecordImage.Clone();
+ }
+ }
+ }
+ else if (o_InputImage != null && o_InputImage is Mat)
+ {
+ //灏哅at杞崲涓篐Object
+ using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage))
+ {
+ if (ho_RecordImage != null)
+ {
+ InputImage = ho_RecordImage.Clone();
+ }
+ }
}
if (InputImage != null && InputImage.IsInitialized())
{
- HOperatorSet.GetImageSize(InputImage, out ho_ImageWidth, out ho_ImageHeight);
+ InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight);
//鍥剧墖灏哄鍙樺寲鎵嶆洿鏂扮獥鍙e昂瀵竅鎻愰珮閫熷害]
if ((ho_ImageWidth.Length > 0 && ho_ImageWidth.TupleInt() != hWindowControl.Size.Width)
@@ -489,7 +502,38 @@
if (dicContext.TryGetValue(ProcessName, out IProcess obj)
&& obj is IProcess process)
{
- process.InputImage = null;
+ if (process.InputImage != null)
+ {
+ if (process.InputImage is HObject)
+ {
+ ((HObject)process.InputImage).Dispose();
+ }
+ else if (process.InputImage is Mat)
+ {
+ ((Mat)process.InputImage).Dispose();
+ }
+ else if (process.InputImage is Bitmap)
+ {
+ ((Bitmap)process.InputImage).Dispose();
+ }
+ process.InputImage = null;
+ }
+ if (process.OutputImage != null)
+ {
+ if (process.OutputImage is HObject)
+ {
+ ((HObject)process.OutputImage).Dispose();
+ }
+ else if (process.OutputImage is Mat)
+ {
+ ((Mat)process.OutputImage).Dispose();
+ }
+ else if (process.OutputImage is Bitmap)
+ {
+ ((Bitmap)process.OutputImage).Dispose();
+ }
+ process.OutputImage = null;
+ }
UpdateInputs(process);
// 涓嶅悓鑺傜偣璺宠繃鐨勬柟寮忎笉鍚�
--
Gitblit v1.9.3