namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Access { /// /// 获取From全局图像Handler /// public class GetFromGlobalImageHandler : IVisionFlowHandler { /// /// 类型 /// public VisionFlowType Type => VisionFlowType.从全局图像获取图片; /// /// 执行 /// /// 视觉功能 /// 变量项 /// 返回布尔值 public bool Execute(VisionFunction func, VisionFlow item) { if (item.StringParams.TryGetValue("Image", out string imageName)) { var imageData = func.ImageDatas.Where(i => i.Name == imageName).FirstOrDefault(); if (imageData != null) { func.Src = imageData.Mat.Clone(); return true; } else { throw new Exception("图像池中未找到对应图片!"); } } return false; } } }