using Hawkeye.VisionBuilder.Workflow.Configuration; using Hawkeye.VisionBuilder.Workflow.Datatypes; using Hawkeye.VisionBuilder.Workflow.Links; using OpenCvSharp; using OpenCvSharp.Extensions; using Rectangle = Hawkeye.VisionBuilder.Workflow.Datatypes.Elements.Rectangle.RectangleElement; namespace Hawkeye.VisionBuilder.Workflow.Operations; public class GetImageOperation:BaseOperation,IHaveImage { private readonly WorkflowList _workflowList; public GetImageOperation(WorkflowList workflowList) { _workflowList = workflowList; } public HawkeyeImage? Image { get; set; } protected override void InterpretInternal(Context context) { var image = _workflowList.ImageSource.GetImage(context.CancellationToken).Result; context.ActiveImage = new HawkeyeImage(){ImageData = image}; context.LastCameraImage = context.ActiveImage; Image = context.ActiveImage; if (CheckImageExists(context)) { Status= $"Image size: {context.ActiveImage.ImageData.Width}x{context.ActiveImage.ImageData.Height}"; Result = true; } else { Status = "No image"; Result = false; } } /// /// Save the operation to the binary writer /// /// public override void Save(BinaryWriter bw) { bw.Write(Id.ToString()); bw.Write(Label); } /// /// Load the operation from the binary reader /// /// public override void Load(BinaryReader br) { Id = new Guid(br.ReadString()); Label = br.ReadString(); } }