namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Access { /// /// 从局部图像(局部图像)获取图片 /// public class GetImageFromProcessHandler : IVisionFlowHandler { /// /// 类型 /// public VisionFlowType Type => VisionFlowType.从局部图像获取图片; /// /// 执行 /// /// 视觉功能 /// 变量项 /// 返回布尔值 public bool Execute(VisionFunction func, VisionFlow item) { if (item.StringParams.TryGetValue("Image", out string imageName)) { var theMat = func.LocalImageDatas.Where(w => w.Name == imageName).FirstOrDefault(); if (theMat != null) { func.Src = theMat.Mat.Clone(); item.Flow.Done = true; return true; } else { throw new Exception("未找到局部图像!"); } } throw new Exception("未配置局部图像名称!"); } } }