check point
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
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(CancellationToken.None).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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Save the operation to the binary writer
|
||||
/// </summary>
|
||||
/// <param name="bw"></param>
|
||||
public override void Save(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(Id.ToString());
|
||||
bw.Write(Label);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the operation from the binary reader
|
||||
/// </summary>
|
||||
/// <param name="br"></param>
|
||||
public override void Load(BinaryReader br)
|
||||
{
|
||||
Id = new Guid(br.ReadString());
|
||||
Label = br.ReadString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user